r10077: - move gcc option checks to check_cc.m4
authorStefan Metzmacher <metze@samba.org>
Thu, 8 Sep 2005 11:01:39 +0000 (11:01 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:37:51 +0000 (13:37 -0500)
- only use -g if supported
- don't allow AC_PROG_C and friends to autoset the CFLAGS
  (we don't want -g -02 by default..., maybe a configure option
   for -OX could be useful...)

metze

source/build/m4/check_cc.m4
source/build/m4/check_path.m4

index 3ca69c9f87a328beb8b05ab2eafedb29dc0072ae..19261d50b6c9b9f0b1f7b3a0195d229ea36d6291 100644 (file)
@@ -5,13 +5,23 @@ dnl  Released under the GNU GPL
 dnl -------------------------------------------------------
 dnl
 
+# don't let the AC_PROG_CC macro auto set the CFLAGS
+OLD_CFLAGS="${CFLAGS}"
 AC_PROG_CC
+CFLAGS="${OLD_CFLAGS}"
 if test x"$CC" = x""; then
        AC_MSG_WARN([No c compiler was not found!])
        AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
 fi
 
-AC_C_INLINE
+#
+# Set the debug symbol option if we have
+# --enable-*developer or --enable-debug
+# and the compiler supports it
+#
+if test x$ac_cv_prog_cc_g = xyes -a x$debug = xyes; then
+       CFLAGS="${CFLAGS} -g"
+fi
 
 dnl needed before AC_TRY_COMPILE
 AC_ISC_POSIX
@@ -110,6 +120,27 @@ AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
 # Check if the compiler can handle the options we selected by
 # --enable-*developer
 #
+DEVELOPER_CFLAGS=""
+if test x$developer = xyes; then
+       DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
+       if test x"$GCC" = x"yes" ; then
+           OLD_CFLAGS="${CFLAGS}"
+           CFLAGS="${CFLAGS} -D_SAMBA_DEVELOPER_DONNOT_USE_O2_"
+           AX_CFLAGS_GCC_OPTION(-Wall, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wshadow, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Werror-implicit-function-declaration, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wpointer-arith, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wcast-qual, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wcast-align, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wwrite-strings, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS)
+           AX_CFLAGS_GCC_OPTION(-Wno-declaration-after-statement, DEVELOPER_CFLAGS)
+           CFLAGS="${OLD_CFLAGS}"
+       fi
+fi
 if test -n "$DEVELOPER_CFLAGS"; then
        OLD_CFLAGS="${CFLAGS}"
        CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
index 3c626ee0d0dc501791894495279f029f967bbf91..3e46c16cbfbbfb78df1b3f77c86f39af9d3ac468 100644 (file)
@@ -145,45 +145,29 @@ AC_ARG_WITH(selftest-prefix,
     ;;
   esac])
 
+debug=no
+AC_ARG_ENABLE(debug,
+[  --enable-debug          Turn on compiler debugging information (default=no)],
+    [if test x$enable_debug = xyes; then
+        debug=yes
+    fi])
+
 developer=no
 AC_SUBST(developer)
-AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
+AC_ARG_ENABLE(developer,
+[  --enable-developer      Turn on developer warnings and debugging (default=no)],
     [if test x$enable_developer = xyes; then
        debug=yes
         developer=yes
-       DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
-       if test x"$GCC" = x"yes" ; then
-           AX_CFLAGS_GCC_OPTION(-Wall, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wshadow, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Werror-implicit-function-declaration, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wpointer-arith, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wcast-qual, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wcast-align, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wwrite-strings, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS)
-           AX_CFLAGS_GCC_OPTION(-Wno-declaration-after-statement, DEVELOPER_CFLAGS)
-       fi
-    fi])
-
-debug=no
-AC_ARG_ENABLE(debug, 
-[  --enable-debug          Turn on compiler debugging information (default=no)],
-    [if test x$enable_debug = xyes -a x$enable_developer != xyes; then
-        debug=yes
-       CFLAGS="${CFLAGS} -g"
     fi])
 
-
 experimental=no
-AC_ARG_ENABLE(experimental, [  --enable-experimental Turn on experimental features (default=no)],
-    [if eval "test x$enable_experimental = xyes"; then
+AC_ARG_ENABLE(experimental,
+[  --enable-experimental   Turn on experimental features (default=no)],
+    [if test x$enable_experimental = xyes; then
         experimental=yes
     fi])
 
-
 dnl disable these external libs 
 AC_ARG_WITH(disable-ext-lib,
 [  --with-disable-ext-lib=LIB Comma-seperated list of external libraries],