From: Wouter Wijngaards Date: Mon, 5 Feb 2007 11:20:38 +0000 (+0000) Subject: configure improvement. X-Git-Tag: release-0.0~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8f092c53c7e3e0253200381d43def9bc93c28f5;p=thirdparty%2Funbound.git configure improvement. git-svn-id: file:///svn/unbound/trunk@62 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/configure.ac b/configure.ac index fa1b79657..932797d14 100644 --- a/configure.ac +++ b/configure.ac @@ -34,15 +34,121 @@ $3 fi ]) +dnl routine to help check for needed compiler flags. +# if the given code compiles without the flag, execute argument 4 +# if the given code only compiles with the flag, execute argument 3 +# otherwise fail +AC_DEFUN([CHECK_COMPILER_FLAG_NEEDED], +[ +AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING(whether we need $1 as a flag for $CC) +cache=`echo $1 | sed 'y%.=/+-%___p_%'` +AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache, +[ +echo '$2' > conftest.c +echo 'void f(){}' >>conftest.c +if test -z "`$CC $CFLAGS -Werror -Wall -c conftest.c 2>&1`"; then +eval "cv_prog_cc_flag_needed_$cache=no" +else +[ +if test -z "`$CC $CFLAGS $1 -Werror -Wall -c conftest.c 2>&1`"; then +eval "cv_prog_cc_flag_needed_$cache=yes" +else +echo 'Test with flag fails too!' +cat conftest.c +echo "$CC $CFLAGS $1 -Werror -Wall -c conftest.c 2>&1" +echo `$CC $CFLAGS $1 -Werror -Wall -c conftest.c` +exit 1 +fi +] +fi +rm -f conftest* +]) +if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then +AC_MSG_RESULT(yes) +: +$3 +else +AC_MSG_RESULT(no) +: +$4 +fi +]) + # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_LANG_C CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) + +CHECK_COMPILER_FLAG_NEEDED(-std=c99, +[ +#include +#include +int test() { + int a = 0; + a = isblank(12); + return a; +} +], [CFLAGS="$CFLAGS -std=c99"]) + +CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE, +[ +#include + +int test() { + int a; + a = isascii(32); + return a; +} +], [CFLAGS="$CFLAGS -D_BSD_SOURCE"]) + +CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112, +[ +#include +#include + +int test() { + int a = 0; + char *t; + time_t time = 0; + char *buf = NULL; + const char* str = NULL; + t = ctime_r(&time, buf); + str = gai_strerror(0); + return a; +} +], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"]) + +CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__, +[ +#include +#include +#include +#include +#include + +int test() { + int a; + char **opts = NULL; + struct timeval tv; + tv.tv_usec = 10; + srandom(32); + a = getopt(2, opts, "a"); + a = isascii(32); + return a; +} +], [CFLAGS="$CFLAGS -D__EXTENSIONS__"]) + +# for Sun studio 11. +CHECK_COMPILER_FLAG(xO4, [CFLAGS="$CFLAGS -xO4"]) +CHECK_COMPILER_FLAG(xtarget=generic, [CFLAGS="$CFLAGS -xtarget=generic"]) +# flag warnings. CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"]) CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"]) CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"]) CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"]) + AC_C_INLINE AC_DEFUN([AC_CHECK_FORMAT_ATTRIBUTE], diff --git a/doc/Changelog b/doc/Changelog index 58f2e3f0f..ec1484515 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +5 February 2007: Wouter + - Picked up stdc99 and other define tests from ldns. Improved + POSIX define test to include getaddrinfo. + 2 February 2007: Wouter - Created udp4 and udp6 port arrays to provide service for both address families.