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

James Flemer jflemer at uvm.edu
Tue Jan 6 02:32:49 GMT 2004


The attched patch makes a few changes to the Samba configure script.
It changes the AC_PROG_CC_FLAG macro to handle a wider range of flags,
mainly flags with dashes (-) in them.  It then uses this improved
macro to make the --enable-developer option check that the flags it wants
to add are accepted by the compiler (since not everyone uses gcc).
The --enable-developer checks were moved after AC_PROG_CC so that
the -g flag does not have to be checked twice.

This patch also removes some useless code.  The saving and restoring
of CFLAGS is not needed for AC_PROG_CPP.  The AC_PROG_CC macro does
changes CFLAGS, but saving and restoring is not needed.  AC_PROG_CC
sets CFLAGS only if it is empty to begin with.  If CFLAGS is unset,
it adds -g if it is accepted by the compiler, and it adds -O2 if the
compiler is gcc.  Letting AC_PROG_CC do it's thing makes the defaulting
of CFLAGS to "-O" pointless (especially since that flags may not
be accepted by all compilers.)  It also makes the --enable-debug
option pointless; I belive --enable-developer pretty much makes
--enable-debug pointless anyway.

These patches (and comments on autoconf behavior) were tested with
autoconf 2.53 only.  Perhaps someone using 2.57 should verify that
they do not have any problems with that version.

-James

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	6 Jan 2004 02:07:28 -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_COMPILE_IFELSE([void f(){}],
+    [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	6 Jan 2004 02:07:29 -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
@@ -214,18 +195,9 @@
 fi
 
 dnl Checks for programs.
-
-##
-## for some reason this macro resets the CFLAGS
-## so save and restore
-##
-OLD_CFLAGS=${CFLAGS}
 AC_PROG_CC
-CFLAGS=${OLD_CFLAGS}
 
-OLD_CFLAGS=${CFLAGS}
 AC_PROG_CPP
-CFLAGS=${OLD_CFLAGS}
 
 AC_PROG_INSTALL
 AC_PROG_AWK
@@ -233,11 +205,55 @@
 
 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}"
+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
+  AC_PROG_CC_FLAG([-gstabs])
+  if test x"$ac_cv_prog_cc__gstabs" = 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
 
 dnl Check if we use GNU ld
@@ -326,7 +342,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 +355,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