Code

configure.ac: Added the --enable-standards command line option.
[template.git] / configure.ac
index 583843df66554a719d478788c4e5e0aa7e33f8b9..e0fd5dbcab30485e671c6c022012d05ac7e884fc 100644 (file)
@@ -1,6 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([foobar],[m4_esyscmd(./version-gen.sh)],[sh@tokkee.org])
+AC_INIT([foobar],[m4_esyscmd(./version-gen.sh)],
+               [Sebastian Harl <sh@tokkee.org>])
 AC_CONFIG_SRCDIR([src/foobar.c])
 AC_CONFIG_HEADERS([src/config.h])
 AC_PREFIX_DEFAULT([/opt/foobar])
@@ -11,7 +12,6 @@ AC_LANG(C)
 
 AC_SYS_LARGEFILE
 
-dnl Check for programs...
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_INSTALL
@@ -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])
 
@@ -51,3 +82,19 @@ AC_CHECK_HEADERS(libgen.h)
 AC_CONFIG_FILES([Makefile src/Makefile])
 AC_OUTPUT
 
+cat <<EOF;
+
+$PACKAGE_NAME has been configured successfully.
+
+Run 'make' to compile the software and use 'make install' to
+install the package into $prefix.
+
+Configuration summary:
+
+  package version: $PACKAGE_VERSION
+  build date: $build_date
+
+Please report bugs to $PACKAGE_BUGREPORT.
+
+EOF
+