configure: Test compiler flags

When AC_PROG_CC detects GCC, Make.mk adds a bunch of flags to CFLAGS.
Works only for flags that any version of gcc in use accepts.

Instead, make configure add the flags that actually work to CFLAGS.
This will let us add flags that work only for some compilers.

The new autoconf macros are from autoconf-archive v2015.02.24.

Unfortunately, AX_APPEND_COMPILE_FLAGS doesn't work reliably for
-Wno-*: gcc complains about unknown -Wno-foo only when other
diagnostics are being produced.  Test -Wfoo instead of -Wno-foo, and
rename to MY_APPEND_COMPILE_FLAGS.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-06-06 15:53:00 +02:00
parent 35f34581be
commit 23373d01d9
7 changed files with 269 additions and 9 deletions

View file

@ -50,7 +50,6 @@ AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_CC
AC_SUBST(GCC)
AM_PROG_CC_C_O
# Private automake macro, tsk, tsk, tsk...
_AM_DEPENDENCIES(CC)
@ -81,6 +80,26 @@ LIBS_server="$LIBS"
### Checks for typedefs, structures, and compiler characteristics
# Enable useful warnings
# clang needs to be tested with -Werror=unknown-warning-option
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
[cflags_test="-Werror=unknown-warning-option"],
[cflags_test=""])
MY_APPEND_COMPILE_FLAGS([-Wall -Wextra dnl
-Wmissing-prototypes dnl
-Wnested-externs dnl
-Wpointer-arith dnl
-Wredundant-decls dnl
-Wstrict-prototypes dnl
-Wno-unused-parameter dnl
], [], [$cflags_test])
# Our carg() conflicts with libm's TODO clean that up
MY_APPEND_COMPILE_FLAGS([-fno-builtin-carg])
# No multiple definitions of uninitialized global variables
MY_APPEND_COMPILE_FLAGS([-fno-common])
### Checks for library functions