From 0418645b520ed4c7689de83032f3ee955efb5376 Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Tue, 29 May 2018 16:59:41 +0100 Subject: [PATCH] Handle g++ as a compiler when -Wstrict-prototypes is an invalid option, this emits a warning which can become an error. To add to the fun the standard test program uses 'int main()', so we need our own program to check things, also PACKAGE_URL is a macro re-define, also an error... --- configure.ac | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index dbd1362807..583169d146 100644 --- a/configure.ac +++ b/configure.ac @@ -19,9 +19,6 @@ AC_INIT([SWIFT],[0.7.0],[https://gitlab.cosma.dur.ac.uk/swift/swiftsim]) swift_config_flags="$*" -# Need to define this, instead of using fifth argument of AC_INIT, until 2.64. -AC_DEFINE([PACKAGE_URL],["www.swiftsim.com"], [Package web pages]) - AC_COPYRIGHT AC_CONFIG_SRCDIR([src/space.c]) AC_CONFIG_AUX_DIR([.]) @@ -687,7 +684,7 @@ if test "x$with_profiler" != "xno"; then proflibs="-lprofiler" fi AC_CHECK_LIB([profiler],[ProfilerFlush], - [have_profiler="yes" + [have_profiler="yes" AC_DEFINE([WITH_PROFILER],1,[Link against the gperftools profiling library.])], [have_profiler="no"], $proflibs) @@ -830,16 +827,17 @@ if test "$enable_warn" != "no"; then # We will do this by hand instead and only default to the macro for unknown compilers case "$ax_cv_c_compiler_vendor" in gnu | clang) - CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -Wshadow -Wstrict-prototypes" + CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -Wshadow" ;; intel) - CFLAGS="$CFLAGS -w2 -Wunused-variable -Wshadow -Wstrict-prototypes" + CFLAGS="$CFLAGS -w2 -Wunused-variable -Wshadow" ;; *) AX_CFLAGS_WARN_ALL ;; esac + # Add a "choke on warning" flag if it exists if test "$enable_warn" = "error"; then case "$ax_cv_c_compiler_vendor" in @@ -848,6 +846,11 @@ if test "$enable_warn" != "no"; then ;; esac fi + + # We want strict-prototypes, but this must still work even if warnings + # are an error. + AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes],[CFLAGS="$CFLAGS -Wstrict-prototypes"], + [CFLAGS="$CFLAGS"],[$CFLAGS],[AC_LANG_SOURCE([int main(void){return 0;}])]) fi # Various package configuration options. @@ -1211,6 +1214,11 @@ AC_DEFINE_UNQUOTED([SWIFT_CONFIG_FLAGS],["$swift_config_flags"],[Flags passed to # Make sure the latest git revision string gets included touch src/version.c +# Need to define this, instead of using fifth argument of AC_INIT, until +# 2.64. Defer until now as this redefines PACKAGE_URL, which can emit a +# compilation error when testing with -Werror. +AC_DEFINE([PACKAGE_URL],["www.swiftsim.com"], [Package web pages]) + # Generate output. AC_OUTPUT -- GitLab