aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2014-06-02 10:49:47 +0000
committerStefan Bühler <stbuehler@web.de>2014-06-02 10:49:47 +0000
commit4b14ad8ff4a98e605cdbcd5a4cc590df4be3dee0 (patch)
tree12845573bc49ac9b6d7cae04fb228e537113dd72
parent7eacd9caff75b87142e6488bc4bef73f7e7b5bc5 (diff)
downloadspawn-fcgi-4b14ad8ff4a98e605cdbcd5a4cc590df4be3dee0.tar.gz
spawn-fcgi-4b14ad8ff4a98e605cdbcd5a4cc590df4be3dee0.zip
[autobuild] Check whether compiler supports wanted CFLAGS (fixes #2235)
From: Stefan Bühler <stbuehler@web.de> git-svn-id: svn://svn.lighttpd.net/spawn-fcgi/trunk@65 4a9f3682-ca7b-49a8-9a55-ba4640e46f83
-rw-r--r--NEWS1
-rw-r--r--configure.ac37
2 files changed, 31 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 75c5332..15f0485 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ NEWS
* Use autoreconf instead of calling tools manually
* Add more flags to extra-warning flags
* Check return values of setuid, setgid, setgroups, initgroups, write
+ * Check whether compiler supports wanted CFLAGS (fixes #2235)
- 1.6.3 - 2009-09-23
* Fix unix socket mode change to work without specifying user/group for socket
diff --git a/configure.ac b/configure.ac
index f626104..b21bbf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,25 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_PROG_MAKE_SET
+dnl @synopsis TRY_CFLAGS [compiler flags]
+dnl @summary check whether C compiler supports given flags and adds them to CFLAGS
+AC_DEFUN([TRY_CFLAGS],
+[dnl
+ AC_MSG_CHECKING([if $CC supports $1])
+ AC_LANG_PUSH([C])
+ ac_try_cflags_saved_cflags="${CFLAGS}"
+ CFLAGS="${CFLAGS} $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+ [AC_MSG_RESULT([yes])],
+ [
+ AC_MSG_ERROR([no])
+ # options not supported, remove them:
+ CFLAGS="${ac_try_cflags_saved_cflags}"
+ ]
+ )
+ AC_LANG_POP([C])
+])
+
# Checks for libraries.
# Checks for header files.
@@ -47,8 +66,8 @@ AC_CHECK_FUNCS([dup2 memset putenv select socket strerror strtol issetugid inet_
# Check for IPv6 support
AC_ARG_ENABLE(ipv6,
- AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
- [case "${enableval}" in
+ AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
+ [case "${enableval}" in
yes) ipv6=true ;;
no) ipv6=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
@@ -56,10 +75,13 @@ AC_ARG_ENABLE(ipv6,
if test x$ipv6 = xtrue; then
AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
- [AC_TRY_LINK([ #include <sys/types.h>
+ [AC_TRY_LINK([[
+#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ],
- [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
+#include <netinet/in.h>
+ ]], [[
+struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
+ ]], [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
if test "$ac_cv_ipv6_support" = yes; then
AC_DEFINE(HAVE_IPV6,1,[Whether to enable IPv6 support])
@@ -69,7 +91,8 @@ fi
# check for extra compiler options (warning options)
if test "${GCC}" = "yes"; then
- CFLAGS="${CFLAGS} -Wall -W -Wshadow -pedantic -std=gnu99"
+ TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
+ TRY_CFLAGS([-std=gnu99])
fi
AC_ARG_ENABLE(extra-warnings,
@@ -81,7 +104,7 @@ AC_ARG_ENABLE(extra-warnings,
esac],[extrawarnings=false])
if test x$extrawarnings = xtrue; then
- CFLAGS="${CFLAGS} -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Winline -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security"
+ TRY_CFLAGS([-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Winline -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security])
fi
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])