Add --enable-debug={yes,no} configure option
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Fri, 15 Jun 2012 16:06:21 +0000 (17:06 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Fri, 15 Jun 2012 16:11:55 +0000 (17:11 +0100)
Building with --enable-debug=yes will help catch a lot of programming
mistakes. It enables -Werror -Wall and a lot of other useful compiler
flags.

configure.ac

index 61a1e53..01b24f1 100644 (file)
@@ -93,6 +93,34 @@ dnl *** Include GLib/GSettings specific stuff ***
 dnl *********************************************
 GLIB_GSETTINGS
 
+dnl ***********************************
+dnl *** Check for debugging support ***
+dnl ***********************************
+AC_ARG_ENABLE([debug],
+              AC_HELP_STRING([--enable-debug@:@=no|yes@:>@],
+                             [Build with debugging support @<:@default=m4_default([$1], [no])@:>@]),
+              [enable_debug=$enableval], [enable_debug=m4_default([$1], [no])])
+AC_MSG_CHECKING([whether to build with debugging support])
+if test x"$enable_debug" = x"yes"; then
+  AC_DEFINE([DEBUG], [1], [Define for debugging support])
+
+  CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
+  CFLAGS="$CFLAGS -Werror -Wall -Wextra \
+            -Wno-missing-field-initializers \
+            -Wno-unused-parameter -Wold-style-definition \
+            -Wdeclaration-after-statement \
+            -Wmissing-declarations \
+            -Wmissing-noreturn -Wshadow -Wpointer-arith \
+            -Wcast-align -Wformat-security \
+            -Winit-self -Wmissing-include-dirs -Wundef \
+            -Wmissing-format-attribute -Wnested-externs \
+            -fstack-protector"
+
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
+fi
+
 AC_OUTPUT([
 Makefile
 boot-manager/Makefile