Summary: minor, provide malldbg multiarg for MALLOC_PERTURB_
[sxemacs] / m4 / sxe-compiler.m4
index dac0909..12fd03b 100644 (file)
@@ -607,12 +607,14 @@ AC_DEFUN([SXE_WARNFLAGS], [dnl
        ## Warnings about char subscripts are pretty
        ## pointless, though,
        ## and we use them in various places.
-       SXE_CHECK_COMPILER_FLAGS([-Wsign-compare], [
-               warnflags="$warnflags -Wsign-compare"])
-       SXE_CHECK_COMPILER_FLAGS([-Wno-char-subscripts], [
-               warnflags="$warnflags -Wno-char-subscripts"])
-       SXE_CHECK_COMPILER_FLAGS([-Wundef], [
-               warnflags="$warnflags -Wundef"])
+       if test "${with_maximum_warning_output}" = "yes"; then
+               SXE_CHECK_COMPILER_FLAGS([-Wsign-compare], [
+                       warnflags="$warnflags -Wsign-compare"])
+               SXE_CHECK_COMPILER_FLAGS([-Wno-char-subscripts], [
+                       warnflags="$warnflags -Wno-char-subscripts"])
+               SXE_CHECK_COMPILER_FLAGS([-Wundef], [
+                       warnflags="$warnflags -Wundef"])
+       fi
 
        ## too much at the moment, we rarely define protos
        #warnflags="$warnflags -Wmissing-prototypes -Wstrict-prototypes"
@@ -634,8 +636,6 @@ AC_DEFUN([SXE_WARNFLAGS], [dnl
                warnflags="$warnflags -Wmissing-declarations"])
        SXE_CHECK_COMPILER_FLAGS([-Wmissing-prototypes], [
                warnflags="$warnflags -Wmissing-prototypes"])
-       SXE_CHECK_COMPILER_FLAGS([-Winline], [
-               warnflags="$warnflags -Winline"])
        SXE_CHECK_COMPILER_FLAGS([-Wbad-function-cast], [
                warnflags="$warnflags -Wbad-function-cast"])
        SXE_CHECK_COMPILER_FLAGS([-Wcast-qual], [
@@ -643,25 +643,35 @@ AC_DEFUN([SXE_WARNFLAGS], [dnl
        SXE_CHECK_COMPILER_FLAGS([-Wcast-align], [
                warnflags="$warnflags -Wcast-align"])
 
+       ## too aggressive innit
+       if test "${with_maximum_warning_output}" = "yes"; then
+               SXE_CHECK_COMPILER_FLAGS([-Winline], [
+                       warnflags="$warnflags -Winline"])
+       fi
+
        ## warn about incomplete switches
-       SXE_CHECK_COMPILER_FLAGS([-Wswitch], [
-               warnflags="$warnflags -Wswitch"])
-       SXE_CHECK_COMPILER_FLAGS([-Wswitch-default], [
-               warnflags="$warnflags -Wswitch-default"])
-       SXE_CHECK_COMPILER_FLAGS([-Wswitch-enum], [
-               warnflags="$warnflags -Wswitch-enum"])
+       if test "${with_maximum_warning_output}" = "yes"; then
+               SXE_CHECK_COMPILER_FLAGS([-Wswitch], [
+                       warnflags="$warnflags -Wswitch"])
+               SXE_CHECK_COMPILER_FLAGS([-Wswitch-default], [
+                       warnflags="$warnflags -Wswitch-default"])
+               SXE_CHECK_COMPILER_FLAGS([-Wswitch-enum], [
+                       warnflags="$warnflags -Wswitch-enum"])
+       fi
 
        ## Wunused's
-       SXE_CHECK_COMPILER_FLAGS([-Wunused-function], [
-               warnflags="$warnflags -Wunused-function"])
-       SXE_CHECK_COMPILER_FLAGS([-Wunused-variable], [
-               warnflags="$warnflags -Wunused-variable"])
-       SXE_CHECK_COMPILER_FLAGS([-Wunused-parameter], [
-               warnflags="$warnflags -Wunused-parameter"])
-       SXE_CHECK_COMPILER_FLAGS([-Wunused-value], [
-               warnflags="$warnflags -Wunused-value"])
-       SXE_CHECK_COMPILER_FLAGS([-Wunused], [
-               warnflags="$warnflags -Wunused"])
+       if test "${with_maximum_warning_output}" = "yes"; then
+               SXE_CHECK_COMPILER_FLAGS([-Wunused-function], [
+                       warnflags="$warnflags -Wunused-function"])
+               SXE_CHECK_COMPILER_FLAGS([-Wunused-variable], [
+                       warnflags="$warnflags -Wunused-variable"])
+               SXE_CHECK_COMPILER_FLAGS([-Wunused-parameter], [
+                       warnflags="$warnflags -Wunused-parameter"])
+               SXE_CHECK_COMPILER_FLAGS([-Wunused-value], [
+                       warnflags="$warnflags -Wunused-value"])
+               SXE_CHECK_COMPILER_FLAGS([-Wunused], [
+                       warnflags="$warnflags -Wunused"])
+       fi
 
        ## icc
        SXE_CHECK_COMPILER_FLAGS([-Wreorder], [
@@ -975,14 +985,6 @@ dnl                [optiflags="$optiflags -fstrict-aliasing"])
        SXE_CHECK_COMPILER_FLAGS([-fsection-anchors],
                [optiflags="$optiflags -fsection-anchors"])
 
-dnl    ## actually this belongs to error-checking stuff
-dnl    SXE_CHECK_COMPILER_FLAGS([-fstack-protector],
-dnl            [optiflags="$optiflags -fstack-protector"])
-dnl    if test "$sxe_cv_c_flags__fstack_protector" = "yes"; then
-dnl            ## just check for ssp in this case
-dnl            AC_CHECK_LIB([ssp], [__stack_chk_guard])
-dnl    fi
-
        SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize])
        SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize2])
        if test "$sxe_cv_c_flags__fbranch_target_load_optimize2" = "yes"; then
@@ -1602,6 +1604,16 @@ extern void f(void*restrict[]);
        AC_MSG_RESULT([$typeofname])
 ])dnl SXE_CHECK_BROKEN_RESTRICT        
 
+AC_DEFUN([SXE_STACK_FLAGS], [dnl
+       ## actually this belongs to error-checking stuff
+       SXE_CHECK_COMPILER_FLAGS([-fstack-protector],
+               [diagflags="${diagflags} -fstack-protector"])
+       if test "${sxe_cv_c_flags__fstack_protector}" = "yes"; then
+               ## just check for ssp in this case
+               AC_CHECK_LIB([ssp], [__stack_chk_guard])
+       fi
+])dnl SXE_STACK_FLAGS
+
 dnl recommended interface macros
 ## compiler wrapper
 AC_DEFUN([SXE_CHECK_CC], [dnl
@@ -1652,16 +1664,31 @@ AC_DEFUN([SXE_CHECK_CFLAGS], [dnl
        dnl #### This may need to be overhauled so that all of SXEMACS_CC's flags
        dnl are handled separately, not just the xe_cflags_warning stuff.
 
+       ## diagnostic stuff and error checking
+       ## this may somehow be in contradiction to optimisation flags later on
+       ## so we issue the tests right here
+       if test "${with_error_checking_stack}" = "yes"; then
+               SXE_STACK_FLAGS
+       fi
+       if test "${with_error_checking_malldbg}" = "yes"; then
+               ## keep MALLOC_PERTURB_ and friends?
+               :
+       else
+               EXTRA_BATCHENV="MALLOC_PERTURB_= MALLOC_CHECK_="
+               AC_SUBST([EXTRA_BATCHENV])
+       fi
+       SXE_CFLAGS="${SXE_CFLAGS} ${diagflags}"
+
        ## Use either command line flag, environment var, or autodetection
        if test "$with_ridiculously_aggressive_optimisations" = "yes"; then
                CFLAGS=""
                SXE_DEBUGFLAGS
                SXE_WARNFLAGS
                SXE_OPTIFLAGS
-               SXE_CFLAGS="$debugflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $debugflags $optiflags $warnflags"
 
                SXE_FEATFLAGS
-               SXE_CFLAGS="$debugflags $featflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $featflags"
 
        elif test "$CFLAGS_uspecified_p" = "no" -o \
                "$ac_test_CFLAGS" != "set"; then
@@ -1702,16 +1729,17 @@ AC_DEFUN([SXE_CHECK_CFLAGS], [dnl
                                optiflags="-O"])
                fi
 
-               SXE_CFLAGS="$debugflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $debugflags $optiflags $warnflags"
 
                SXE_FEATFLAGS
-               SXE_CFLAGS="$debugflags $featflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $featflags"
        else
-               SXE_CFLAGS=${USER_CFLAGS}
+               SXE_CFLAGS="${SXE_CFLAGS} ${USER_CFLAGS}"
                featflags=""
                debugflags=""
                optiflags=""
                warnflags=""
+               diagflags=""
        fi
 
        ## unset the werror flag again