Merge in updates from m4.
authorBrian Aker <brian@tangent.org>
Wed, 19 Sep 2012 23:31:55 +0000 (19:31 -0400)
committerBrian Aker <brian@tangent.org>
Wed, 19 Sep 2012 23:31:55 +0000 (19:31 -0400)
m4/ax_harden_compiler_flags.m4
m4/debug.m4

index d8b997f7b64d9d6e66c9afb3439b6a74850b68be..1490819d4045f3d06f41f486e33449722aa2d5f4 100644 (file)
 # 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])
       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])
       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
   ])
index 605576593c99c29a543f1fd396dbcc89213e63d8..7bdbeba092b7886d136298554242d127cf08c1eb 100644 (file)
@@ -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"