summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-02-25 12:03:01 +0100
committerHans de Goede <hdegoede@redhat.com>2012-02-25 12:38:21 +0100
commitab7c9dbc6a08e0137294d4bbb33739e3ee8c3572 (patch)
tree213a94b0435bbaf4b1213fcfa09f3d2085031411 /configure.ac
parent575d73b42b283fb7f76a7e627cda94c896c90f00 (diff)
Compile with -Wall -Werror by default and fix existing warnings
The direct trigger for making this change is the fact that the 0.4 release is broken due to a return without a value in a non void function. Somehow this happened to always do the right thing in my testing, but not for others. This is something which should have been caught by a compiler warning, but I always build from git, and then no -Wall (let alone -Werror) gets passed to the compiler, which allowed this to slip through. So to avoid future embarrassment this patch changes the configure script to add various compiler options to CFLAGS by default, which should catch most detectable mistakes. Note that this change modifies CFLAGS directly, so if you're somehow specifying your own CFLAGS nothing will change (this is intentional). Also all added flags are checked, so if you've a compiler which is not gcc nothing will change. This patch also fixes the few warnings actually present in the code, so as to not have a state in the commit tree where the code does not compile. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac15
1 files changed, 15 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 1e8a121..3b5dcda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,21 @@ AC_PROG_LN_S
LT_INIT
dnl AC_DEFINE(_GNU_SOURCE, [1], [Enable GNU extensions])
+# Set some sane default CFLAGS, avoid having to do another release like 0.4.1
+if test "$ac_test_CFLAGS" != set; then
+ DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4"
+ for F in $DEFAULT_CFLAGS; do
+ AC_MSG_CHECKING([whether $CC supports $F])
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $F"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [cc_flag=yes], [cc_flag=no])
+ if test "x$cc_flag" != "xyes"; then
+ CFLAGS="$save_CFLAGS"
+ fi
+ AC_MSG_RESULT([$cc_flag])
+ done
+fi
+
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(LIBUSB, [libusb-1.0 >= 1.0.9])