build: Set default compiler variables from configure This centralizes the setting so there's no duplication anymore, makes sure the user supplied variables are never overridden, and are only set when using gcc. Reported-by: Samuli Suominen <ssuominen@gentoo.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/configure.ac b/configure.ac
index 54da101..063bf92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,9 @@ AM_INIT_AUTOMAKE([1.8 foreign nostdinc])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
+# Check and store if we got user supplied variables
+user_CFLAGS=${CFLAGS-unset}
+
# Checks for operating system services and capabilities.
AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
@@ -22,6 +25,11 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
+# Set default compiler variables
+if test "$user_CFLAGS" = unset && test "$GCC" = yes; then
+ CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter"
+fi
+
# Checks for libraries.
# Checks for header files.
diff --git a/src/Makefile.am b/src/Makefile.am
index 4c57136..46b946b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,8 +1,5 @@
## Process this file with automake to produce Makefile.in
-# Set default values for user variables
-CFLAGS = -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter
-
AM_CPPFLAGS = \
-I$(top_builddir) \
-isystem $(top_srcdir)/include/bsd/ \
diff --git a/test/Makefile.am b/test/Makefile.am
index f280136..1d41b86 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,8 +1,5 @@
## Process this file with automake to produce Makefile.in
-# Set default values for user variables
-CFLAGS = -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter
-
AM_CPPFLAGS = \
-I$(top_builddir) \
-isystem $(top_srcdir)/include/bsd/ \