configure.ac cleanup, move to ax_append_*_flags
This commit is contained in:
parent
530695c17b
commit
a5afdfab99
263
configure.ac
263
configure.ac
@ -4,119 +4,113 @@ AC_INIT([libgim], [0.1.0], [danny@nerdcruft.net])
|
|||||||
## debugging is enabled.
|
## debugging is enabled.
|
||||||
: ${CXXFLAGS=""}
|
: ${CXXFLAGS=""}
|
||||||
|
|
||||||
AC_CANONICAL_HOST
|
###############################################################################
|
||||||
|
## Build environment discovery
|
||||||
AC_PROG_CXX
|
|
||||||
AC_LANG([C++])
|
|
||||||
LT_INIT
|
|
||||||
AM_PROG_CC_C_O
|
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.11 silent-rules])
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
|
AC_CANONICAL_HOST
|
||||||
|
|
||||||
|
AC_LANG([C++])
|
||||||
|
AC_PROG_CXX
|
||||||
|
AC_PROG_CXXCPP
|
||||||
|
|
||||||
|
AX_CXX_COMPILE_STDCXX_11([noext])
|
||||||
|
|
||||||
|
LT_INIT
|
||||||
|
|
||||||
|
AM_INIT_AUTOMAKE([1.14 dist-bzip2 dist-xz foreign subdir-objects])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
AX_APPEND_FLAG([-include config.h])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Major compilation options
|
||||||
|
|
||||||
AC_ARG_ENABLE([debugging],
|
AC_ARG_ENABLE([debugging],
|
||||||
[AS_HELP_STRING([--enable-debugging],
|
[AS_HELP_STRING([--enable-debugging], [enables developer debugging support])]
|
||||||
[enables developer debugging support])],
|
)
|
||||||
[ case "${enableval}" in
|
|
||||||
yes) ac_cv_debugging=yes ;;
|
|
||||||
no) ac_cv_debugging=no ;;
|
|
||||||
*) AC_MSG_ERROR([bad value for --enable-debugging=[yes|no]]) ;;
|
|
||||||
esac ],
|
|
||||||
[ac_cv_debugging=no])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([mudflap],
|
AC_ARG_ENABLE([mudflap],
|
||||||
[AS_HELP_STRING([--enable-mudflap],
|
[AS_HELP_STRING([--enable-mudflap], [enable mudflap runtime debugging])]
|
||||||
[enable mudflap runtime debugging])],
|
)
|
||||||
[ case "${enableval}" in
|
|
||||||
yes) ac_cv_mudflap=yes ;;
|
|
||||||
no) ac_cv_mudflap=no ;;
|
|
||||||
*) AC_MSG_ERROR([bad value for --enable-mudflap[yes|no]]) ;;
|
|
||||||
esac ],
|
|
||||||
[ac_cv_mudflap=no])
|
|
||||||
|
|
||||||
##
|
###############################################################################
|
||||||
## Warnings
|
## Warnings
|
||||||
WARNING_FLAGS=""
|
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wall], [WARNING_FLAGS="$WARNING_FLAGS -Wall"])
|
AX_APPEND_COMPILE_FLAGS([-Wall])
|
||||||
AS_CXX_COMPILER_FLAG([-Wextra], [WARNING_FLAGS="$WARNING_FLAGS -Wextra"])
|
AX_APPEND_COMPILE_FLAGS([-Wextra])
|
||||||
AS_CXX_COMPILER_FLAG([-Wno-parentheses], [WARNING_FLAGS="$WARNING_FLAGS -Wno-parentheses"])
|
AX_APPEND_COMPILE_FLAGS([-Wno-parentheses])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wcast-align])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wsign-compare])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wsign-conversion])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wtype-limits])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wfloat-equal])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wunused-parameter])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wunused-but-set-variable])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wshadwo])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-Wredundant-decls])
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wpointer-arith], [WARNING_FLAGS="$WARNING_FLAGS -Wpointer-arith"])
|
AX_APPEND_COMPILE_FLAGS([-pedantic])
|
||||||
AS_CXX_COMPILER_FLAG([-Wcast-qual], [WARNING_FLAGS="$WARNING_FLAGS -Wcast-qual"])
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wcast-align], [WARNING_FLAGS="$WARNING_FLAGS -Wcast-align"])
|
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wsign-compare], [WARNING_FLAGS="$WARNING_FLAGS -Wsign-compare"])
|
######################################################################
|
||||||
AS_CXX_COMPILER_FLAG([-Wsign-conversion], [WARNING_FLAGS="$WARNING_FLAGS -Wsign-conversion"])
|
## Platform compilation helpers
|
||||||
AS_CXX_COMPILER_FLAG([-Wtype-limits], [WARNING_FLAGS="$WARNING_FLAGS -Wtype-limits"])
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wfloat-equal], [WARNING_FLAGS="$WARNING_FLAGS -Wfloat-equal"])
|
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wswitch-default], [COMMON_CFLAGS="$COMMON_CFLAGS -Wswitch-default"])
|
AX_APPEND_COMPILE_FLAGS([-fno-common])
|
||||||
#AS_CXX_COMPILER_FLAG([-Wswitch-enum], [COMMON_CFLAGS="$COMMON_CFLAGS -Wswitch-enum"])
|
AX_APPEND_COMPILE_FLAGS([-fno-nonansi-builtins])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-fno-deduce-init-list])
|
||||||
|
|
||||||
#AS_CXX_COMPILER_FLAG([-Wzero-as-null-pointer-constant], [WARNING_FLAGS="$WARNING_FLAGS -Wzero-as-null-pointer-constant"])
|
###############################################################################
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wunused-parameter], [WARNING_FLAGS="$WARNING_FLAGS -Wunused-parameter"])
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wunused-but-set-variable], [WARNING_FLAGS="$WARNING_FLAGS -Wunused-parameter"])
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wshadow], [WARNING_FLAGS="$WARNING_FLAGS -Wshadow"])
|
|
||||||
AS_CXX_COMPILER_FLAG([-Wredundant-decls], [WARNING_FLAGS="$WARNING_FLAGS -Wredundant-decls"])
|
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-pedantic], [COMMON_CFLAGS="$COMMON_CFLAGS -pedantic"])
|
|
||||||
|
|
||||||
##
|
|
||||||
## Compilation
|
|
||||||
AS_CXX_COMPILER_FLAG([-fno-common ], [COMMON_CFLAGS="$COMMON_CFLAGS -fno-common "])
|
|
||||||
AS_CXX_COMPILER_FLAG([-fno-nonansi-builtins],
|
|
||||||
[COMMON_CFLAGS="$COMMON_CFLAGS -fno-nonansi-builtins"])
|
|
||||||
##AS_CXX_COMPILER_FLAG([-fno-rtti], [COMMON_CFLAGS="$COMMON_CFLAGS -fno-rtti"])
|
|
||||||
|
|
||||||
AS_CXX_COMPILER_FLAG([-fno-deduce-init-list], [COMMON_CFLAGS="$COMMON_CFLAGS -fno-deduce-init-list "])
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## Compiler features
|
## Compiler features
|
||||||
|
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AC_C_RESTRICT
|
AC_C_RESTRICT
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
|
|
||||||
##
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([struct A { virtual void C (void) = 0; };
|
||||||
|
struct B : A { void C (void) override; }; ],
|
||||||
|
[])],
|
||||||
|
[], [AC_DEFINE([override], [], [Pretend about override keyword support])])
|
||||||
|
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([struct A final { }; ],
|
||||||
|
[])],
|
||||||
|
[], [AC_DEFINE([final], [], [Pretend about final keyword support])])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
## Architecture features
|
## Architecture features
|
||||||
|
|
||||||
AC_C_BIGENDIAN
|
AC_C_BIGENDIAN
|
||||||
|
|
||||||
##
|
###############################################################################
|
||||||
## Useful headers or platform features
|
## Useful headers or platform features
|
||||||
|
|
||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
AC_TYPE_SSIZE_T
|
AC_TYPE_SSIZE_T
|
||||||
|
|
||||||
##
|
###############################################################################
|
||||||
## platform features
|
## Platform features
|
||||||
#AC_DEFINE([_GNU_SOURCE], [], [Description])
|
|
||||||
|
|
||||||
case $host_os in
|
AS_CASE([$host_os],
|
||||||
mingw32)
|
[mingw32], [
|
||||||
AM_CONDITIONAL([PLATFORM_WIN32], [true])
|
AM_CONDITIONAL([PLATFORM_WIN32], [true])
|
||||||
AM_CONDITIONAL([PLATFORM_LINUX], [false])
|
AM_CONDITIONAL([PLATFORM_LINUX], [false])
|
||||||
|
|
||||||
AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
|
AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
|
||||||
AC_SUBST([NET_LIBS], [-lws2_32])
|
AC_SUBST([NET_LIBS], [-lws2_32])
|
||||||
|
],
|
||||||
|
|
||||||
#COMMON_LDFLAGS="$COMMON_LDFLAGS -ldbghelp"
|
[linux-gnu], [
|
||||||
;;
|
|
||||||
|
|
||||||
linux-gnu)
|
|
||||||
AM_CONDITIONAL([PLATFORM_WIN32], [false])
|
AM_CONDITIONAL([PLATFORM_WIN32], [false])
|
||||||
AM_CONDITIONAL([PLATFORM_LINUX], [true])
|
AM_CONDITIONAL([PLATFORM_LINUX], [true])
|
||||||
;;
|
],
|
||||||
|
|
||||||
*)
|
[AC_ERROR([Unknown host_os])]
|
||||||
AC_ERROR([Unknown host_os])
|
)
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
AC_FUNC_MMAP
|
AC_FUNC_MMAP
|
||||||
|
|
||||||
@ -128,72 +122,61 @@ AC_CHECK_HEADER([execinfo.h], [break])
|
|||||||
AM_CONDITIONAL([HAVE_EXECINFO], [test x$ac_cv_header_execinfo_h = "xyes"])
|
AM_CONDITIONAL([HAVE_EXECINFO], [test x$ac_cv_header_execinfo_h = "xyes"])
|
||||||
|
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt])
|
AC_SEARCH_LIBS([clock_gettime], [rt])
|
||||||
if [[ "x$ac_cv_search_clock_gettime" == "x-*" ]]; then
|
AS_IF([test "x$ac_cv_search_clock_gettime" == "x-*"], [
|
||||||
COMMON_LDFLAGS="$COMMON_LDFLAGS $ac_cv_search_clock_gettime"
|
AX_APPEND_LINK_FLAGS([$ac_cv_search_clock_gettime])
|
||||||
fi
|
])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
##
|
|
||||||
## Debug features
|
## Debug features
|
||||||
if test "x$ac_cv_debugging" = "xyes"; then
|
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS -O0"
|
|
||||||
|
|
||||||
if test "x$ac_cv_mudflap" = "xyes"; then
|
AS_IF([test "x$enable_debugging" = "xyes"], [
|
||||||
AS_CXX_COMPILER_FLAG([-fmudflapth], [
|
AS_IF([test "x$enable_mudflap" = "xyes"], [
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS -fmudflapth";
|
AX_APPEND_COMPILE_FLAGS([-fmudflapth])
|
||||||
COMMON_LDFLAGS="$COMMON_LDFLAGS -lmudflapth"
|
AX_APPEND_LINK_FLAGS([-lmudflapth])
|
||||||
])
|
])
|
||||||
fi
|
|
||||||
|
|
||||||
AC_DEFINE([ENABLE_DEBUGGING], [], [Description])
|
AX_APPEND_COMPILE_FLAGS([-ggdb])
|
||||||
AC_DEFINE([_GLIBCXX_DEBUG], [], [Description])
|
|
||||||
|
|
||||||
else
|
AC_DEFINE([ENABLE_DEBUGGING], [], [Debugging support enabled])
|
||||||
## Use 'none' LTO partitioning to avoid discarded section linker errors
|
AC_DEFINE([_GLIBCXX_DEBUG], [], [Use glibcxx debugging mode])
|
||||||
## against boost
|
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS -O2 -flto=8 -flto-partition=none"
|
|
||||||
COMMON_LDFLAGS="$COMMON_LDFLAGS -flto=8 -flto-partition=none"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $host_os in
|
AX_APPEND_COMPILE_FLAGS([-O0])
|
||||||
mingw32)
|
], [
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS -gstabs"
|
AX_APPEND_COMPILE_FLAGS([-02])
|
||||||
;;
|
AX_APPEND_COMPILE_FLAGS([-flto=8])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-flto-partition=none])
|
||||||
|
|
||||||
linux-gnu)
|
AX_APPEND_LINK_FLAGS([-flto=8])
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS -g"
|
AX_APPEND_LINK_FLAGS([-flto-partition=none])
|
||||||
AS_CXX_COMPILER_FLAG([-ggdb], [COMMON_CFLAGS="$COMMON_CFLAGS -ggdb"])
|
AX_APPEND_LINK_FLAGS([-fwhole-program])
|
||||||
;;
|
])
|
||||||
|
|
||||||
*)
|
AS_CASE([$host_os],
|
||||||
AC_ERROR([Unknown host_os])
|
[mingw32], [
|
||||||
;;
|
AX_APPEND_COMPILE_FLAGS([-gstabs])
|
||||||
esac
|
|
||||||
|
|
||||||
case $host_cpu in
|
## HACK: Stop multiple defines from boost exception rethrowers
|
||||||
x86_64)
|
## terminating the build. Works around boost bug #4258.
|
||||||
OPTIMISATION_FLAGS="$OPTIMISATION_FLAGS -mtune=generic"
|
AX_APPEND_COMPILE_FLAGS([-Wl,--allow-multiple-definition])
|
||||||
;;
|
],
|
||||||
|
|
||||||
i686)
|
[linux-gnu], [
|
||||||
OPTIMISATION_FLAGS="$OPTIMISATION_FLAGS -march=prescott -mtune=generic -mfpmath=sse"
|
AX_APPEND_COMPILE_FLAGS([-g])
|
||||||
;;
|
AX_APPEND_COMPILE_FLAGS([-ggdb])
|
||||||
|
],
|
||||||
|
|
||||||
*)
|
[AC_MSG_WARN([Unknown host_os])]
|
||||||
AC_MSG_ERROR([Unknown target CPU])
|
)
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
##
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
##
|
###############################################################################
|
||||||
## Required packages
|
## Required packages
|
||||||
|
|
||||||
CHECK_RAGEL([ip.cpp])
|
CHECK_RAGEL([ip.cpp])
|
||||||
|
|
||||||
|
AX_BOOST_BASE([1.52], [], [AC_MSG_ERROR([Boost version >= 1.52 required])])
|
||||||
AX_BOOST_BASE([1.49], [], [AC_MSG_ERROR([Boost version >= 1.42 required])])
|
|
||||||
AC_SUBST(BOOST_CPPFLAGS)
|
AC_SUBST(BOOST_CPPFLAGS)
|
||||||
AC_SUBST(BOOST_LDFLAGS)
|
AC_SUBST(BOOST_LDFLAGS)
|
||||||
|
|
||||||
@ -204,21 +187,39 @@ AX_BOOST_SYSTEM
|
|||||||
AX_BOOST_FILESYSTEM
|
AX_BOOST_FILESYSTEM
|
||||||
AC_SUBST(BOOST_FILESYSTEM_LIB)
|
AC_SUBST(BOOST_FILESYSTEM_LIB)
|
||||||
|
|
||||||
if test "x$ax_cv_boost_filesystem" != "xyes"; then
|
AS_IF([text "x$ax_cv_boost_filesystem" != "xyes"], [
|
||||||
AC_MSG_ERROR("boost-filesystem is a hard requirement")
|
AC_MSG_ERROR("boost-filesystem is a hard requirement")
|
||||||
fi
|
])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
## Optional packages
|
## Optional packages
|
||||||
|
|
||||||
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0])
|
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0])
|
||||||
|
AC_SUBST(ZLIB_CFLAGS)
|
||||||
|
AC_SUBST(ZLIB_LIBS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Performance and build optimisations
|
||||||
|
|
||||||
|
AS_CASE([$host_cpu],
|
||||||
|
[x86_64], [
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-mtune=generic])
|
||||||
|
],
|
||||||
|
|
||||||
|
[i686], [
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-march=prescott])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-mtune=generic])
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-mfpmath=sse])
|
||||||
|
],
|
||||||
|
|
||||||
|
[AC_MSG_WARN([unknown host_cpu])]
|
||||||
|
)
|
||||||
|
|
||||||
|
AX_APPEND_COMPILE_FLAGS([-pipe])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
## Output
|
## Output
|
||||||
|
|
||||||
COMMON_CXXFLAGS="-std=c++0x -pipe -include config.h $WARNING_FLAGS $OPTIMISATION_FLAGS $COMMON_CFLAGS"
|
|
||||||
COMMON_LDFLAGS="$COMMON_LDFLAGS "
|
|
||||||
|
|
||||||
AC_SUBST(COMMON_CXXFLAGS)
|
|
||||||
AC_SUBST(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Doxyfile
|
Doxyfile
|
||||||
Makefile
|
Makefile
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
dnl as-compiler-flag.m4 0.1.0
|
|
||||||
|
|
||||||
dnl autostars m4 macro for detection of compiler flags
|
|
||||||
|
|
||||||
dnl David Schleef <ds@schleef.org>
|
|
||||||
dnl Tim-Philipp Müller <tim centricular net>
|
|
||||||
|
|
||||||
dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
|
|
||||||
dnl Tries to compile with the given CFLAGS.
|
|
||||||
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
|
|
||||||
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
|
|
||||||
|
|
||||||
AC_DEFUN([AS_COMPILER_FLAG],
|
|
||||||
[
|
|
||||||
AC_MSG_CHECKING([to see if compiler understands $1])
|
|
||||||
|
|
||||||
save_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$CFLAGS $1"
|
|
||||||
|
|
||||||
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
|
|
||||||
CFLAGS="$save_CFLAGS"
|
|
||||||
|
|
||||||
if test "X$flag_ok" = Xyes ; then
|
|
||||||
$2
|
|
||||||
true
|
|
||||||
else
|
|
||||||
$3
|
|
||||||
true
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT([$flag_ok])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
|
|
||||||
dnl Tries to compile with the given CPPFLAGS.
|
|
||||||
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
|
|
||||||
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
|
|
||||||
|
|
||||||
AC_DEFUN([AS_CXX_COMPILER_FLAG],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([AC_PROG_CXX])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([to see if c++ compiler understands $1])
|
|
||||||
|
|
||||||
save_CPPFLAGS="$CPPFLAGS"
|
|
||||||
CPPFLAGS="$CPPFLAGS $1"
|
|
||||||
|
|
||||||
AC_LANG_PUSH(C++)
|
|
||||||
|
|
||||||
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
|
|
||||||
CPPFLAGS="$save_CPPFLAGS"
|
|
||||||
|
|
||||||
if test "X$flag_ok" = Xyes ; then
|
|
||||||
$2
|
|
||||||
true
|
|
||||||
else
|
|
||||||
$3
|
|
||||||
true
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_LANG_POP(C++)
|
|
||||||
|
|
||||||
AC_MSG_RESULT([$flag_ok])
|
|
||||||
])
|
|
||||||
|
|
65
m4/ax_append_compile_flags.m4
Normal file
65
m4/ax_append_compile_flags.m4
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
|
||||||
|
# flag. If it does, the flag is added FLAGS-VARIABLE
|
||||||
|
#
|
||||||
|
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
|
||||||
|
# CFLAGS) is used. During the check the flag is always added to the
|
||||||
|
# current language's flags.
|
||||||
|
#
|
||||||
|
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||||
|
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||||
|
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||||
|
# force the compiler to issue an error when a bad flag is given.
|
||||||
|
#
|
||||||
|
# NOTE: This macro depends on the AX_APPEND_FLAG and
|
||||||
|
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
|
||||||
|
# AX_APPEND_LINK_FLAGS.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
# option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
# Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||||
|
# modified version of the Autoconf Macro, you may extend this special
|
||||||
|
# exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
#serial 3
|
||||||
|
|
||||||
|
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
|
||||||
|
[AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
|
||||||
|
AC_REQUIRE([AX_APPEND_FLAG])
|
||||||
|
for flag in $1; do
|
||||||
|
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
|
||||||
|
done
|
||||||
|
])dnl AX_APPEND_COMPILE_FLAGS
|
69
m4/ax_append_flag.m4
Normal file
69
m4/ax_append_flag.m4
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
|
||||||
|
# added in between.
|
||||||
|
#
|
||||||
|
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
|
||||||
|
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
|
||||||
|
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
|
||||||
|
# FLAG.
|
||||||
|
#
|
||||||
|
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||||
|
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
# option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
# Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||||
|
# modified version of the Autoconf Macro, you may extend this special
|
||||||
|
# exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
#serial 2
|
||||||
|
|
||||||
|
AC_DEFUN([AX_APPEND_FLAG],
|
||||||
|
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
|
||||||
|
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
|
||||||
|
AS_VAR_SET_IF(FLAGS,
|
||||||
|
[case " AS_VAR_GET(FLAGS) " in
|
||||||
|
*" $1 "*)
|
||||||
|
AC_RUN_LOG([: FLAGS already contains $1])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_RUN_LOG([: FLAGS="$FLAGS $1"])
|
||||||
|
AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[AS_VAR_SET(FLAGS,["$1"])])
|
||||||
|
AS_VAR_POPDEF([FLAGS])dnl
|
||||||
|
])dnl AX_APPEND_FLAG
|
63
m4/ax_append_link_flags.m4
Normal file
63
m4/ax_append_link_flags.m4
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# For every FLAG1, FLAG2 it is checked whether the linker works with the
|
||||||
|
# flag. If it does, the flag is added FLAGS-VARIABLE
|
||||||
|
#
|
||||||
|
# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
|
||||||
|
# used. During the check the flag is always added to the linker's flags.
|
||||||
|
#
|
||||||
|
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
|
||||||
|
# when the check is done. The check is thus made with the flags: "LDFLAGS
|
||||||
|
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
|
||||||
|
# issue an error when a bad flag is given.
|
||||||
|
#
|
||||||
|
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
|
||||||
|
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
# option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
# Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||||
|
# modified version of the Autoconf Macro, you may extend this special
|
||||||
|
# exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
#serial 3
|
||||||
|
|
||||||
|
AC_DEFUN([AX_APPEND_LINK_FLAGS],
|
||||||
|
[AC_REQUIRE([AX_CHECK_LINK_FLAG])
|
||||||
|
AC_REQUIRE([AX_APPEND_FLAG])
|
||||||
|
for flag in $1; do
|
||||||
|
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3])
|
||||||
|
done
|
||||||
|
])dnl AX_APPEND_LINK_FLAGS
|
107
m4/ax_cxx_compile_stdcxx_11.m4
Normal file
107
m4/ax_cxx_compile_stdcxx_11.m4
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# ============================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
|
||||||
|
# ============================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CXX_COMPILE_STDCXX_11([ext|noext])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check for baseline language coverage in the compiler for the C++11
|
||||||
|
# standard; if necessary, add switches to CXXFLAGS to enable support.
|
||||||
|
# Errors out if no mode that supports C++11 baseline syntax can be found.
|
||||||
|
# The argument, if specified, indicates whether you insist on an extended
|
||||||
|
# mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -std=c++11).
|
||||||
|
# If neither is specified, you get whatever works, with preference for an
|
||||||
|
# extended mode.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
#serial 1
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
||||||
|
template <typename T>
|
||||||
|
struct check
|
||||||
|
{
|
||||||
|
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef check<check<bool>> right_angle_brackets;
|
||||||
|
|
||||||
|
int a;
|
||||||
|
decltype(a) b;
|
||||||
|
|
||||||
|
typedef check<int> check_type;
|
||||||
|
check_type c;
|
||||||
|
check_type&& cr = static_cast<check_type&&>(c);
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
||||||
|
m4_if([$1], [], [],
|
||||||
|
[$1], [ext], [],
|
||||||
|
[$1], [noext], [],
|
||||||
|
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
|
||||||
|
AC_LANG_ASSERT([C++])dnl
|
||||||
|
ac_success=no
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
|
||||||
|
ax_cv_cxx_compile_cxx11,
|
||||||
|
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||||
|
[ax_cv_cxx_compile_cxx11=yes],
|
||||||
|
[ax_cv_cxx_compile_cxx11=no])])
|
||||||
|
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
|
||||||
|
ac_success=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
m4_if([$1], [noext], [], [dnl
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
for switch in -std=gnu++11 -std=gnu++0x; do
|
||||||
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||||
|
$cachevar,
|
||||||
|
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||||
|
CXXFLAGS="$CXXFLAGS $switch"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||||
|
[eval $cachevar=yes],
|
||||||
|
[eval $cachevar=no])
|
||||||
|
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||||
|
if eval test x\$$cachevar = xyes; then
|
||||||
|
CXXFLAGS="$CXXFLAGS $switch"
|
||||||
|
ac_success=yes
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi])
|
||||||
|
|
||||||
|
m4_if([$1], [ext], [], [dnl
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
for switch in -std=c++11 -std=c++0x; do
|
||||||
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||||
|
$cachevar,
|
||||||
|
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||||
|
CXXFLAGS="$CXXFLAGS $switch"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||||
|
[eval $cachevar=yes],
|
||||||
|
[eval $cachevar=no])
|
||||||
|
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||||
|
if eval test x\$$cachevar = xyes; then
|
||||||
|
CXXFLAGS="$CXXFLAGS $switch"
|
||||||
|
ac_success=yes
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi])
|
||||||
|
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
|
||||||
|
fi
|
||||||
|
])
|
Loading…
Reference in New Issue
Block a user