From: Brian Aker Date: Wed, 19 Sep 2012 23:31:55 +0000 (-0400) Subject: Merge in updates from m4. X-Git-Tag: 1.0.12~20^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=8586aca8c7c155bdd29355374502aeb3048a630c;p=awesomized%2Flibmemcached Merge in updates from m4. --- diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 index d8b997f7..1490819d 100644 --- a/m4/ax_harden_compiler_flags.m4 +++ b/m4/ax_harden_compiler_flags.m4 @@ -54,17 +54,33 @@ # AX_APPEND_COMPILE_FLAGS([-Wlong-long]) -- Don't turn on for compatibility issues memcached_stat_st #serial 2 + AC_DEFUN([AX_HARDEN_LINKER_FLAGS], [ + AC_REQUIRE([AX_CHECK_LINK_FLAG]) + AC_REQUIRE([AX_VCS_CHECKOUT]) + AC_REQUIRE([AX_DEBUG]) + + AS_IF([test "$ac_cv_vcs_checkout" = yes], [ + AX_CHECK_LINK_FLAG([-Werror]) + ]) + AX_CHECK_LINK_FLAG([-z relro -z now]) + ]) AC_DEFUN([AX_HARDEN_C_COMPILER_FLAGS], [ AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) - AC_REQUIRE([AX_CHECK_LINK_FLAG]) - AC_REQUIRE([AX_VCS_CHECKOUT]) + AC_REQUIRE([AX_HARDEN_LINKER_FLAGS]) AC_LANG_PUSH([C]) - AX_APPEND_COMPILE_FLAGS([-O2]) + AS_IF([test "$ax_with_debug" = yes], [ + AX_APPEND_COMPILE_FLAGS([-O0])],[ + AX_APPEND_COMPILE_FLAGS([-O2]) + ]) + + ac_cv_warnings_as_errors=no AS_IF([test "$ac_cv_vcs_checkout" = yes], [ AX_APPEND_COMPILE_FLAGS([-Werror]) + ac_cv_warnings_as_errors=yes ]) + AX_APPEND_COMPILE_FLAGS([-Wall]) AX_APPEND_COMPILE_FLAGS([-Wextra]) AX_APPEND_COMPILE_FLAGS([-std=c99]) @@ -76,20 +92,27 @@ AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes]) AX_APPEND_COMPILE_FLAGS([-Wlogical-op]) AC_LANG_POP + ]) AC_DEFUN([AX_HARDEN_CC_COMPILER_FLAGS], [ AC_REQUIRE([AX_HARDEN_C_COMPILER_FLAGS]) AC_LANG_PUSH([C++]) - AX_APPEND_COMPILE_FLAGS([-O2]) + + AS_IF([test "$ax_with_debug" = yes], [ + AX_APPEND_COMPILE_FLAGS([-O0])],[ + AX_APPEND_COMPILE_FLAGS([-O2]) + AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2]) + ]) + AS_IF([test "$ac_cv_vcs_checkout" = yes], [ AX_APPEND_COMPILE_FLAGS([-Werror]) ]) + AX_APPEND_COMPILE_FLAGS([-Wall]) AX_APPEND_COMPILE_FLAGS([-Wextra]) AX_APPEND_COMPILE_FLAGS([-Wpragmas]) AX_APPEND_COMPILE_FLAGS([--paramssp-buffer-size=1]) - AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2]) AX_APPEND_COMPILE_FLAGS([-Waddress]) AX_APPEND_COMPILE_FLAGS([-Warray-bounds]) AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts]) @@ -118,9 +141,5 @@ AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all]) AX_APPEND_COMPILE_FLAGS([-fwrapv]) AX_APPEND_COMPILE_FLAGS([-ggdb]) - AS_IF([test "$ac_cv_vcs_checkout" = yes], [ - AX_CHECK_LINK_FLAG([-Werror]) - ]) - AX_CHECK_LINK_FLAG([-z relro -z now]) AC_LANG_POP ]) diff --git a/m4/debug.m4 b/m4/debug.m4 index 60557659..7bdbeba0 100644 --- a/m4/debug.m4 +++ b/m4/debug.m4 @@ -2,9 +2,9 @@ AC_DEFUN([AX_DEBUG],[ AC_ARG_WITH([debug], [AS_HELP_STRING([--with-debug], [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], - [with_debug=$withval], - [with_debug=no]) - AS_IF([test "$with_debug" = "yes"],[ + [ax_with_debug=$withval], + [ax_with_debug=no]) + AS_IF([test "$ax_with_debug" = "yes"],[ # Debugging. No optimization. AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG" AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG"