]> git.cworth.org Git - obsolete/notmuch-old/commitdiff
configure: Test for each compiler warning before enabling it.
authorCarl Worth <cworth@cworth.org>
Sat, 30 Oct 2010 19:36:06 +0000 (12:36 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 30 Oct 2010 20:11:56 +0000 (13:11 -0700)
This should allow the build to be much more automatically portable
to compilers with different sets of warning options.

TODO
configure

diff --git a/TODO b/TODO
index 995ffd9a2dd8e6937ba39700510cb9c08e14a394..ff4ccb0ad506ad701212b179208e774355cb126d 100644 (file)
--- 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.
 
 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
 Completion
 ----------
 Fix bash completion to complete multiple search options (both --first
index 5e360d8c45d2116fad18aa28d09302e92076b1df..c5bcd07159421f5ba7959fed015d9bc3ed3f3525 100755 (executable)
--- a/configure
+++ b/configure
@@ -391,6 +391,30 @@ else
 fi
 rm -f compat/have_strcasestr
 
 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 <<EOF
 
 All required packages were found. You may now run the following
 cat <<EOF
 
 All required packages were found. You may now run the following
@@ -429,10 +453,10 @@ CXXFLAGS = ${CXXFLAGS}
 LDFLAGS = ${LDFLAGS}
 
 # Flags to enable warnings when using the C++ compiler
 LDFLAGS = ${LDFLAGS}
 
 # Flags to enable warnings when using the C++ compiler
-WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
+WARN_CXXFLAGS=${WARN_CXXFLAGS}
 
 # Flags to enable warnings when using the C compiler
 
 # Flags to enable warnings when using the C compiler
-WARN_CFLAGS=\$(WARN_CXXFLAGS) -Wmissing-declarations
+WARN_CFLAGS=${WARN_CFLAGS}
 
 # The prefix to which notmuch should be installed
 # Note: If you change this value here, be sure to ensure that the
 
 # The prefix to which notmuch should be installed
 # Note: If you change this value here, be sure to ensure that the