From: Carl Worth Date: Sat, 30 Oct 2010 19:36:06 +0000 (-0700) Subject: configure: Test for each compiler warning before enabling it. X-Git-Tag: 0.4~18 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=b802c18d3b9b0a2f5909e4c92ef7d6e7db234825 configure: Test for each compiler warning before enabling it. This should allow the build to be much more automatically portable to compilers with different sets of warning options. --- diff --git a/TODO b/TODO index 995ffd9a..ff4ccb0a 100644 --- a/TODO +++ b/TODO @@ -57,10 +57,6 @@ Add a binding to open all closed messages. Change the 'a'rchive command in the thread view to only archive open messages. -Portability ------------ -Fix configure script to test each compiler warning we want to use. - Completion ---------- Fix bash completion to complete multiple search options (both --first diff --git a/configure b/configure index 5e360d8c..c5bcd071 100755 --- a/configure +++ b/configure @@ -391,6 +391,30 @@ else fi rm -f compat/have_strcasestr +printf "int main(void){return 0;}\n" > minimal.c + +WARN_CXXFLAGS="" +printf "Checking for available C++ compiler warning flags... " +for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do + if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1 + then + WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}" + fi +done +printf "\n\t${WARN_CXXFLAGS}\n" + +WARN_CFLAGS="${WARN_CXXFLAGS}" +printf "Checking for available C compiler warning flags... " +for flag in -Wmissing-declarations; do + if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1 + then + WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}" + fi +done +printf "\n\t${WARN_CFLAGS}\n" + +rm -f minimal minimal.c + cat <