[patch] configure --enable-developer and non-gcc

James E. Flemer jflemer at uvm.edu
Wed Jan 14 02:58:42 GMT 2004


Here is an updated patch for the problems I previously mentioned
concerning --enable-developer.  This patch makes AC_PROG_CC_FLAG take
arguments with both dash (-) and space ( ).  It also does save and
restore CFLAGS around AC_PROG_CC, but only when developer mode is
enabled, otherwise it lets AC_PROG_CC set the default CFLAGS.  The
CFLAGS are restored when developer mode is enabled to prevent -O2 from
being added by AC_PROG_CC.  Additionaly, the AC_PROG_CC_FLAG(-gstabs)
check is no longer present, as it returned a false positive on at least
one compiler.  Instead, -gstabs is used if gcc is detected by
AC_PROG_CC, otherwise -g is used if it is accepted.

(I also fixed the inverted logic for -Wstrict-prototypes present in the
previous patch.)

-James
-------------- next part --------------
Index: aclocal.m4
===================================================================
RCS file: /cvsroot/samba/source/aclocal.m4,v
retrieving revision 1.31
diff -u -r1.31 aclocal.m4
--- aclocal.m4	13 Nov 2003 17:04:59 -0000	1.31
+++ aclocal.m4	7 Jan 2004 03:55:25 -0000
@@ -78,14 +78,14 @@
 
 dnl AC_PROG_CC_FLAG(flag)
 AC_DEFUN(AC_PROG_CC_FLAG,
-[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
-[echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
-  ac_cv_prog_cc_$1=yes
-else
-  ac_cv_prog_cc_$1=no
-fi
-rm -f conftest*
+         [AC_CACHE_CHECK(whether ${CC-cc} accepts $1,
+	                 [ac_cv_prog_cc_]translit([$1], [-A-Z ], [_a-z_]),
+[ ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="${CFLAGS} $1"
+  AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])],
+    [ac_cv_prog_cc_]translit([$1], [-A-Z ], [_a-z_])[=yes],
+    [ac_cv_prog_cc_]translit([$1], [-A-Z ], [_a-z_])[=no])
+  CFLAGS="${ac_save_CFLAGS}"
 ])])
 
 dnl see if a declaration exists for a function or variable
Index: configure.in
===================================================================
RCS file: /cvsroot/samba/source/configure.in,v
retrieving revision 1.511
diff -u -r1.511 configure.in
--- configure.in	12 Dec 2003 20:15:47 -0000	1.511
+++ configure.in	7 Jan 2004 03:55:26 -0000
@@ -184,25 +184,6 @@
 AC_SUBST(EXTRA_ALL_TARGETS)
 AC_SUBST(CONFIG_LIBS)
 
-AC_ARG_ENABLE(debug, 
-[  --enable-debug          Turn on compiler debugging information (default=no)],
-    [if eval "test x$enable_debug = xyes"; then
-        echo "DEBUGGING TURNED ON!!!!"
-	CFLAGS="${CFLAGS} -g"
-    fi])
-
-AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
-    [if eval "test x$enable_developer = xyes"; then
-        developer=yes
-    	CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
-    fi])
-
-AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
-    [if eval "test x$enable_krb5developer = xyes"; then
-        developer=yes
-	CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
-    fi])
-
 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
 
 if test "x$enable_dmalloc" = xyes
@@ -216,16 +197,67 @@
 dnl Checks for programs.
 
 ##
-## for some reason this macro resets the CFLAGS
-## so save and restore
+## AC_PROG_CC sets CFLAGS (to "-g -O2") if it is not already set.
+## Save CFLAGS so that if developer mode is enabled the old CFLAGS
+## can be used to avoid using the "-O2" flag.
 ##
 OLD_CFLAGS=${CFLAGS}
 AC_PROG_CC
-CFLAGS=${OLD_CFLAGS}
 
-OLD_CFLAGS=${CFLAGS}
+dnl Check for developer build
+developer=no
+AC_ARG_ENABLE(developer,
+    [  --enable-developer      Turn on developer warnings and debugging (default=no)],
+    [if test "x$enable_developer" = xyes; then developer=yes; fi])
+
+AC_ARG_ENABLE(krb5developer,
+    [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
+    [if test "x$enable_krb5developer" = xyes; then developer=krb5; fi])
+
+dnl Set extra CFLAGS for developers
+if test "x$developer" != xno; then
+  # use OLD_CFLAGS to avoid any changes AC_PROG_CC made
+  CFLAGS="${OLD_CFLAGS}"
+  if test x"$GCC" = xyes; then
+    CFLAGS="${CFLAGS} -gstabs"
+  else if test x"$ac_cv_prog_cc_g" = xyes; then
+    CFLAGS="${CFLAGS} -g"
+  fi
+  fi
+  AC_PROG_CC_FLAG([-Wall])
+  if test x"$ac_cv_prog_cc__wall" = xyes; then
+      CFLAGS="${CFLAGS} -Wall"
+  fi
+  AC_PROG_CC_FLAG([-Wshadow])
+  if test x"$ac_cv_prog_cc__wshadow" = xyes; then
+      CFLAGS="${CFLAGS} -Wshadow"
+  fi
+  if test x"$developer" != xkrb5; then
+    AC_PROG_CC_FLAG([-Wstrict-prototypes])
+    if test x"$ac_cv_prog_cc__wstrict_prototypes" = xyes; then
+        CFLAGS="${CFLAGS} -Wstrict-prototypes"
+    fi
+  fi
+  AC_PROG_CC_FLAG([-Wpointer-arith])
+  if test x"$ac_cv_prog_cc__wpointer_arith" = xyes; then
+      CFLAGS="${CFLAGS} -Wpointer-arith"
+  fi
+  AC_PROG_CC_FLAG([-Wcast-qual])
+  if test x"$ac_cv_prog_cc__wcast_qual" = xyes; then
+      CFLAGS="${CFLAGS} -Wcast-qual"
+  fi
+  AC_PROG_CC_FLAG([-Wcast-align])
+  if test x"$ac_cv_prog_cc__wcast_align" = xyes; then
+      CFLAGS="${CFLAGS} -Wcast-align"
+  fi
+  AC_PROG_CC_FLAG([-Wwrite-strings])
+  if test x"$ac_cv_prog_cc__wwrite_strings" = xyes; then
+      CFLAGS="${CFLAGS} -Wwrite-strings"
+  fi
+  CFLAGS="${CFLAGS} -DDEBUG_PASSWORD -DDEVELOPER"
+fi
+
 AC_PROG_CPP
-CFLAGS=${OLD_CFLAGS}
 
 AC_PROG_INSTALL
 AC_PROG_AWK
@@ -233,13 +265,6 @@
 
 AC_CHECK_TOOL(AR, ar)
 
-# compile with optimization and without debugging by default, but
-# allow people to set their own preference.
-if test "x$CFLAGS" = x
-then
-  CFLAGS="-O ${CFLAGS}"
-fi
-
 dnl Check if we use GNU ld
 LD=ld
 AC_PROG_LD_GNU
@@ -326,7 +351,7 @@
 dnl These are preferably build shared, and static if dlopen() is not available
 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap charset_CP850 charset_CP437"
 
-if test "x$developer" = xyes; then
+if test "x$developer" != xno; then
    default_static_modules="$default_static_modules rpc_echo"
    default_shared_modules="$default_shared_modules charset_weird"
 fi
@@ -339,10 +364,10 @@
 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
     *hpux*)
     
-      AC_PROG_CC_FLAG(Ae)
+      AC_PROG_CC_FLAG([-Ae])
       # mmap on HPUX is completely broken...
       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
-      if test $ac_cv_prog_cc_Ae = yes; then
+      if test $ac_cv_prog_cc__ae = yes; then
         CPPFLAGS="$CPPFLAGS -Ae"
       fi
 #


More information about the samba-technical mailing list