autoconf: separate warning flags from CFLAGS int WFLAGS
authorMarko Kreen <markokr@gmail.com>
Wed, 31 Mar 2010 12:02:07 +0000 (15:02 +0300)
committerMarko Kreen <markokr@gmail.com>
Wed, 31 Mar 2010 12:02:07 +0000 (15:02 +0300)
this allows easier CFLAGS customization in user program.

Makefile
config.mak.in
m4/usual.m4

index c276ae1ff9066e5442926fba68620ddc7db139d3..05382814fdb27575e79370ca3168094e58daf8a8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,9 +12,6 @@ USUAL_OBJDIR = obj
 USUAL_MODULES = $(filter-out pgsocket, $(subst .h,, $(notdir $(wildcard usual/*.h))))
 include $(USUAL_DIR)/Setup.mk
 
-# extra warning flags
-WFLAGS =
-
 # full path for files
 srcs = $(USUAL_SRCS)
 hdrs = $(USUAL_HDRS)
index 3d8a85b91ad72c24f226b7a6770d72f84d371e55..f7b652f0575487f536e8ccb67205ee3735ba799d 100644 (file)
@@ -10,6 +10,7 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
+WFLAGS = @WFLAGS@
 
 AR = @AR@
 STRIP = @STRIP@
index e75185a4eafabe3de85a7df7c55fb1633c38093a..843392dd6e0e9ecc5d6546e8a208d4f7ea0bc485 100644 (file)
@@ -65,10 +65,10 @@ if test "$GCC" = "yes"; then
      LDFLAGS="$old_LDFLAGS"])
 fi
 dnl Pick good warning flags for gcc
+WFLAGS=""
 if test x"$GCC" = xyes; then
   AC_MSG_CHECKING([for working warning switches])
   good_CFLAGS="$CFLAGS"
-  warnings=""
   flags="-Wall -Wextra"
   # turn off noise from Wextra
   flags="$flags -Wno-unused-parameter -Wno-missing-field-initializers"
@@ -77,16 +77,17 @@ if test x"$GCC" = xyes; then
   flags="$flags -Wdeclaration-after-statement -Wold-style-definition"
   flags="$flags -Wstrict-prototypes -Wundef -Wformat -Wnonnull -Wstrict-overflow"
   for f in $flags; do
-    CFLAGS="$good_CFLAGS $warnings $f"
-    AC_COMPILE_IFELSE([void foo(void){}], [warnings="$warnings $f"])
+    CFLAGS="$good_CFLAGS $WFLAGS $f"
+    AC_COMPILE_IFELSE([void foo(void){}], [WFLAGS="$WFLAGS $f"])
   done
-  CFLAGS="$good_CFLAGS $warnings"
+  CFLAGS="$good_CFLAGS"
   AC_MSG_RESULT([done])
 fi
 # autoconf does not want to find 'install', if not using automake...
 INSTALL=install
 BININSTALL="$INSTALL"
 AC_SUBST(INSTALL)
+AC_SUBST(WFLAGS)
 AC_SUBST(BININSTALL)
 AC_CHECK_TOOL([STRIP], [strip])
 AC_CHECK_TOOL([AR], [ar])