From 81c652292a39bb9d7801cad35f11790bffa53b75 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Wed, 2 Jul 2014 23:11:14 +0900 Subject: [PATCH] Added updated autoconf scripts. --- configure.ac | 12 +-- scripts/ax_check_zlib.m4 | 142 +++++++++++++++++++++++++++ scripts/ax_cxx_compile_stdcxx_0x.m4 | 106 ++++++++++++++++++++ scripts/ax_cxx_compile_stdcxx_11.m4 | 147 ++++++++++++++++++++++++++++ scripts/checks.m4 | 99 ------------------- scripts/common.m4 | 101 ------------------- scripts/rak_compiler.m4 | 37 +++++++ scripts/rak_cxx.m4 | 61 ++++++++++++ 8 files changed, 498 insertions(+), 207 deletions(-) create mode 100644 scripts/ax_check_zlib.m4 create mode 100644 scripts/ax_cxx_compile_stdcxx_0x.m4 create mode 100644 scripts/ax_cxx_compile_stdcxx_11.m4 create mode 100644 scripts/rak_compiler.m4 create mode 100644 scripts/rak_cxx.m4 diff --git a/configure.ac b/configure.ac index 82ff2b67..72015453 100644 --- a/configure.ac +++ b/configure.ac @@ -9,20 +9,18 @@ AM_PATH_CPPUNIT(1.9.6) AC_PROG_CXX AC_PROG_LIBTOOL -TORRENT_CHECK_CXXFLAGS -TORRENT_ENABLE_DEBUG -TORRENT_ENABLE_EXTRA_DEBUG -TORRENT_ENABLE_WERROR +RAK_ENABLE_DEBUG +RAK_ENABLE_EXTRA_DEBUG +RAK_ENABLE_WERROR -TORRENT_CHECK_CXX11 -TORRENT_CHECK_TR1_LIB +RAK_CHECK_CXX11 +RAK_CHECK_TR1_LIB TORRENT_DISABLE_IPV6 AC_SYS_LARGEFILE TORRENT_CHECK_EXECINFO -TORRENT_OTFD TORRENT_ENABLE_ARCH TORRENT_WITH_SYSROOT diff --git a/scripts/ax_check_zlib.m4 b/scripts/ax_check_zlib.m4 new file mode 100644 index 00000000..ae5705f6 --- /dev/null +++ b/scripts/ax_check_zlib.m4 @@ -0,0 +1,142 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_ZLIB([action-if-found], [action-if-not-found]) +# +# DESCRIPTION +# +# This macro searches for an installed zlib library. If nothing was +# specified when calling configure, it searches first in /usr/local and +# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified, +# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If +# --without-zlib is specified, the library is not searched at all. +# +# If either the header file (zlib.h) or the library (libz) is not found, +# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is +# not specified, the configuration exits on error, asking for a valid zlib +# installation directory or --without-zlib. +# +# If both header file and library are found, shell commands +# 'action-if-found' is run. If 'action-if-found' is not specified, the +# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends +# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls +# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition +# for this symbol in a config.h file. Sample usage in a C/C++ source is as +# follows: +# +# #ifdef HAVE_LIBZ +# #include +# #endif /* HAVE_LIBZ */ +# +# LICENSE +# +# Copyright (c) 2008 Loic Dachary +# Copyright (c) 2010 Bastien Chevreux +# +# 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 2 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 . +# +# 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 14 + +AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB]) +AC_DEFUN([AX_CHECK_ZLIB], +# +# Handle user hints +# +[AC_MSG_CHECKING(if zlib is wanted) +zlib_places="/usr/local /usr /opt/local /sw" +AC_ARG_WITH([zlib], +[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to + /usr/local or /usr if not found in /usr/local@:>@ + --without-zlib to disable zlib usage completely], +[if test "$withval" != no ; then + AC_MSG_RESULT(yes) + if test -d "$withval" + then + zlib_places="$withval $zlib_places" + else + AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) + fi +else + zlib_places= + AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(yes)]) + +# +# Locate zlib, if wanted +# +if test -n "${zlib_places}" +then + # check the user supplied or any other more or less 'standard' place: + # Most UNIX systems : /usr/local and /usr + # MacPorts / Fink on OSX : /opt/local respectively /sw + for ZLIB_HOME in ${zlib_places} ; do + if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi + ZLIB_HOME="" + done + + ZLIB_OLD_LDFLAGS=$LDFLAGS + ZLIB_OLD_CPPFLAGS=$CPPFLAGS + if test -n "${ZLIB_HOME}"; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + fi + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no]) + AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) + AC_LANG_RESTORE + if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes" + then + # + # If both library and header were found, action-if-found + # + m4_ifblank([$1],[ + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + LIBS="-lz $LIBS" + AC_DEFINE([HAVE_LIBZ], [1], + [Define to 1 if you have `z' library (-lz)]) + ],[ + # Restore variables + LDFLAGS="$ZLIB_OLD_LDFLAGS" + CPPFLAGS="$ZLIB_OLD_CPPFLAGS" + $1 + ]) + else + # + # If either header or library was not found, action-if-not-found + # + m4_default([$2],[ + AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib]) + ]) + fi +fi +]) diff --git a/scripts/ax_cxx_compile_stdcxx_0x.m4 b/scripts/ax_cxx_compile_stdcxx_0x.m4 new file mode 100644 index 00000000..5ff134a6 --- /dev/null +++ b/scripts/ax_cxx_compile_stdcxx_0x.m4 @@ -0,0 +1,106 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_0X +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++0x +# standard. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# +# 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 7 (+1) + +AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X]) +AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [ + AC_CACHE_CHECK(if g++ supports C++0x features without additional flags, + ax_cv_cxx_compile_cxx0x_native, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c);],, + ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no) + AC_LANG_RESTORE + ]) + + AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x, + ax_cv_cxx_compile_cxx0x_cxx, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=c++0x" + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c);],, + ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no) + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE + ]) + + AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x, + ax_cv_cxx_compile_cxx0x_gxx, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=gnu++0x" + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c);],, + ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no) + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE + ]) + + if test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then + AC_DEFINE(HAVE_STDCXX_0X,, [Define if compiler supports C++0x features.]) + CXXFLAGS="$CXXFLAGS -std=c++0x" + fi +]) diff --git a/scripts/ax_cxx_compile_stdcxx_11.m4 b/scripts/ax_cxx_compile_stdcxx_11.m4 new file mode 100644 index 00000000..5cf70eb6 --- /dev/null +++ b/scripts/ax_cxx_compile_stdcxx_11.m4 @@ -0,0 +1,147 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++11 +# standard; if necessary, add switches to CXXFLAGS to enable support. +# +# The first 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. +# +# The second argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline C++11 support is required and that the macro +# should error out if no mode with that support is found. If specified +# 'optional', then configuration proceeds regardless, after defining +# HAVE_CXX11 if and only if a supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014 Alexey Sokolov +# Copyright (c) 2014 Jari Sundell +# +# 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 5 + +m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + struct Base { + virtual void f() {} + }; + struct Child : public Base { + virtual void f() override {} + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c); + + auto d = a; + auto l = [](){}; + + void unused() { + l(); + } +]]) + +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 + m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], + [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], + [$2], [optional], [ax_cxx_compile_cxx11_required=false], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])]) + AC_LANG_PUSH([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]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) + fi + else + if test x$ac_success = xno; then + HAVE_CXX11=0 + AC_MSG_NOTICE([No compiler with C++11 support was found]) + else + HAVE_CXX11=1 + AC_DEFINE(HAVE_CXX11,1, + [define if the compiler supports basic C++11 syntax]) + fi + + AC_SUBST(HAVE_CXX11) + fi +]) diff --git a/scripts/checks.m4 b/scripts/checks.m4 index 10dd53dc..8d77fc5e 100644 --- a/scripts/checks.m4 +++ b/scripts/checks.m4 @@ -354,105 +354,6 @@ AC_DEFUN([TORRENT_WITH_ADDRESS_SPACE], [ ]) ]) -AC_DEFUN([TORRENT_CHECK_TR1], [ - AC_LANG_PUSH(C++) - AC_MSG_CHECKING(for TR1 support) - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - #include - class Foo; - typedef std::tr1::unordered_map Bar; - ])], - [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_TR1, 1, Define to 1 if your C++ library supports the extensions from Technical Report 1) - ], - [ - AC_MSG_RESULT(no) - ] - ) - - AC_LANG_POP(C++) -]) - -AC_DEFUN([TORRENT_CHECK_CXX11], [ - AC_LANG_PUSH(C++) - AC_MSG_CHECKING(C++11 support) - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - #include - class Foo; typedef std::vector Bar; - union test { Bar b1; }; - ]) - ], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CXX11, 1, Define to 1 if your C++ compiler has support for C++11.) - ], [ - CXXFLAGS="$CXXFLAGS -std=c++11" - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - #include - class Foo; typedef std::vector Bar; - union test { Bar b1; }; - ]) - ], [ - AC_MSG_RESULT([with -std=c++11]) - AC_DEFINE(HAVE_CXX11, 1, Define to 1 if your C++ compiler has support for C++11.) - ], [ - AC_MSG_ERROR([No support for C++11 found.]) - ]) - ]) - - AC_LANG_POP(C++) -]) - -AC_DEFUN([TORRENT_CHECK_TR1_LIB], [ - AC_LANG_PUSH(C++) - AC_MSG_CHECKING(should use TR1 headers) - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - #include - class Foo; typedef std::unordered_map Bar; - Bar b1; - ]) - ], [ - AC_MSG_RESULT(no) - AC_DEFINE(USE_TR1_LIB, 0, Define to 1 if you need to use TR1 containers.) - - AC_DEFINE([lt_tr1_array], [], [TR1 array]) - AC_DEFINE([lt_tr1_functional], [], [TR1 functional]) - AC_DEFINE([lt_tr1_memory], [], [TR1 memory]) - AC_DEFINE([lt_tr1_unordered_map], [], [TR1 unordered_map]) - - ], [ - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - #include - class Foo; typedef std::tr1::unordered_map Bar; - Bar b1; - ]) - ], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(USE_TR1_LIB, 1, Define to 1 if you need to use TR1 containers.) - - AC_DEFINE([lt_tr1_array], [], [TR1 array]) - AC_DEFINE([lt_tr1_functional], [], [TR1 functional]) - AC_DEFINE([lt_tr1_memory], [], [TR1 memory]) - AC_DEFINE([lt_tr1_unordered_map], [], [TR1 unordered_map]) - - ], [ - AC_MSG_ERROR([No support for C++11 standard library nor TR1 extensions found.]) - ]) - ]) - - AH_VERBATIM(lt_tr1_zzz, [ -#if USE_TR1_LIB == 1 -namespace std { namespace tr1 {} using namespace tr1; } -#endif -]) - - AC_LANG_POP(C++) -]) - AC_DEFUN([TORRENT_WITH_FASTCGI], [ AC_ARG_WITH(fastcgi, AC_HELP_STRING([--with-fastcgi=PATH], [enable FastCGI RPC support (DO NOT USE)]), diff --git a/scripts/common.m4 b/scripts/common.m4 index 51276242..9885b037 100644 --- a/scripts/common.m4 +++ b/scripts/common.m4 @@ -1,53 +1,3 @@ -AC_DEFUN([TORRENT_CHECK_CXXFLAGS], [ - - AC_MSG_CHECKING([for user-defined CXXFLAGS]) - - if test -n "$CXXFLAGS"; then - AC_MSG_RESULT([user-defined "$CXXFLAGS"]) - else - CXXFLAGS="-O2 -Wall" - AC_MSG_RESULT([default "$CXXFLAGS"]) - fi -]) - - -AC_DEFUN([TORRENT_ENABLE_DEBUG], [ - AC_ARG_ENABLE(debug, - AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]), - [ - if test "$enableval" = "yes"; then - CXXFLAGS="$CXXFLAGS -g -DDEBUG" - else - CXXFLAGS="$CXXFLAGS -DNDEBUG" - fi - ],[ - CXXFLAGS="$CXXFLAGS -g -DDEBUG" - ]) -]) - - -AC_DEFUN([TORRENT_ENABLE_WERROR], [ - AC_ARG_ENABLE(werror, - AC_HELP_STRING([--enable-werror], [enable the -Werror and -Wall flag [[default=no]]]), - [ - if test "$enableval" = "yes"; then - CXXFLAGS="$CXXFLAGS -Werror -Wall" - fi - ]) -]) - - -AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [ - AC_ARG_ENABLE(extra-debug, - AC_HELP_STRING([--enable-extra-debug], [enable extra debugging checks [[default=no]]]), - [ - if test "$enableval" = "yes"; then - AC_DEFINE(USE_EXTRA_DEBUG, 1, Enable extra debugging checks.) - fi - ]) -]) - - AC_DEFUN([TORRENT_WITH_SYSROOT], [ AC_ARG_WITH(sysroot, AC_HELP_STRING([--with-sysroot=PATH], [compile and link with a specific sysroot]), @@ -95,26 +45,6 @@ AC_DEFUN([TORRENT_ENABLE_ARCH], [ ]) -AC_DEFUN([TORRENT_OTFD], [ - AC_LANG_PUSH(C++) - AC_MSG_CHECKING(for proper overloaded template function disambiguation) - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - template void f(T&) {} - template void f(T*) {} - int main() { int *i = 0; f(*i); f(i); } - ])], - [ - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - AC_MSG_ERROR([your compiler does not properly handle overloaded template function disambiguation]) - ]) - - AC_LANG_POP(C++) -]) - - AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(signedness of mincore parameter) @@ -310,34 +240,3 @@ AC_DEFUN([TORRENT_DISABLE_IPV6], [ fi ]) ]) - -AC_DEFUN([TORRENT_ENABLE_TR1], [ - AC_ARG_ENABLE(std_tr1, - AC_HELP_STRING([--disable-std_tr1], [disable check for support for TR1 [[default=enable]]]), - [ - if test "$enableval" = "yes"; then - TORRENT_CHECK_TR1() - else - AC_MSG_CHECKING(for TR1 support) - AC_MSG_RESULT(disabled) - fi - ],[ - TORRENT_CHECK_TR1() - ]) -]) - -AC_DEFUN([TORRENT_ENABLE_CXX11], [ - AC_ARG_ENABLE(std_c++11, - AC_HELP_STRING([--disable-std_c++11], [disable check for support for C++11 [[default=enable]]]), - [ - if test "$enableval" = "yes"; then - TORRENT_CHECK_CXX11() - else - AC_MSG_CHECKING(for C++11 support) - AC_MSG_RESULT(disabled) - fi - ],[ - TORRENT_CHECK_CXX11() - ] - ) -]) diff --git a/scripts/rak_compiler.m4 b/scripts/rak_compiler.m4 new file mode 100644 index 00000000..39bd19a7 --- /dev/null +++ b/scripts/rak_compiler.m4 @@ -0,0 +1,37 @@ +AC_DEFUN([RAK_ENABLE_DEBUG], [ + AC_ARG_ENABLE(debug, + AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]), + [ + if test "$enableval" = "yes"; then + CXXFLAGS="$CXXFLAGS -g -DDEBUG" + else + CXXFLAGS="$CXXFLAGS -DNDEBUG" + fi + ],[ + CXXFLAGS="$CXXFLAGS -g -DDEBUG" + ]) +]) + + +AC_DEFUN([RAK_ENABLE_WERROR], [ + AC_ARG_ENABLE(werror, + AC_HELP_STRING([--enable-werror], [enable the -Werror and -Wall flags [[default -Wall only]]]), + [ + if test "$enableval" = "yes"; then + CXXFLAGS="$CXXFLAGS -Werror -Wall" + fi + ],[ + CXXFLAGS="$CXXFLAGS -Wall" + ]) +]) + + +AC_DEFUN([RAK_ENABLE_EXTRA_DEBUG], [ + AC_ARG_ENABLE(extra-debug, + AC_HELP_STRING([--enable-extra-debug], [enable extra debugging checks [[default=no]]]), + [ + if test "$enableval" = "yes"; then + AC_DEFINE(USE_EXTRA_DEBUG, 1, Enable extra debugging checks.) + fi + ]) +]) diff --git a/scripts/rak_cxx.m4 b/scripts/rak_cxx.m4 new file mode 100644 index 00000000..3660f3a7 --- /dev/null +++ b/scripts/rak_cxx.m4 @@ -0,0 +1,61 @@ +AC_DEFUN([RAK_CHECK_CXX11], [ + AC_ARG_ENABLE([c++0x], + AC_HELP_STRING([--enable-c++0x], [compile with C++0x (unsupported)]), + [ + if test "$enableval" = "yes"; then + AX_CXX_COMPILE_STDCXX_0X + else + AX_CXX_COMPILE_STDCXX_11(noext) + fi + ],[ + AX_CXX_COMPILE_STDCXX_11(noext) + ] + ) +]) + +AC_DEFUN([RAK_CHECK_TR1_LIB], [ + AC_LANG_PUSH(C++) + AC_MSG_CHECKING(should use TR1 headers) + + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include + class Foo; typedef std::unordered_map Bar; + Bar b1; + ]) + ], [ + AC_MSG_RESULT(no) + AC_DEFINE(USE_TR1_LIB, 0, Define to 1 if you need to use TR1 containers.) + + AC_DEFINE([lt_tr1_array], [], [TR1 array]) + AC_DEFINE([lt_tr1_functional], [], [TR1 functional]) + AC_DEFINE([lt_tr1_memory], [], [TR1 memory]) + AC_DEFINE([lt_tr1_unordered_map], [], [TR1 unordered_map]) + + ], [ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include + class Foo; typedef std::tr1::unordered_map Bar; + Bar b1; + ]) + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(USE_TR1_LIB, 1, Define to 1 if you need to use TR1 containers.) + + AC_DEFINE([lt_tr1_array], [], [TR1 array]) + AC_DEFINE([lt_tr1_functional], [], [TR1 functional]) + AC_DEFINE([lt_tr1_memory], [], [TR1 memory]) + AC_DEFINE([lt_tr1_unordered_map], [], [TR1 unordered_map]) + + ], [ + AC_MSG_ERROR([No support for C++11 standard library nor TR1 extensions found.]) + ]) + ]) + + AH_VERBATIM(lt_tr1_zzz, [ +#if USE_TR1_LIB == 1 +namespace std { namespace tr1 {} using namespace tr1; } +#endif +]) + + AC_LANG_POP(C++) +])