Code

configure.ac: Added the --enable-standards command line option.
authorSebastian Harl <sh@tokkee.org>
Thu, 15 Oct 2009 21:56:41 +0000 (23:56 +0200)
committerSebastian Harl <sh@tokkee.org>
Thu, 15 Oct 2009 21:56:41 +0000 (23:56 +0200)
This option may be used to enable C99 and POSIX.1 2001 standards compliance
mode.

configure.ac

index abd0c5ed3efe981c6b152bef8c66ec352ecc81a6..e0fd5dbcab30485e671c6c022012d05ac7e884fc 100644 (file)
@@ -30,6 +30,37 @@ test_cc_flags() {
        return $ret
 }
 
+dnl Optionally stick to standard C99 and POSIX.1 2001 as close as possible.
+AC_ARG_ENABLE([standards],
+               AS_HELP_STRING([--enable-standards],
+                               [Enable standards compliance mode]),
+               [enable_standards="$enableval"],
+               [enable_standards="no"])
+
+if test "x$enable_standards" = "xyes"; then
+       AC_DEFINE([_ISOC99_SOURCE], 1,
+                       [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
+       AC_DEFINE([_POSIX_C_SOURCE], 200112L,
+                       [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
+       AC_DEFINE([_XOPEN_SOURCE], 600,
+                       [Define to enforce X/Open 6 (XSI) compliance.])
+       AC_DEFINE([_REENTRANT], 1,
+                       [Define to enable reentrant interfaces.])
+       AC_DEFINE([_THREAD_SAFE], 1,
+                       [Define to enable reentrant interfaces.])
+
+       for flag in -std=c99 -pedantic; do
+               AC_MSG_CHECKING([whether $CC accepts $flag])
+
+               if test_cc_flags $flag; then
+                       CFLAGS="$CFLAGS $flag"
+                       AC_MSG_RESULT([yes])
+               else
+                       AC_MSG_RESULT([no])
+               fi
+       done
+fi
+
 for flag in -Wall -Wextra -Werror; do
        AC_MSG_CHECKING([whether $CC accepts $flag])