📄 acinclude_custom.m4
字号:
# Copyright (c) 2003 Luc Vincent## This M4 script includes a number of non-standard# autoconf macros that are typically available# at the GNU Autoconf Macro Archive:## http://www.gnu.org/software/ac-archive/## Specially developed macros are placed a the# end of this file. Some of them were originally written# by L. Bottou and Y. LeCundnl -------------------------------------------------------dnl @synopsis AC_PROG_DOXYGEN_VERSION(VERSION,dnl [ACTION-IF-TRUE], [ACTION-IF-FALSE])dnldnl Check if doxygen is present and if version on machinednl is at least version number supplied as argumentdnldnl Makes sure that doxygen supports the version indicated. If true thednl shell commands in ACTION-IF-TRUE are executed. If not the shelldnl commands in ACTION-IF-FALSE are run. Note if $DOXYGEN is not set (fordnl example by running AC_CHECK_PROG or AC_PATH_PROG),dnl AC_CHECK_PROG(DOXYGEN, doxygen, doxygen) will be run.dnldnl Example:dnl dnl AC_PROG_DOXYGEN_VERSION(1.3.2)dnldnl This will check to make sure that the version of doxygen you havednl is at least version 1.3.2dnl -------------------------------------------------------AC_DEFUN([AC_PROG_DOXYGEN_VERSION],[dnl# Make sure we have doxygenif test -z "$DOXYGEN"; then# AC_CHECK_PROG(DOXYGEN,doxygen,doxygen) AC_PATH_PROG(DOXYGEN,doxygen)fi# Check if version of Doxygen is sufficientac_doxygen_version=$1if test "x$DOXYGEN" != "x"; then AC_MSG_CHECKING(for doxygen version at least equal to $ac_doxygen_version) # NB: It would be nice to log the error if there is one, but we cannot rely # on autoconf internals... # This is the actual version of doxygen doxy_version=`$DOXYGEN --version` # Need to turn these floating point numbers into integers: AC_DEFINE_VERSIONLEVEL(DOXYGEN_VERSION_REQUIRED, $ac_doxygen_version) AC_DEFINE_VERSIONLEVEL(DOXYGEN_VERSION_ACTUAL, $doxy_version) if test $DOXYGEN_VERSION_ACTUAL -lt $DOXYGEN_VERSION_REQUIRED; then AC_MSG_RESULT(no); $3 else AC_MSG_RESULT(ok); $2 fielse AC_MSG_WARN(could not find doxygen)fi])dnldnl -------------------------------------------------------dnl @synopsis AC_DEFINE_INSTALL_PATHSdnl Define various installation pathsdnl -------------------------------------------------------AC_DEFUN([AC_DEFINE_INSTALL_PATHS],[ save_prefix="${prefix}" save_exec_prefix="${exec_prefix}" test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="$prefix" DIR_PREFIX="`eval echo \"$prefix\"`" AC_DEFINE_UNQUOTED(DIR_PREFIX,["${DIR_PREFIX}"],[directory "prefix"]) DIR_EXEC_PREFIX="`eval echo \"$exec_prefix\"`" AC_DEFINE_UNQUOTED(DIR_EXEC_PREFIX,["${DIR_EXEC_PREFIX}"],[directory "exec_prefix"]) DIR_BINDIR="`eval echo \"$bindir\"`" AC_DEFINE_UNQUOTED(DIR_BINDIR,["${DIR_BINDIR}"],[directory "bindir"]) DIR_LIBDIR="`eval echo \"$libdir\"`" AC_DEFINE_UNQUOTED(DIR_LIBDIR,["${DIR_LIBDIR}"],[directory "libdir"]) DIR_DATADIR="`eval echo \"$datadir\"`" AC_DEFINE_UNQUOTED(DIR_DATADIR,["${DIR_DATADIR}"],[directory "datadir"]) DIR_MANDIR="`eval echo \"$mandir\"`" AC_DEFINE_UNQUOTED(DIR_MANDIR,["${DIR_MANDIR}"],[directory "mandir"]) prefix="${save_prefix}" exec_prefix="${save_exec_prefix}"])dnl -------------------------------------------------------dnl @synopsis AC_CHECK_CXX_OPT(OPTION,dnl ACTION-IF-OKAY,ACTION-IF-NOT-OKAY)dnl Check if compiler accepts option OPTION.dnl -------------------------------------------------------AC_DEFUN(AC_CHECK_CXX_OPT,[ opt="$1" AC_MSG_CHECKING([if $CXX accepts $opt]) echo 'void f(){}' > conftest.cc if test -z "`${CXX} ${CXXFLAGS} ${OPTS} $opt -c conftest.cc 2>&1`"; then AC_MSG_RESULT(yes) rm conftest.* $2 else AC_MSG_RESULT(no) rm conftest.* $3 fi])dnl -------------------------------------------------------dnl @synopsis AC_CC_OPTIMIZEdnl Setup option --enable-debugdnl Collects optimization/debug option in variable CFLAGS,dnl filtering options already in CFLAGS. Also definednl DEBUG_MODE if appropriate.dnl Adapted from AC_CXX_OPTIMIZE in djvulibrednl -------------------------------------------------------AC_DEFUN([AC_CXX_OPTIMIZE],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Compile with debugging options (default: no)]), [ac_debug=$enableval],[ac_debug=no]) OPTS= AC_SUBST(OPTS) dnl VCOPTS_COMMON="/nologo /G5 /Zp1 /W3 /Za /Op- /GX" # Note: the /Za option might be nice to have, but it is # incompatible with <windows.h>, which some packages # (like the tiff library) require VCOPTS_COMMON="/nologo /G5 /Zp1 /W3" dnl AC_SUBST(OPTS) saved_CXXFLAGS="$CXXFLAGS" saved_CFLAGS="$CFLAGS" CXXFLAGS= CFLAGS= for opt in $saved_CXXFLAGS ; do case $opt in -g*) test $ac_debug != no && OPTS="$OPTS $opt" ;; -O*) ;; *) CXXFLAGS="$CXXFLAGS $opt" ;; esac done for opt in $saved_CFLAGS ; do case $opt in -O*|-g*) ;; *) CFLAGS="$CFLAGS $opt" ;; esac done if test x$ac_debug = xno ; then OPTS=-DNDEBUG if test x$CXX = xcl.exe ; then OPTS="$OPTS $VCOPTS_COMMON /Ow /O2" else AC_CHECK_CXX_OPT([-O3],[OPTS="$OPTS -O3"], [ AC_CHECK_CXX_OPT([-O2], [OPTS="$OPTS -O2"] ) ] ) dnl This triggers compiler bugs with gcc-3.2.2 - comment out for now dnl AC_CHECK_CXX_OPT([-funroll-loops], [OPTS="$OPTS -funroll-loops"]) cpu=`uname -m 2>/dev/null` test -z "$cpu" && cpu=${host_cpu} case "${host_cpu}" in i?86) opt="-mcpu=${host_cpu}" AC_CHECK_CXX_OPT([$opt], [OPTS="$OPTS $opt"]) ;; esac fi else if test x$CXX = xcl.exe ; then OPTS="$OPTS $VCOPTS_COMMON /Od /Z7" fi AC_DEFINE(DEBUG_MODE,1,[Define when compiling in debug mode]) fi if test x$CXX != xcl.exe ; then AC_CHECK_CXX_OPT([-Wall],[OPTS="$OPTS -Wall"]) fi case x"$ac_debug" inchangequote(<<, >>)dnl x[0-9]) OPTS="$OPTS -DDEBUGLVL=$ac_debug" ;; xr*) OPTS="$OPTS -DRUNTIME_DEBUG_ONLY" ;;changequote([, ])dnl esac CXXFLAGS="$CXXFLAGS $OPTS" CFLAGS="$CFLAGS $OPTS"])dnl -------------------------------------------------------dnl @synopsis AC_CXX_MEMBER_TEMPLATESdnl If the compiler supports member templates, dnl define HAVE_MEMBER_TEMPLATES.dnl -------------------------------------------------------AC_DEFUN([AC_CXX_MEMBER_TEMPLATES],[AC_CACHE_CHECK(whether the compiler supports member templates,ac_cv_cxx_member_templates,[AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([template<class T, int N> class A{ public: template<int N2> A<T,N> operator=(const A<T,N2>& z) { return A<T,N>(); }};],[A<double,4> x; A<double,7> y; x = y; return 0;], ac_cv_cxx_member_templates=yes, ac_cv_cxx_member_templates=no) AC_LANG_RESTORE])if test "$ac_cv_cxx_member_templates" = yes; then AC_DEFINE(HAVE_MEMBER_TEMPLATES,1, [define if the compiler supports member templates])fi])dnl -------------------------------------------------------dnl @synopsis AC_CXX_NAMESPACESdnl Define HAVE_NAMESPACES if the compiler supportsdnl namespaces.dnl -------------------------------------------------------AC_DEFUN([AC_CXX_NAMESPACES],[AC_CACHE_CHECK(whether the compiler implements namespaces,ac_cv_cxx_namespaces,[ AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], [using namespace Outer::Inner; return i;], ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) AC_LANG_RESTORE])if test "$ac_cv_cxx_namespaces" = yes && test "$ac_debug" = no; then AC_DEFINE(HAVE_NAMESPACES,1, [define if the compiler implements namespaces])fi])dnl -------------------------------------------------------dnl @synopsis AC_CXX_TYPENAMEdnl Define HAVE_TYPENAME if the compiler recognizes dnl keyword typename.dnl -------------------------------------------------------AC_DEFUN([AC_CXX_TYPENAME],[AC_CACHE_CHECK(whether the compiler recognizes typename,ac_cv_cxx_typename,[AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([template<typename T>class X {public:X(){}};],[X<float> z; return 0;], ac_cv_cxx_typename=yes, ac_cv_cxx_typename=no) AC_LANG_RESTORE])if test "$ac_cv_cxx_typename" = yes; then AC_DEFINE(HAVE_TYPENAME,1,[define if the compiler recognizes typename])fi])dnl -------------------------------------------------------dnl @synopsis AC_CXX_STDINCLUDESdnl Define HAVE_STDINCLUDES if the compiler has thednl new style include files (without the .h)dnl -------------------------------------------------------AC_DEFUN([AC_CXX_STDINCLUDES],[AC_CACHE_CHECK(whether the compiler comes with standard includes,ac_cv_cxx_stdincludes,[AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <new>struct X { int a; X(int a):a(a){}; };X* foo(void *x) { return new(x) X(2); } ],[], ac_cv_cxx_stdincludes=yes, ac_cv_cxx_stdincludes=no) AC_LANG_RESTORE])if test "$ac_cv_cxx_stdincludes" = yes; then AC_DEFINE(HAVE_STDINCLUDES,1, [define if the compiler comes with standard includes])fi])dnl -------------------------------------------------------dnl @synopsis AC_CXX_BOOLdnl If the compiler recognizes bool as a separate built-in type,dnl define HAVE_BOOL. Note that a typedef is not a separatednl type since you cannot overload a function such that it dnl accepts either the basic type or the typedef.dnl -------------------------------------------------------AC_DEFUN([AC_CXX_BOOL],[AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type,ac_cv_cxx_bool,[AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([int f(int x){return 1;}int f(char x){return 1;}int f(bool x){return 1;}],[bool b = true; return f(b);], ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no) AC_LANG_RESTORE])if test "$ac_cv_cxx_bool" = yes; then AC_DEFINE(HAVE_BOOL,1,[define if bool is a built-in type])fi])dnl -------------------------------------------------------dnl @synopsis AC_CXX_EXCEPTIONSdnl If the C++ compiler supports exceptions handling (try,dnl throw and catch), define HAVE_EXCEPTIONS.dnl -------------------------------------------------------AC_DEFUN([AC_CXX_EXCEPTIONS],[AC_CACHE_CHECK(whether the compiler supports exceptions,ac_cv_cxx_exceptions,[AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE(,[try { throw 1; } catch (int i) { return i; }], ac_cv_cxx_exceptions=yes, ac_cv_cxx_exceptions=no) AC_LANG_RESTORE])if test "$ac_cv_cxx_exceptions" = yes; then AC_DEFINE(HAVE_EXCEPTIONS,1,[define if the compiler supports exceptions])fi])dnl -------------------------------------------------------dnl @synopsis AC_CXX_RPOdnl Defines option --enable-rpo and searches program RPO.dnl Set output variables CXXRPOFLAGS and RPO. dnl -------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -