|
[yoda-svn] r579 - in trunk: . m4blackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Mar 22 10:39:57 GMT 2013
Author: buckley Date: Fri Mar 22 10:39:56 2013 New Revision: 579 Log: Using the nice Boost-finding macros from https://github.com/tsuna/boost.m4 and tidying up configure.ac. Removing the use of svn:external to pull in Boost macros and using a minimal local set instead. Added: trunk/m4/ trunk/m4/boost.m4 trunk/m4/cxx.m4 trunk/m4/cython.m4 trunk/m4/osx.m4 trunk/m4/pkgchecks.m4 trunk/m4/python.m4 Modified: trunk/ (props changed) trunk/ChangeLog trunk/configure.ac Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Fri Mar 22 10:33:49 2013 (r578) +++ trunk/ChangeLog Fri Mar 22 10:39:56 2013 (r579) @@ -1,3 +1,11 @@ +2013-03-22 Andy Buckley <andy.buckley at cern.ch> + + * Removing the use of svn:external to pull in Boost macros and + using a minimal local set instead. + + * Using the nice Boost-finding macros from + https://github.com/tsuna/boost.m4 and tidying up configure.ac + 2013-03-15 Andy Buckley <andy.buckley at cern.ch> * Re-organising the C++ side of the auto-format I/O functions, Modified: trunk/configure.ac ============================================================================== --- trunk/configure.ac Fri Mar 22 10:33:49 2013 (r578) +++ trunk/configure.ac Fri Mar 22 10:39:56 2013 (r579) @@ -37,10 +37,25 @@ LIB_SUFFIX=\\\"$shrext_cmds\\\" AC_SUBST([LIB_SUFFIX]) +## Set default build flags +AM_CPPFLAGS="-I\$(top_srcdir)/include -I\$(top_builddir)/include" +AM_CPPFLAGS="$AM_CPPFLAGS -I\$(BOOSTINCPATH) \$(BOOST_CPPFLAGS)" +AC_CEDAR_CHECKCXXFLAG([-pedantic], [AM_CXXFLAGS="$AM_CXXFLAGS -pedantic "]) +AC_CEDAR_CHECKCXXFLAG([-Wall], [AM_CXXFLAGS="$AM_CXXFLAGS -Wall -Wno-format"]) +AC_CEDAR_CHECKCXXFLAG([-std=c++98], [AM_CXXFLAGS="$AM_CXXFLAGS -std=c++98 "]) + +## Debug flag (default=none) +AC_ARG_ENABLE([debug], [AC_HELP_STRING(--enable-debug, [build with debugging symbols @<:@default=no@:>@])], [], [enable_debug=no]) +if test x$enable_debug == xyes; then + [AM_CXXFLAGS="$AM_CXXFLAGS -g"] +fi + + ## Build Doxygen if possible AC_PATH_PROG(DOXYGEN, doxygen) AM_CONDITIONAL(WITH_DOXYGEN, test "$DOXYGEN") + ## Python extension AC_ARG_ENABLE(pyext, [AC_HELP_STRING(--disable-pyext, [don't build Python module (default=build)])], @@ -61,7 +76,7 @@ AC_MSG_RESULT([$python_incpath]) python_header="$python_incpath/Python.h" if test -z "$python_incpath"; then - AC_MSG_ERROR([Can't build Python extension since include directory cannot be determined from distutils]) + AC_MSG_ERROR([Can't build Python extension since include directory cannot be determined from distutils]) enable_pyext=no elif test ! -e "$python_header"; then AC_MSG_ERROR([Can't build Python extension since header file $python_header cannot be found]) @@ -72,7 +87,6 @@ enable_pyext=no fi fi - ## Cython checks (Probably need some help...) # TODO: "Tarball users" should ideally not need to have Cython installed if test x$enable_pyext == xyes; then @@ -84,13 +98,13 @@ cython_compiler=$CXX fi fi - -## Finish +## Finish Python extension testing if test x$enable_pyext == xyes; then AC_MSG_NOTICE([All Python build checks successful: 'yoda' Python extension will be built]) fi AM_CONDITIONAL(ENABLE_PYEXT, [test x$enable_pyext == xyes]) + ## Optional ROOT analysis framework #AC_ARG_ENABLE([ROOT], [AC_HELP_STRING(--enable-root, [build with ROOT output @<:@default=yes@:>@])], [], [enable_root=yes]) #if test "x$enable_root" != "xno"; then @@ -100,44 +114,21 @@ # AM_CONDITIONAL(WITH_ROOT, [test x$with_root == xyes]) #fi -## Boost C++ header library -AC_CEDAR_HEADERS([Boost], , , [AC_MSG_ERROR([Boost is required])]) -oldCPPFLAGS=$CPPFLAGS -CPPFLAGS="$CPPFLAGS -I$BOOSTINCPATH" -BOOSTERRMSG="You need at least version 1.34.0 of Boost for this installation." -BOOSTERRMSG="$BOOSTERRMSG If you want to use Boost from a non-standard location," -BOOSTERRMSG="$BOOSTERRMSG please specify '--with-boost-incpath=/path/to/boost_1_35/include'" -BOOSTERRMSG="$BOOSTERRMSG as option to the configure script or run the rivet-bootstrap script " -BOOSTERRMSG="$BOOSTERRMSG with the --install-boost option, or --boost=/path/to/boost" -AC_CHECK_HEADER([boost/foreach.hpp], [], [AC_MSG_ERROR([Boost foreach not found. $BOOSTERRMSG])]) -AC_CHECK_HEADER([boost/smart_ptr.hpp], [], [AC_MSG_ERROR([Boost smart_ptr not found. $BOOSTERRMSG])]) -AC_CHECK_HEADER([boost/lexical_cast.hpp], [], [AC_MSG_ERROR([Boost lexical_cast not found. $BOOSTERRMSG])]) -AC_CHECK_HEADER([boost/assign.hpp], [], [AC_MSG_ERROR([Boost assign not found. $BOOSTERRMSG])]) -AC_CHECK_HEADER([boost/random.hpp], [], [AC_MSG_ERROR([Boost random numbers not found. $BOOSTERRMSG])]) -CPPFLAGS=$oldCPPFLAGS - -## Set default build flags -AM_CPPFLAGS="-I\$(top_srcdir)/include -I\$(top_builddir)/include" -AM_CPPFLAGS="$AM_CPPFLAGS -I\$(BOOSTINCPATH) \$(BOOST_CPPFLAGS)" - -AC_CEDAR_CHECKCXXFLAG([-pedantic], [AM_CXXFLAGS="$AM_CXXFLAGS -pedantic "]) -dnl ansi is implied by std=c++, listing it confuses clang -dnl AC_CEDAR_CHECKCXXFLAG([-ansi], [AM_CXXFLAGS="$AM_CXXFLAGS -ansi "]) -AC_CEDAR_CHECKCXXFLAG([-Wall], [AM_CXXFLAGS="$AM_CXXFLAGS -Wall -Wno-format"]) -dnl AC_CEDAR_CHECKCXXFLAG([-Wno-long-long], [AM_CXXFLAGS="$AM_CXXFLAGS -Wno-long-long "]) -dnl Need to be C++98! -AC_CEDAR_CHECKCXXFLAG([-std=c++98], [AM_CXXFLAGS="$AM_CXXFLAGS -std=c++98 "]) +## Boost C++ utility library +BOOST_REQUIRE([1.34.0]) +BOOST_FOREACH +BOOST_SMART_PTR +BOOST_FIND_HEADER([boost/lexical_cast.hpp]) +BOOST_FIND_HEADER([boost/assign.hpp]) -## Debug flag (default=none) -AC_ARG_ENABLE([debug], [AC_HELP_STRING(--enable-debug, [build with debugging symbols @<:@default=no@:>@])], [], [enable_debug=no]) -if test x$enable_debug == xyes; then - [AM_CXXFLAGS="$AM_CXXFLAGS -g"] -fi +## Substitute the default build flags after lib testing AC_SUBST(AM_CPPFLAGS) AC_SUBST(AM_CXXFLAGS) + +## BUild file output AC_EMPTY_SUBST AC_CONFIG_FILES([Makefile Doxyfile]) AC_CONFIG_FILES([include/Makefile include/YODA/Makefile]) Added: trunk/m4/boost.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/m4/boost.m4 Fri Mar 22 10:39:56 2013 (r579) @@ -0,0 +1,1239 @@ +# boost.m4: Locate Boost headers and libraries for autoconf-based projects. +# Copyright (C) 2007, 2008, 2009, 2010, 2011 Benoit Sigoure <tsuna at lrde.epita.fr> +# +# 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. +# +# Additional permission under section 7 of the GNU General Public +# License, version 3 ("GPLv3"): +# +# If you convey this file as part of a work that contains a +# configuration script generated by Autoconf, you may do so under +# terms of your choice. +# +# 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/>. + +m4_define([_BOOST_SERIAL], [m4_translit([ +# serial 17 +], [# +], [])]) + +# Original sources can be found at http://github.com/tsuna/boost.m4 +# You can fetch the latest version of the script by doing: +# wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4 + +# ------ # +# README # +# ------ # + +# This file provides several macros to use the various Boost libraries. +# The first macro is BOOST_REQUIRE. It will simply check if it's possible to +# find the Boost headers of a given (optional) minimum version and it will +# define BOOST_CPPFLAGS accordingly. It will add an option --with-boost to +# your configure so that users can specify non standard locations. +# If the user's environment contains BOOST_ROOT and --with-boost was not +# specified, --with-boost=$BOOST_ROOT is implicitly used. +# For more README and documentation, go to http://github.com/tsuna/boost.m4 +# Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL. If you don't, don't worry, +# simply read the README, it will show you what to do step by step. + +m4_pattern_forbid([^_?(BOOST|Boost)_]) + + +# _BOOST_SED_CPP(SED-PROGRAM, PROGRAM, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# -------------------------------------------------------- +# Same as AC_EGREP_CPP, but leave the result in conftest.i. +# +# SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP. It is expanded +# in double-quotes, so escape your double quotes. +# +# It could be useful to turn this into a macro which extracts the +# value of any macro. +m4_define([_BOOST_SED_CPP], +[AC_LANG_PREPROC_REQUIRE()dnl +AC_REQUIRE([AC_PROG_SED])dnl +AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])]) +AS_IF([dnl eval is necessary to expand ac_cpp. +dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. +dnl Beware of Windows end-of-lines, for instance if we are running +dnl some Windows programs under Wine. In that case, boost/version.hpp +dnl is certainly using "\r\n", but the regular Unix shell will only +dnl strip `\n' with backquotes, not the `\r'. This results in +dnl boost_cv_lib_version='1_37\r' for instance, which breaks +dnl everything else. +dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK +(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | + tr -d '\r' | + $SED -n -e "$1" >conftest.i 2>&1], + [$3], + [$4]) +rm -rf conftest* +])# AC_EGREP_CPP + + + +# BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND]) +# ----------------------------------------------- +# Look for Boost. If version is given, it must either be a literal of the form +# "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a +# variable "$var". +# Defines the value BOOST_CPPFLAGS. This macro only checks for headers with +# the required version, it does not check for any of the Boost libraries. +# On # success, defines HAVE_BOOST. On failure, calls the optional +# ACTION-IF-NOT-FOUND action if one was supplied. +# Otherwise aborts with an error message. +AC_DEFUN([BOOST_REQUIRE], +[AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_GREP])dnl +echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD +boost_save_IFS=$IFS +boost_version_req=$1 +IFS=. +set x $boost_version_req 0 0 0 +IFS=$boost_save_IFS +shift +boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"` +boost_version_req_string=$[1].$[2].$[3] +AC_ARG_WITH([boost], + [AS_HELP_STRING([--with-boost=DIR], + [prefix of Boost $1 @<:@guess@:>@])])dnl +AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl +# If BOOST_ROOT is set and the user has not provided a value to +# --with-boost, then treat BOOST_ROOT as if it the user supplied it. +if test x"$BOOST_ROOT" != x; then + if test x"$with_boost" = x; then + AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT]) + with_boost=$BOOST_ROOT + else + AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost]) + fi +fi +AC_SUBST([DISTCHECK_CONFIGURE_FLAGS], + ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl +boost_save_CPPFLAGS=$CPPFLAGS + AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string], + [boost_cv_inc_path], + [boost_cv_inc_path=no +AC_LANG_PUSH([C++])dnl +m4_pattern_allow([^BOOST_VERSION$])dnl + AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp> +#if !defined BOOST_VERSION +# error BOOST_VERSION is not defined +#elif BOOST_VERSION < $boost_version_req +# error Boost headers version < $boost_version_req +#endif +]])]) + # If the user provided a value to --with-boost, use it and only it. + case $with_boost in #( + ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \ + /usr/include C:/Boost/include;; #( + *) set x "$with_boost/include" "$with_boost";; + esac + shift + for boost_dir + do + # Without --layout=system, Boost (or at least some versions) installs + # itself in <prefix>/include/boost-<version>. This inner loop helps to + # find headers in such directories. + # + # Any ${boost_dir}/boost-x_xx directories are searched in reverse version + # order followed by ${boost_dir}. The final '.' is a sentinel for + # searching $boost_dir" itself. Entries are whitespace separated. + # + # I didn't indent this loop on purpose (to avoid over-indented code) + boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \ + && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \ + && echo .` + for boost_inc in $boost_layout_system_search_list + do + if test x"$boost_inc" != x.; then + boost_inc="$boost_dir/$boost_inc" + else + boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list + fi + if test x"$boost_inc" != x; then + # We are going to check whether the version of Boost installed + # in $boost_inc is usable by running a compilation that + # #includes it. But if we pass a -I/some/path in which Boost + # is not installed, the compiler will just skip this -I and + # use other locations (either from CPPFLAGS, or from its list + # of system include directories). As a result we would use + # header installed on the machine instead of the /some/path + # specified by the user. So in that precise case (trying + # $boost_inc), make sure the version.hpp exists. + # + # Use test -e as there can be symlinks. + test -e "$boost_inc/boost/version.hpp" || continue + CPPFLAGS="$CPPFLAGS -I$boost_inc" + fi + AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no]) + if test x"$boost_cv_inc_path" = xyes; then + if test x"$boost_inc" != x; then + boost_cv_inc_path=$boost_inc + fi + break 2 + fi + done + done +AC_LANG_POP([C++])dnl + ]) + case $boost_cv_inc_path in #( + no) + boost_errmsg="cannot find Boost headers version >= $boost_version_req_string" + m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])], + [AC_MSG_NOTICE([$boost_errmsg])]) + $2 + ;;#( + yes) + BOOST_CPPFLAGS= + ;;#( + *) + AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl + ;; + esac + if test x"$boost_cv_inc_path" != xno; then + AC_DEFINE([HAVE_BOOST], [1], + [Defined if the requested minimum BOOST version is satisfied]) + AC_CACHE_CHECK([for Boost's header version], + [boost_cv_lib_version], + [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl + _BOOST_SED_CPP([/^boost-lib-version = /{s///;s/\"//g;p;q;}], + [#include <boost/version.hpp> +boost-lib-version = BOOST_LIB_VERSION], + [boost_cv_lib_version=`cat conftest.i`])]) + # e.g. "134" for 1_34_1 or "135" for 1_35 + boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'` + case $boost_major_version in #( + '' | *[[!0-9]]*) + AC_MSG_ERROR([invalid value: boost_major_version=$boost_major_version]) + ;; + esac +fi +CPPFLAGS=$boost_save_CPPFLAGS +])# BOOST_REQUIRE + +# BOOST_STATIC() +# -------------- +# Add the "--enable-static-boost" configure argument. If this argument is given +# on the command line, static versions of the libraries will be looked up. +AC_DEFUN([BOOST_STATIC], + [AC_ARG_ENABLE([static-boost], + [AS_HELP_STRING([--enable-static-boost], + [Prefer the static boost libraries over the shared ones [no]])], + [enable_static_boost=yes], + [enable_static_boost=no])])# BOOST_STATIC + +# BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND]) +# -------------------------------------------------------------------------- +# Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for +# some parts of the Boost library which are only made of headers and don't +# require linking (such as Boost.Foreach). +# +# Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be +# found in the first place, in which case by default a notice is issued to the +# user. Presumably if we haven't died already it's because it's OK to not have +# Boost, which is why only a notice is issued instead of a hard error. +# +# Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in +# case of success # (where HEADER-NAME is written LIKE_THIS, e.g., +# HAVE_BOOST_FOREACH_HPP). +AC_DEFUN([BOOST_FIND_HEADER], +[AC_REQUIRE([BOOST_REQUIRE])dnl +if test x"$boost_cv_inc_path" = xno; then + m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])]) +else +AC_LANG_PUSH([C++])dnl +boost_save_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" +AC_CHECK_HEADER([$1], + [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1], + [Define to 1 if you have <$1>])])], + [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])]) +CPPFLAGS=$boost_save_CPPFLAGS +AC_LANG_POP([C++])dnl +fi +])# BOOST_FIND_HEADER + + +# BOOST_FIND_LIB([LIB-NAME], [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], +# [CXX-PROLOGUE]) +# ------------------------------------------------------------------------- +# Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for +# libboost_thread). Check that HEADER-NAME works and check that +# libboost_LIB-NAME can link with the code CXX-TEST. The optional argument +# CXX-PROLOGUE can be used to include some C++ code before the `main' +# function. +# +# Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above). +# +# Boost libraries typically come compiled with several flavors (with different +# runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one +# or more of the following letters: sgdpn (in that order). s = static +# runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build, +# n = (unsure) STLPort build without iostreams from STLPort (it looks like `n' +# must always be used along with `p'). Additionally, PREFERRED-RT-OPT can +# start with `mt-' to indicate that there is a preference for multi-thread +# builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp +# ... If you want to make sure you have a specific version of Boost +# (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro. +AC_DEFUN([BOOST_FIND_LIB], +[AC_REQUIRE([BOOST_REQUIRE])dnl +AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl +AC_REQUIRE([BOOST_STATIC])dnl +AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl +if test x"$boost_cv_inc_path" = xno; then + AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library]) +else +dnl The else branch is huge and wasn't intended on purpose. +AC_LANG_PUSH([C++])dnl +AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl +AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl +AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl +AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl +BOOST_FIND_HEADER([$3]) +boost_save_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" +# Now let's try to find the library. The algorithm is as follows: first look +# for a given library name according to the user's PREFERRED-RT-OPT. For each +# library name, we prefer to use the ones that carry the tag (toolset name). +# Each library is searched through the various standard paths were Boost is +# usually installed. If we can't find the standard variants, we try to +# enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist +# but there's -obviously- libboost_threads-mt.dylib). +AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib], + [Boost_lib=no + case "$2" in #( + mt | mt-) boost_mt=-mt; boost_rtopt=;; #( + mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$2" : 'Xmt-*\(.*\)'`;; #( + *) boost_mt=; boost_rtopt=$2;; + esac + if test $enable_static_boost = yes; then + boost_rtopt="s$boost_rtopt" + fi + # Find the proper debug variant depending on what we've been asked to find. + case $boost_rtopt in #( + *d*) boost_rt_d=$boost_rtopt;; #( + *[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn') + boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #( + *) boost_rt_d='-d';; + esac + # If the PREFERRED-RT-OPT are not empty, prepend a `-'. + test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt" + $boost_guess_use_mt && boost_mt=-mt + # Look for the abs path the static archive. + # $libext is computed by Libtool but let's make sure it's non empty. + test -z "$libext" && + AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?]) + boost_save_ac_objext=$ac_objext + # Generate the test file. + AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$3> +$5], [$4])]) +dnl Optimization hacks: compiling C++ is slow, especially with Boost. What +dnl we're trying to do here is guess the right combination of link flags +dnl (LIBS / LDFLAGS) to use a given library. This can take several +dnl iterations before it succeeds and is thus *very* slow. So what we do +dnl instead is that we compile the code first (and thus get an object file, +dnl typically conftest.o). Then we try various combinations of link flags +dnl until we succeed to link conftest.o in an executable. The problem is +dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always +dnl remove all the temporary files including conftest.o. So the trick here +dnl is to temporarily change the value of ac_objext so that conftest.o is +dnl preserved accross tests. This is obviously fragile and I will burn in +dnl hell for not respecting Autoconf's documented interfaces, but in the +dnl mean time, it optimizes the macro by a factor of 5 to 30. +dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left +dnl empty because the test file is generated only once above (before we +dnl start the for loops). + AC_COMPILE_IFELSE([], + [ac_objext=do_not_rm_me_plz], + [AC_MSG_ERROR([cannot compile a test that uses Boost $1])]) + ac_objext=$boost_save_ac_objext + boost_failed_libs= +# Don't bother to ident the 6 nested for loops, only the 2 innermost ones +# matter. +for boost_tag_ in -$boost_cv_lib_tag ''; do +for boost_ver_ in -$boost_cv_lib_version ''; do +for boost_mt_ in $boost_mt -mt ''; do +for boost_rtopt_ in $boost_rtopt '' -d; do + for boost_lib in \ + boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ + boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \ + boost_$1$boost_tag_$boost_mt_$boost_ver_ \ + boost_$1$boost_tag_$boost_ver_ + do + # Avoid testing twice the same lib + case $boost_failed_libs in #( + *@$boost_lib@*) continue;; + esac + # If with_boost is empty, we'll search in /lib first, which is not quite + # right so instead we'll try to a location based on where the headers are. + boost_tmp_lib=$with_boost + test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} + for boost_ldpath in "$boost_tmp_lib/lib" '' \ + /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ + "$with_boost" C:/Boost/lib /lib* + do + test -e "$boost_ldpath" || continue + boost_save_LDFLAGS=$LDFLAGS + # Are we looking for a static library? + case $boost_ldpath:$boost_rtopt_ in #( + *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) + Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" + test -e "$Boost_lib_LIBS" || continue;; #( + *) # No: use -lboost_foo to find the shared library. + Boost_lib_LIBS="-l$boost_lib";; + esac + boost_save_LIBS=$LIBS + LIBS="$Boost_lib_LIBS $LIBS" + test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" +dnl First argument of AC_LINK_IFELSE left empty because the test file is +dnl generated only once above (before we start the for loops). + _BOOST_AC_LINK_IFELSE([], + [Boost_lib=yes], [Boost_lib=no]) + ac_objext=$boost_save_ac_objext + LDFLAGS=$boost_save_LDFLAGS + LIBS=$boost_save_LIBS + if test x"$Boost_lib" = xyes; then + # Check or used cached result of whether or not using -R or -rpath makes sense. + # Some implementations of ld, such as for Mac OSX, require -rpath but + # -R is the flag known to work on other systems. + # https://github.com/tsuna/boost.m4/issues/19 + AC_CACHE_VAL([boost_cv_rpath_link_ldflag], + [for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do + LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" + LIBS="$Boost_lib_LIBS $boost_save_LIBS" + _BOOST_AC_LINK_IFELSE([], + [boost_rpath_link_ldflag_found=yes + break], + [boost_rpath_link_ldflag_found=no]) + done + AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"], + [AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])]) + LDFLAGS=$boost_save_LDFLAGS + LIBS=$boost_save_LIBS + ]) + Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" + Boost_lib_LDPATH="$boost_ldpath" + break 6 + else + boost_failed_libs="$boost_failed_libs@$boost_lib@" + fi + done + done +done +done +done +done +rm -f conftest.$ac_objext +]) +case $Boost_lib in #( + no) _AC_MSG_LOG_CONFTEST + AC_MSG_ERROR([cannot find the flags to link with Boost $1]) + ;; +esac +AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl +AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl +AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl +AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl +CPPFLAGS=$boost_save_CPPFLAGS +AS_VAR_POPDEF([Boost_lib])dnl +AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl +AS_VAR_POPDEF([Boost_lib_LDPATH])dnl +AS_VAR_POPDEF([Boost_lib_LIBS])dnl +AC_LANG_POP([C++])dnl +fi +])# BOOST_FIND_LIB + + +# --------------------------------------- # +# Checks for the various Boost libraries. # +# --------------------------------------- # + +# List of boost libraries: http://www.boost.org/libs/libraries.htm +# The page http://beta.boost.org/doc/libs is useful: it gives the first release +# version of each library (among other things). + +# BOOST_DEFUN(LIBRARY, CODE) +# -------------------------- +# Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE. +# +# Use indir to avoid the warning on underquoted macro name given to AC_DEFUN. +m4_define([BOOST_DEFUN], +[m4_indir([AC_DEFUN], + m4_toupper([BOOST_$1]), +[m4_pushdef([BOOST_Library], [$1])dnl +$2 +m4_popdef([BOOST_Library])dnl +]) +]) + +# BOOST_ARRAY() +# ------------- +# Look for Boost.Array +BOOST_DEFUN([Array], +[BOOST_FIND_HEADER([boost/array.hpp])]) + + +# BOOST_ASIO() +# ------------ +# Look for Boost.Asio (new in Boost 1.35). +BOOST_DEFUN([Asio], +[AC_REQUIRE([BOOST_SYSTEM])dnl +BOOST_FIND_HEADER([boost/asio.hpp])]) + + +# BOOST_BIND() +# ------------ +# Look for Boost.Bind +BOOST_DEFUN([Bind], +[BOOST_FIND_HEADER([boost/bind.hpp])]) + + +# BOOST_CHRONO() +# ------------------ +# Look for Boost.Chrono +BOOST_DEFUN([Chrono], +[# Do we have to check for Boost.System? This link-time dependency was +# added as of 1.35.0. If we have a version <1.35, we must not attempt to +# find Boost.System as it didn't exist by then. +if test $boost_major_version -ge 135; then +BOOST_SYSTEM([$1]) +fi # end of the Boost.System check. +boost_filesystem_save_LIBS=$LIBS +boost_filesystem_save_LDFLAGS=$LDFLAGS +m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl +LIBS="$LIBS $BOOST_SYSTEM_LIBS" +LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" +BOOST_FIND_LIB([chrono], [$1], + [boost/chrono.hpp], + [boost::chrono::thread_clock d;]) +if test $enable_static_boost = yes && test $boost_major_version -ge 135; then + AC_SUBST([BOOST_FILESYSTEM_LIBS], ["$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"]) +fi +LIBS=$boost_filesystem_save_LIBS +LDFLAGS=$boost_filesystem_save_LDFLAGS + +])# BOOST_CHRONO + + +# BOOST_CONVERSION() +# ------------------ +# Look for Boost.Conversion (cast / lexical_cast) +BOOST_DEFUN([Conversion], +[BOOST_FIND_HEADER([boost/cast.hpp]) +BOOST_FIND_HEADER([boost/lexical_cast.hpp]) +])# BOOST_CONVERSION + + +# BOOST_CRC() +# ----------- +# Look for Boost.CRC +BOOST_DEFUN([CRC], +[BOOST_FIND_HEADER([boost/crc.hpp]) +])# BOOST_CRC + + +# BOOST_DATE_TIME([PREFERRED-RT-OPT]) +# ----------------------------------- +# Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Date_Time], +[BOOST_FIND_LIB([date_time], [$1], + [boost/date_time/posix_time/posix_time.hpp], + [boost::posix_time::ptime t;]) +])# BOOST_DATE_TIME + + +# BOOST_FILESYSTEM([PREFERRED-RT-OPT]) +# ------------------------------------ +# Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see +# the documentation of BOOST_FIND_LIB above. +# Do not check for boost/filesystem.hpp because this file was introduced in +# 1.34. +BOOST_DEFUN([Filesystem], +[# Do we have to check for Boost.System? This link-time dependency was +# added as of 1.35.0. If we have a version <1.35, we must not attempt to +# find Boost.System as it didn't exist by then. +if test $boost_major_version -ge 135; then +BOOST_SYSTEM([$1]) +fi # end of the Boost.System check. +boost_filesystem_save_LIBS=$LIBS +boost_filesystem_save_LDFLAGS=$LDFLAGS +m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl +LIBS="$LIBS $BOOST_SYSTEM_LIBS" +LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" +BOOST_FIND_LIB([filesystem], [$1], + [boost/filesystem/path.hpp], [boost::filesystem::path p;]) +if test $enable_static_boost = yes && test $boost_major_version -ge 135; then + AC_SUBST([BOOST_FILESYSTEM_LIBS], ["$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"]) +fi +LIBS=$boost_filesystem_save_LIBS +LDFLAGS=$boost_filesystem_save_LDFLAGS +])# BOOST_FILESYSTEM + + +# BOOST_FOREACH() +# --------------- +# Look for Boost.Foreach +BOOST_DEFUN([Foreach], +[BOOST_FIND_HEADER([boost/foreach.hpp])]) + + +# BOOST_FORMAT() +# -------------- +# Look for Boost.Format +# Note: we can't check for boost/format/format_fwd.hpp because the header isn't +# standalone. It can't be compiled because it triggers the following error: +# boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std' +# does not name a type +BOOST_DEFUN([Format], +[BOOST_FIND_HEADER([boost/format.hpp])]) + + +# BOOST_FUNCTION() +# ---------------- +# Look for Boost.Function +BOOST_DEFUN([Function], +[BOOST_FIND_HEADER([boost/function.hpp])]) + + +# BOOST_GEOMETRY() +# ---------------- +# Look for Boost.Geometry (new since 1.47.0). +BOOST_DEFUN([Geometry], +[BOOST_FIND_HEADER([boost/geometry.hpp]) +])# BOOST_GEOMETRY + + +# BOOST_GRAPH([PREFERRED-RT-OPT]) +# ------------------------------- +# Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Graph], +[BOOST_FIND_LIB([graph], [$1], + [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;]) +])# BOOST_GRAPH + + +# BOOST_IOSTREAMS([PREFERRED-RT-OPT]) +# ----------------------------------- +# Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([IOStreams], +[BOOST_FIND_LIB([iostreams], [$1], + [boost/iostreams/device/file_descriptor.hpp], + [boost::iostreams::file_descriptor fd; fd.close();]) +])# BOOST_IOSTREAMS + + +# BOOST_HASH() +# ------------ +# Look for Boost.Functional/Hash +BOOST_DEFUN([Hash], +[BOOST_FIND_HEADER([boost/functional/hash.hpp])]) + + +# BOOST_LAMBDA() +# -------------- +# Look for Boost.Lambda +BOOST_DEFUN([Lambda], +[BOOST_FIND_HEADER([boost/lambda/lambda.hpp])]) + + +# BOOST_LOG([PREFERRED-RT-OPT]) +# ----------------------------- +# Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Log], +[BOOST_FIND_LIB([log], [$1], + [boost/log/core/core.hpp], + [boost::log::attribute a; a.get_value();]) +])# BOOST_LOG + + +# BOOST_LOG_SETUP([PREFERRED-RT-OPT]) +# ----------------------------------- +# Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Log_Setup], +[AC_REQUIRE([BOOST_LOG])dnl +BOOST_FIND_LIB([log_setup], [$1], + [boost/log/utility/init/from_settings.hpp], + [boost::log::basic_settings<char> bs; bs.empty();]) +])# BOOST_LOG_SETUP + + +# BOOST_MATH() +# ------------ +# Look for Boost.Math +# TODO: This library isn't header-only but it comes in multiple different +# flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99, +# libboost_math_c99f, libboost_math_c99l, libboost_math_tr1, +# libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the +# right thing anyway. +BOOST_DEFUN([Math], +[BOOST_FIND_HEADER([boost/math/special_functions.hpp])]) + + +# BOOST_MULTIARRAY() +# ------------------ +# Look for Boost.MultiArray +BOOST_DEFUN([MultiArray], +[BOOST_FIND_HEADER([boost/multi_array.hpp])]) + + +# BOOST_NUMERIC_CONVERSION() +# -------------------------- +# Look for Boost.NumericConversion (policy-based numeric conversion) +BOOST_DEFUN([Numeric_Conversion], +[BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp]) +])# BOOST_NUMERIC_CONVERSION + + +# BOOST_OPTIONAL() +# ---------------- +# Look for Boost.Optional +BOOST_DEFUN([Optional], +[BOOST_FIND_HEADER([boost/optional.hpp])]) + + +# BOOST_PREPROCESSOR() +# -------------------- +# Look for Boost.Preprocessor +BOOST_DEFUN([Preprocessor], +[BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])]) + + +# BOOST_UNORDERED() +# ----------------- +# Look for Boost.Unordered +BOOST_DEFUN([Unordered], +[BOOST_FIND_HEADER([boost/unordered_map.hpp])]) + + +# BOOST_UUID() +# ------------ +# Look for Boost.Uuid +BOOST_DEFUN([Uuid], +[BOOST_FIND_HEADER([boost/uuid/uuid.hpp])]) + + +# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT]) +# ----------------------------------------- +# Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT, +# see the documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Program_Options], +[BOOST_FIND_LIB([program_options], [$1], + [boost/program_options.hpp], + [boost::program_options::options_description d("test");]) +])# BOOST_PROGRAM_OPTIONS + + + +# _BOOST_PYTHON_CONFIG(VARIABLE, FLAG) +# ------------------------------------ +# Save VARIABLE, and define it via `python-config --FLAG`. +# Substitute BOOST_PYTHON_VARIABLE. +m4_define([_BOOST_PYTHON_CONFIG], +[AC_SUBST([BOOST_PYTHON_$1], + [`python-config --$2 2>/dev/null`])dnl +boost_python_save_$1=$$1 +$1="$$1 $BOOST_PYTHON_$1"]) + + +# BOOST_PYTHON([PREFERRED-RT-OPT]) +# -------------------------------- +# Look for Boost.Python. For the documentation of PREFERRED-RT-OPT, +# see the documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Python], +[_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes]) +_BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags]) +_BOOST_PYTHON_CONFIG([LIBS], [libs]) +m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl +BOOST_FIND_LIB([python], [$1], + [boost/python.hpp], + [], [BOOST_PYTHON_MODULE(empty) {}]) +CPPFLAGS=$boost_python_save_CPPFLAGS +LDFLAGS=$boost_python_save_LDFLAGS +LIBS=$boost_python_save_LIBS +])# BOOST_PYTHON + + +# BOOST_REF() +# ----------- +# Look for Boost.Ref +BOOST_DEFUN([Ref], +[BOOST_FIND_HEADER([boost/ref.hpp])]) + + +# BOOST_REGEX([PREFERRED-RT-OPT]) +# ------------------------------- +# Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Regex], +[BOOST_FIND_LIB([regex], [$1], + [boost/regex.hpp], + [boost::regex exp("*"); boost::regex_match("foo", exp);]) +])# BOOST_REGEX + + +# BOOST_SERIALIZATION([PREFERRED-RT-OPT]) +# --------------------------------------- +# Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see +# the documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Serialization], +[BOOST_FIND_LIB([serialization], [$1], + [boost/archive/text_oarchive.hpp], + [std::ostream* o = 0; // Cheap way to get an ostream... + boost::archive::text_oarchive t(*o);]) +])# BOOST_SERIALIZATION + + +# BOOST_SIGNALS([PREFERRED-RT-OPT]) +# --------------------------------- +# Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Signals], +[BOOST_FIND_LIB([signals], [$1], + [boost/signal.hpp], + [boost::signal<void ()> s;]) +])# BOOST_SIGNALS + + +# BOOST_SIGNALS2() +# ---------------- +# Look for Boost.Signals2 (new since 1.39.0). +BOOST_DEFUN([Signals2], +[BOOST_FIND_HEADER([boost/signals2.hpp]) +])# BOOST_SIGNALS2 + + +# BOOST_SMART_PTR() +# ----------------- +# Look for Boost.SmartPtr +BOOST_DEFUN([Smart_Ptr], +[BOOST_FIND_HEADER([boost/scoped_ptr.hpp]) +BOOST_FIND_HEADER([boost/shared_ptr.hpp]) +]) + + +# BOOST_STATICASSERT() +# -------------------- +# Look for Boost.StaticAssert +BOOST_DEFUN([StaticAssert], +[BOOST_FIND_HEADER([boost/static_assert.hpp])]) + + +# BOOST_STRING_ALGO() +# ------------------- +# Look for Boost.StringAlgo +BOOST_DEFUN([String_Algo], +[BOOST_FIND_HEADER([boost/algorithm/string.hpp]) +]) + + +# BOOST_SYSTEM([PREFERRED-RT-OPT]) +# -------------------------------- +# Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. This library was introduced in Boost +# 1.35.0. +BOOST_DEFUN([System], +[BOOST_FIND_LIB([system], [$1], + [boost/system/error_code.hpp], + [boost::system::error_code e; e.clear();]) +])# BOOST_SYSTEM + + +# BOOST_TEST([PREFERRED-RT-OPT]) +# ------------------------------ +# Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Test], +[m4_pattern_allow([^BOOST_CHECK$])dnl +BOOST_FIND_LIB([unit_test_framework], [$1], + [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);], + [using boost::unit_test::test_suite; + test_suite* init_unit_test_suite(int argc, char ** argv) + { return NULL; }]) +])# BOOST_TEST + + +# BOOST_THREADS([PREFERRED-RT-OPT]) +# --------------------------------- +# Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +# FIXME: Provide an alias "BOOST_THREAD". +BOOST_DEFUN([Threads], +[dnl Having the pthread flag is required at least on GCC3 where +dnl boost/thread.hpp would complain if we try to compile without +dnl -pthread on GNU/Linux. +AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl +boost_threads_save_LIBS=$LIBS +boost_threads_save_LDFLAGS=$LDFLAGS +boost_threads_save_CPPFLAGS=$CPPFLAGS +# Link-time dependency from thread to system was added as of 1.49.0. +if test $boost_major_version -ge 149; then +BOOST_SYSTEM([$1]) +fi # end of the Boost.System check. +m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl +LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" +LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" +# Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3, +# boost/thread.hpp will trigger a #error if -pthread isn't used: +# boost/config/requires_threads.hpp:47:5: #error "Compiler threading support +# is not turned on. Please set the correct command line options for +# threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)" +CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag" + +# When compiling for the Windows platform, the threads library is named +# differently. +case $host_os in + (*mingw*) + BOOST_FIND_LIB([thread_win32], [$1], + [boost/thread.hpp], [boost::thread t; boost::mutex m;]) + BOOST_THREAD_LDFLAGS=$BOOST_THREAD_WIN32_LDFLAGS + BOOST_THREAD_LDPATH=$BOOST_THREAD_WIN32_LDPATH + BOOST_THREAD_LIBS=$BOOST_THREAD_WIN32_LIBS + ;; + (*) + BOOST_FIND_LIB([thread], [$1], + [boost/thread.hpp], [boost::thread t; boost::mutex m;]) + ;; +esac + +BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" +BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS" +BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag" +LIBS=$boost_threads_save_LIBS +LDFLAGS=$boost_threads_save_LDFLAGS +CPPFLAGS=$boost_threads_save_CPPFLAGS +])# BOOST_THREADS + + +# BOOST_TOKENIZER() +# ----------------- +# Look for Boost.Tokenizer +BOOST_DEFUN([Tokenizer], +[BOOST_FIND_HEADER([boost/tokenizer.hpp])]) + + +# BOOST_TRIBOOL() +# --------------- +# Look for Boost.Tribool +BOOST_DEFUN([Tribool], +[BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp]) +BOOST_FIND_HEADER([boost/logic/tribool.hpp]) +]) + + +# BOOST_TUPLE() +# ------------- +# Look for Boost.Tuple +BOOST_DEFUN([Tuple], +[BOOST_FIND_HEADER([boost/tuple/tuple.hpp])]) + + +# BOOST_TYPETRAITS() +# -------------------- +# Look for Boost.TypeTraits +BOOST_DEFUN([TypeTraits], +[BOOST_FIND_HEADER([boost/type_traits.hpp])]) + + +# BOOST_UTILITY() +# --------------- +# Look for Boost.Utility (noncopyable, result_of, base-from-member idiom, +# etc.) +BOOST_DEFUN([Utility], +[BOOST_FIND_HEADER([boost/utility.hpp])]) + + +# BOOST_VARIANT() +# --------------- +# Look for Boost.Variant. +BOOST_DEFUN([Variant], +[BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp]) +BOOST_FIND_HEADER([boost/variant.hpp])]) + +# BOOST_POINTERCONTAINER() +# ------------------------ +# Look for Boost.PointerContainer +BOOST_DEFUN([Pointer_Container], +[BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp]) +BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp]) +BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp]) +BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp]) +BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp]) +BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp]) +])# BOOST_POINTERCONTAINER + +# BOOST_WAVE([PREFERRED-RT-OPT]) +# ------------------------------ +# NOTE: If you intend to use Wave/Spirit with thread support, make sure you +# call BOOST_THREADS first. +# Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the +# documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Wave], +[AC_REQUIRE([BOOST_FILESYSTEM])dnl +AC_REQUIRE([BOOST_DATE_TIME])dnl +boost_wave_save_LIBS=$LIBS +boost_wave_save_LDFLAGS=$LDFLAGS +m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl +LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \ +$BOOST_THREAD_LIBS" +LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \ +$BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS" +BOOST_FIND_LIB([wave], [$1], + [boost/wave.hpp], + [boost::wave::token_id id; get_token_name(id);]) +LIBS=$boost_wave_save_LIBS +LDFLAGS=$boost_wave_save_LDFLAGS +])# BOOST_WAVE + + +# BOOST_XPRESSIVE() +# ----------------- +# Look for Boost.Xpressive (new since 1.36.0). +BOOST_DEFUN([Xpressive], +[BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])]) + + +# ----------------- # +# Internal helpers. # +# ----------------- # + + +# _BOOST_PTHREAD_FLAG() +# --------------------- +# Internal helper for BOOST_THREADS. Based on ACX_PTHREAD: +# http://autoconf-archive.cryp.to/acx_pthread.html +AC_DEFUN([_BOOST_PTHREAD_FLAG], +[AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_LANG_PUSH([C++])dnl +AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag], +[ boost_cv_pthread_flag= + # The ordering *is* (sometimes) important. Some notes on the + # individual items follow: + # (none): in case threads are in libc; should be tried before -Kthread and + # other compiler flags to prevent continual compiler warnings + # -lpthreads: AIX (must check this before -lpthread) + # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) + # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) + # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread) + # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads) + # -pthreads: Solaris/GCC + # -mthreads: MinGW32/GCC, Lynx/GCC + # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it + # doesn't hurt to check since this sometimes defines pthreads too; + # also defines -D_REENTRANT) + # ... -mt is also the pthreads flag for HP/aCC + # -lpthread: GNU Linux, etc. + # --thread-safe: KAI C++ + case $host_os in #( + *solaris*) + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #( + *) + boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \ + -pthreads -mthreads -lpthread --thread-safe -mt";; + esac + # Generate the test file. + AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0);])]) + for boost_pthread_flag in '' $boost_pthread_flags; do + boost_pthread_ok=false +dnl Re-use the test file already generated. + boost_pthreads__save_LIBS=$LIBS + LIBS="$LIBS $boost_pthread_flag" + AC_LINK_IFELSE([], + [if grep ".*$boost_pthread_flag" conftest.err; then + echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD + else + boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag + fi]) + LIBS=$boost_pthreads__save_LIBS + $boost_pthread_ok && break + done +]) +AC_LANG_POP([C++])dnl +])# _BOOST_PTHREAD_FLAG + + +# _BOOST_gcc_test(MAJOR, MINOR) +# ----------------------------- +# Internal helper for _BOOST_FIND_COMPILER_TAG. +m4_define([_BOOST_gcc_test], +["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl + + +# _BOOST_FIND_COMPILER_TAG() +# -------------------------- +# Internal. When Boost is installed without --layout=system, each library +# filename will hold a suffix that encodes the compiler used during the +# build. The Boost build system seems to call this a `tag'. +AC_DEFUN([_BOOST_FIND_COMPILER_TAG], +[AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag], +[boost_cv_lib_tag=unknown +if test x$boost_cv_inc_path != xno; then + AC_LANG_PUSH([C++])dnl + # The following tests are mostly inspired by boost/config/auto_link.hpp + # The list is sorted to most recent/common to oldest compiler (in order + # to increase the likelihood of finding the right compiler with the + # least number of compilation attempt). + # Beware that some tests are sensible to the order (for instance, we must + # look for MinGW before looking for GCC3). + # I used one compilation test per compiler with a #error to recognize + # each compiler so that it works even when cross-compiling (let me know + # if you know a better approach). + # Known missing tags (known from Boost's tools/build/v2/tools/common.jam): + # como, edg, kcc, bck, mp, sw, tru, xlc + # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines + # the same defines as GCC's). + for i in \ + _BOOST_gcc_test(4, 8) \ + _BOOST_gcc_test(4, 7) \ + _BOOST_gcc_test(4, 6) \ + _BOOST_gcc_test(4, 5) \ + _BOOST_gcc_test(4, 4) \ + _BOOST_gcc_test(4, 3) \ + _BOOST_gcc_test(4, 2) \ + _BOOST_gcc_test(4, 1) \ + _BOOST_gcc_test(4, 0) \ + "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \ + && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ + || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \ + _BOOST_gcc_test(3, 4) \ + _BOOST_gcc_test(3, 3) \ + "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \ + "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \ + _BOOST_gcc_test(3, 2) \ + "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \ + _BOOST_gcc_test(3, 1) \ + _BOOST_gcc_test(3, 0) \ + "defined __BORLANDC__ @ bcb" \ + "defined __ICC && (defined __unix || defined __unix__) @ il" \ + "defined __ICL @ iw" \ + "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \ + _BOOST_gcc_test(2, 95) \ + "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \ + "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \ + "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \ + "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8" + do + boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '` + boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'` + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if $boost_tag_test +/* OK */ +#else +# error $boost_tag_test +#endif +]])], [boost_cv_lib_tag=$boost_tag; break], []) + done +AC_LANG_POP([C++])dnl + case $boost_cv_lib_tag in #( + # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed + # to "gcc41" for instance. + *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there. + gcc*) + boost_tag_x= + case $host_os in #( + darwin*) + if test $boost_major_version -ge 136; then + # The `x' added in r46793 of Boost. + boost_tag_x=x + fi;; + esac + # We can specify multiple tags in this variable because it's used by + # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ... + boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc" + ;; #( + unknown) + AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]]) + boost_cv_lib_tag= + ;; + esac +fi])dnl end of AC_CACHE_CHECK +])# _BOOST_FIND_COMPILER_TAG + + +# _BOOST_GUESS_WHETHER_TO_USE_MT() +# -------------------------------- +# Compile a small test to try to guess whether we should favor MT (Multi +# Thread) flavors of Boost. Sets boost_guess_use_mt accordingly. +AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT], +[# Check whether we do better use `mt' even though we weren't ask to. +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if defined _REENTRANT || defined _MT || defined __MT__ +/* use -mt */ +#else +# error MT not needed +#endif +]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false]) +]) + +# _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# ------------------------------------------------------------------- +# Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile, +# will break when Autoconf changes its internals. Requires that you manually +# rm -f conftest.$ac_objext in between to really different tests, otherwise +# you will try to link a conftest.o left behind by a previous test. +# Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this +# macro). +# +# Don't use "break" in the actions, as it would short-circuit some code +# this macro runs after the actions. +m4_define([_BOOST_AC_LINK_IFELSE], +[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +rm -f conftest$ac_exeext +boost_save_ac_ext=$ac_ext +boost_use_source=: +# If we already have a .o, re-use it. We change $ac_ext so that $ac_link +# tries to link the existing object file instead of compiling from source. +test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && + _AS_ECHO_LOG([re-using the existing conftest.$ac_objext]) +AS_IF([_AC_DO_STDERR($ac_link) && { + test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_executable_p conftest$ac_exeext +dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough. + }], + [$2], + [if $boost_use_source; then + _AC_MSG_LOG_CONFTEST + fi + $3]) +ac_objext=$boost_save_ac_objext +ac_ext=$boost_save_ac_ext +dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) +dnl information created by the PGI compiler (conftest_ipa8_conftest.oo), +dnl as it would interfere with the next link command. +rm -f core conftest.err conftest_ipa8_conftest.oo \ + conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl +])# _BOOST_AC_LINK_IFELSE + +# Local Variables: +# mode: autoconf +# End: Added: trunk/m4/cxx.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/m4/cxx.m4 Fri Mar 22 10:39:56 2013 (r579) @@ -0,0 +1,43 @@ +## Produce more comprehensible error messages if possible. +## Must be called BEFORE AC_LANG(C++) or it will have no effect. +## See: http://www.bdsoft.com/tools/stlfilt.html +#AC_CEDAR_CXXFILTER() +#---------------------------------------- +AC_DEFUN([AC_CEDAR_CXXFILTER], [ + if test "x$CXX" = "x"; then + AC_PATH_PROG(GFILT, gfilt, $CXX, $PATH:$HOME/bin:$HOME/local/bin) + if test "x$GFILT" != "x"; then CXX="$GFILT -banner:N"; fi + fi +]) + + +## Try to find an "output colorizing" variant on the compiler. +## Haven't decided yet how this should interact with the normal +## AC_PROG_CXX etc. +#AC_CEDAR_CXXCOLOR() +#---------------------------------------- +AC_DEFUN([AC_CEDAR_CXXCOLOR], [ + AC_PATH_PROG(COLORCXX, $CXX-color, $CXX, $PATH:$HOME/bin:$HOME/local/bin) + CXX=$COLORCXX +]) + + +## Determine whether a compiler flag is accepted +#AC_CEDAR_CHECKCXXFLAG(flag, action-if-true, action-if-false) +AC_DEFUN([AC_CEDAR_CHECKCXXFLAG], [ + AC_LANG_PUSH(C++) + AC_MSG_CHECKING([if the $CXX compiler accepts the $1 flag]) + AC_LANG_CONFTEST([AC_LANG_PROGRAM([],[return 0;])]) + flag_ok=no + #$CXX $1 conftest.cpp >&5 2>/dev/null && flag_ok=yes + stat_string=`$CXX $1 conftest.cpp 2>&1 1>&5` ; test -z "$stat_string" && flag_ok=yes + AC_MSG_RESULT([$flag_ok]) + if test x$flag_ok = xyes; then + true + $2 + else + true + $3 + fi + AC_LANG_POP(C++) +]) Added: trunk/m4/cython.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/m4/cython.m4 Fri Mar 22 10:39:56 2013 (r579) @@ -0,0 +1,81 @@ +dnl Taken from the python bindings to the Enlightenment foundation libraries, +dnl and was part of a GPL package. I have included this file to fix the build. +dnl +dnl +dnl AM_CHECK_CYTHON([VERSION [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) +dnl Check if a Cython version is installed +dnl Defines CYTHON_VERSION and CYTHON_FOUND +AC_DEFUN([AM_CHECK_CYTHON], +[ +AC_REQUIRE([AM_PATH_PYTHON]) +ifelse([$1], [], [_msg=""], [_msg=" >= $1"]) +AC_MSG_CHECKING(for Cython$_msg) +AC_CACHE_VAL(py_cv_cython, [ + +prog="import Cython.Compiler.Version; print Cython.Compiler.Version.version" +CYTHON_VERSION=`$PYTHON -c "$prog" 2>&AC_FD_CC` + +py_cv_cython=no +if test "x$CYTHON_VERSION" != "x"; then + py_cv_cython=yes +fi + +if test "x$py_cv_cython" = "xyes"; then + ifelse([$1], [], [:], + [AS_VERSION_COMPARE([$CYTHON_VERSION], [$1], [py_cv_cython=no])]) +fi +]) + +AC_MSG_RESULT([$py_cv_cython]) + +if test "x$py_cv_cython" = "xyes"; then + CYTHON_FOUND=yes + ifelse([$2], [], [:], [$2]) +else + CYTHON_FOUND=no + ifelse([$3], [], [AC_MSG_ERROR([Could not find usable Cython$_msg])], [$3]) +fi +]) + +dnl AM_CHECK_CYTHON_PRECOMPILED(FILE-LIST [, ACTION-IF-ALL [, ACTION-IF-NOT-ALL]]) +dnl given a list of files ending in .pyx (FILE-LIST), check if their .c +dnl counterpart exists and is not older than the source. +dnl ACTION-IF-ALL is called only if no files failed the check and thus +dnl all pre-generated files are usable. +dnl ACTION-IF-NOT-ALL is called if some or all failed. If not provided, +dnl an error will be issued. +AC_DEFUN([AM_CHECK_CYTHON_PRECOMPILED], +[ +_to_check_list="$1" +_failed_list="" +_exists_list="" + +for inf in $_to_check_list; do + outf=`echo "$inf" | sed -e 's/^\(.*\)[.]pyx$/\1.c/'` + if test "$outf" = "$inf"; then + AC_MSG_WARN([File to check must end in .pyx, but got: $inf -- Skip]) + continue + fi + + AC_MSG_CHECKING([for pre-generated $outf for $inf]) + if ! test -f "$outf"; then + _res=no + _failed_list="${_failed_list} $outf" + elif ! test "$outf" -nt "$inf"; then + _res="no (older)" + _failed_list="${_failed_list} $outf" + else + _res=yes + _exists_list="${_exists_list} $outf" + fi + AC_MSG_RESULT($_res) +done + +if test -z "$_failed_list" -a -n "$_exists_list"; then + ifelse([$2], [], [:], [$2]) +else + ifelse([$3], [], + [AC_MSG_ERROR([Missing pre-generated files: $_failed_list])], + [$3]) +fi +]) Added: trunk/m4/osx.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/m4/osx.m4 Fri Mar 22 10:39:56 2013 (r579) @@ -0,0 +1,17 @@ +#AC_CEDAR_OSX() +#---------------------------------------- +AC_DEFUN([AC_CEDAR_OSX], [ + LIBPATHVARNAME="LD_LIBRARY_PATH" + AC_CHECK_TOOL(SWVERS, sw_vers) + if test x$SWVERS != x; then + PROD_NAME=$($SWVERS -productName | cut -f 2 -d:) + fi + AM_CONDITIONAL(WITH_OSX, [test "$PROD_NAME" = "Mac OS X"]) + if test "$PROD_NAME" = "Mac OS X"; then + MACOSX_DEPLOYMENT_TARGET=$($SWVERS -productVersion | cut -f 1,2 -d.) + AC_MSG_NOTICE([MACOSX_DEPLOYMENT_TARGET = $MACOSX_DEPLOYMENT_TARGET]) + AM_CXXFLAGS="$AM_CXXFLAGS -Dunix" + LIBPATHVARNAME="DYLD_LIBRARY_PATH" + fi + AC_SUBST(LIBPATHVARNAME) +]) Added: trunk/m4/pkgchecks.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/m4/pkgchecks.m4 Fri Mar 22 10:39:56 2013 (r579) @@ -0,0 +1,426 @@ +# Convert argument to an absolute path +AC_DEFUN([AC_CEDAR_ABSPATH], [ + inpath=${$1} + abspath="" + if test -d "$inpath"; then + abspath=`cd $inpath && pwd` + elif test -f "$inpath"; then + dirpart=`dirname $inpath` + localpart=`basename $inpath` + abspath="`cd $dirpart && pwd`/$localpart" + fi + if test -z "$abspath"; then + AC_MSG_ERROR(Could not make absolute path $1 from ${$1}) + fi + $1=$abspath +]) + + +# A version of AC_SUBST which ensures that paths are absolute +AC_DEFUN([AC_CEDAR_PATH_SUBST], [ + AC_CEDAR_ABSPATH($1) + AC_SUBST($1) +]) + + +# Declares an external package to be used. This macro will declare appropriate +# command line switches for ./configure and corresponding environment variables +# to define the package's prefix path, library path and include path. The +# configure command line option switches override the corresponding environment +# variables. Various permutations of capitalisation, version number appendage +# and include/lib path will be attempted. Omit the version number if it isn't +# relevant. The third and fourth options will be executed respectively if the +# package is or isn't found: this is an ideal place to place ERROR/WARNING +# messages as appropriate for mandatory/optional packages and to run tests of +# the library if it appears to be there. +# +#AC_CEDAR_LIBRARYANDHEADERS(PrettyName, ReleaseNumber, action-if-true, action-if-false) +#---------------------------------------- +AC_DEFUN([AC_CEDAR_LIBRARYANDHEADERS], [ + ## Define a bunch of case permutations + m4_define([cedar_PkgName], [$1])dnl + m4_define([cedar_PKGNAME], [translit([translit([$1], [a-z], [A-Z])], [.])])dnl + m4_define([cedar_pkgname], [translit([translit([$1], [A-Z], [a-z])], [.])])dnl + m4_define([cedar_SAFEPKGNAME], [translit(cedar_PKGNAME, [-], [_])])dnl + m4_define([cedar_safepkgname], [translit(cedar_pkgname, [-], [_])])dnl + m4_define([cedar_pkgversion], [$2])dnl + + pkgpath="" + pkglib=no; pkginc=no; pkggood=no + + ## Don't know why this isn't working by default: + test x${prefix} = xNONE && prefix=${ac_default_prefix} + + ## Environment variables for specifying paths + AC_ARG_VAR(@&t at cedar_SAFEPKGNAME@&t at PATH, + path to cedar_PkgName @<:@$prefix and various standard locations@:>@) + pkgpath=${cedar_SAFEPKGNAME@&t at PATH} + + ## "configure" option switches for specifying paths + AC_ARG_WITH([cedar_safepkgname], + [AC_HELP_STRING(--with-@&t at cedar_safepkgname, + path to cedar_PkgName @<:@$prefix and various standard locations@:>@)], + [pkgpath=$with_@&t at cedar_safepkgname], []) + dnl echo "DEBUG: withval=$withval, with_@&t at cedar_safepkgname=$with_@&t at cedar_safepkgname -> pkgpath=$pkgpath" + if test "$pkgpath"; then cedar_SAFEPKGNAME@&t at PATH="$pkgpath"; fi + + ## Has this lib been disabled? + #echo "DEBUG: pkgpath = $pkgpath" + if test x$pkgpath = xno; then + AC_MSG_NOTICE(Not building against cedar_PkgName) + AM_CONDITIONAL(WITH_@&t at cedar_SAFEPKGNAME@&t at INC, false) + AM_CONDITIONAL(WITH_@&t at cedar_SAFEPKGNAME@&t at LIB, false) + AM_CONDITIONAL(WITHOUT_@&t at cedar_SAFEPKGNAME@&t at INC, true) + AM_CONDITIONAL(WITHOUT_@&t at cedar_SAFEPKGNAME@&t at LIB, true) + $4 + else + ## Check library and header + AC_CEDAR_LIBRARY(cedar_PkgName, cedar_pkgversion, , pkglib=no) + AC_CEDAR_HEADERS(cedar_PkgName, cedar_pkgversion, , pkginc=no) + + ## Execute pass/fail shell code + if test "x$pkglib" = "xyes" && test "x$pkginc" = "xyes"; then + #AC_MSG_NOTICE([cedar_PkgName paths verified]) + pkggood="yes" + $3 + else + pkggood="no" + $4 + fi + fi + + ## Export variables to automake + have_@&t at cedar_safepkgname=no + test x$pkggood != xno && have_@&t at cedar_safepkgname=yes + AM_CONDITIONAL(WITH_@&t at cedar_SAFEPKGNAME, [test x$pkggood != xno]) + AM_CONDITIONAL(WITHOUT_@&t at cedar_SAFEPKGNAME, [test x$pkggood = xno]) +]) + + +#AC_CEDAR_HEADERS(PrettyName, ReleaseNumber, action-if-true, action-if-false) +AC_DEFUN([AC_CEDAR_HEADERS], [ + ## Define a bunch of case permutations + m4_define([cedar_PkgName], [$1])dnl + m4_define([cedar_PKGNAME], [translit([translit([$1], [a-z], [A-Z])], [.])])dnl + m4_define([cedar_pkgname], [translit([translit([$1], [A-Z], [a-z])], [.])])dnl + m4_define([cedar_SAFEPKGNAME], [translit(cedar_PKGNAME, [-], [_])])dnl + m4_define([cedar_safepkgname], [translit(cedar_pkgname, [-], [_])])dnl + m4_define([cedar_IncName], [cedar_PkgName])dnl + m4_define([cedar_INCNAME], [cedar_PKGNAME])dnl + m4_define([cedar_incname], [cedar_pkgname])dnl + m4_define([cedar_IncName1], [translit(cedar_PkgName, [-], [_])])dnl + m4_define([cedar_INCNAME1], [translit(cedar_PKGNAME, [-], [_])])dnl + m4_define([cedar_incname1], [translit(cedar_pkgname, [-], [_])])dnl + m4_define([cedar_IncName2], [translit(cedar_PkgName, [-], [])])dnl + m4_define([cedar_INCNAME2], [translit(cedar_PKGNAME, [-], [])])dnl + m4_define([cedar_incname2], [translit(cedar_pkgname, [-], [])])dnl + m4_define([cedar_pkgversion], [$2])dnl + + ## We have a set of user-set variables: + pkgpath=""; pkgincpath="" + ## Also need some status variables: + pkginc=no + + ## Don't know why this isn't working by default: + test x${prefix} = xNONE && prefix=${ac_default_prefix} + + ## Environment variables for specifying paths + AC_ARG_VAR(@&t at cedar_SAFEPKGNAME@&t at PATH, + path to cedar_PkgName @<:@$prefix and various standard locations@:>@) + AC_ARG_VAR(@&t at cedar_SAFEPKGNAME@&t at INCPATH, + path to the directory containing the cedar_PkgName header files @<:@cedar_SAFEPKGNAME@&t at PATH/include@:>@) + + ## "configure" option switches for specifying paths + pkgpath=${cedar_SAFEPKGNAME@&t at PATH} + AC_ARG_WITH(cedar_safepkgname, + AC_HELP_STRING(--with-@&t at cedar_safepkgname@&t@, + path to cedar_PkgName @<:@$prefix and various standard locations@:>@), + [pkgpath=$with_@&t at cedar_safepkgname], []) + dnl echo "DEBUG: withval=$withval, with_@&t at cedar_safepkgname=$with_@&t at cedar_safepkgname -> pkgpath=$pkgpath" + if test "$pkgpath"; then cedar_SAFEPKGNAME@&t at PATH="$pkgpath"; fi + + pkgincpath=${cedar_SAFEPKGNAME@&t at INCPATH} + AC_ARG_WITH(cedar_safepkgname@&t at -incpath, + AC_HELP_STRING(--with-@&t at cedar_safepkgname@&t at -incpath, + path to directory containing cedar_PkgName headers @<:@cedar_SAFEPKGNAME@&t at PATH/include@:>@), + [pkgincpath=$with_@&t at cedar_safepkgname@&t at _incpath], []) + + ## Has this header been disabled? + if test x$pkgpath = xno; then + AC_MSG_NOTICE(Not building against cedar_PkgName) + $4 + else + ## Base paths + pkgbases="$prefix $ac_default_prefix /usr /" + if test "$pkgpath"; then pkgbases="$pkgpath"; fi + + ## Look for include files: first build the search list... + incpaths="" + if test "$pkgincpath"; then + incpath=`echo $pkgincpath | sed -e 's://*:/:g' -e 's:/$::'` + incpaths="$incpath" + else + for base in $pkgbases; do + incpath=`echo "$base/include" | sed -e 's://*:/:g' -e 's:/$::'` + incpaths="$incpaths $incpath" + done + fi + + if test "x$CEDAR_M4_DEBUG" != "x"; then + echo "DEBUG: inc paths = $incpaths" + fi + + + ## Build package names + incnames="cedar_IncName cedar_INCNAME cedar_incname" + if test "cedar_IncName" != "cedar_IncName1"; then + incnames="$incnames cedar_IncName1 cedar_INCNAME1 cedar_incname1" + fi + if test "cedar_IncName" != "cedar_IncName2"; then + incnames="$incnames cedar_IncName2 cedar_INCNAME2 cedar_incname2" + fi + + ## .. and then do the search: + for incpath in $incpaths; do + for incname in $incnames; do + fullincpath="$incpath/$incname" + if test "x$CEDAR_M4_DEBUG" != "x"; then + echo "Testing cedar_PkgName inc path: $fullincpath" + fi + if test -d $fullincpath; then + pkginc=yes + break + else + pkginc=no; + fi + if test x$pkginc != xno; then break; fi + done + if test x$pkginc != xno; then break; fi + done + + if test x$pkginc != xno; then + cedar_SAFEPKGNAME@&t at INCPATH="$incpath" + AC_CEDAR_ABSPATH(cedar_SAFEPKGNAME@&t at INCPATH) + cedar_SAFEPKGNAME@&t at INCNAME="$incname" + cedar_SAFEPKGNAME@&t at CPPFLAGS="-I$cedar_SAFEPKGNAME@&t at INCPATH" + #echo cedar_SAFEPKGNAME@&t at INCPATH : $cedar_SAFEPKGNAME@&t at INCPATH + AC_MSG_NOTICE([Found cedar_PkgName header directory at $incpath]) + else + ## Last resort --- only tried if $pkgpath was specified + if test x$pkgpath != x; then + incpath="$pkgpath/include" + if test -d "$incpath"; then + cedar_SAFEPKGNAME@&t at INCPATH=`echo $incpath | sed -e s:'/$':'':` + AC_CEDAR_ABSPATH(cedar_SAFEPKGNAME@&t at INCPATH) + cedar_SAFEPKGNAME@&t at INCNAME="" + cedar_SAFEPKGNAME@&t at CPPFLAGS="-I$cedar_SAFEPKGNAME@&t at INCPATH" + pkginc=yes + #AC_MSG_NOTICE([Found cedar_PkgName header directory at $incpath]) + fi + else + AC_MSG_WARN(cedar_PkgName header directory was not found) + fi + fi + + ## Execute pass/fail shell code + if test "x$pkginc" = "xyes"; then + true + $3 + else + true + $4 + fi + fi + + ## Export variables to automake + AC_SUBST(cedar_SAFEPKGNAME@&t at INCPATH) + AC_SUBST(cedar_SAFEPKGNAME@&t at INCNAME) + AC_SUBST(cedar_SAFEPKGNAME@&t at CPPFLAGS) + AM_CONDITIONAL(WITH_@&t at cedar_SAFEPKGNAME@&t at INC, [test x$pkgginc != xno]) + AM_CONDITIONAL(WITHOUT_@&t at cedar_SAFEPKGNAME@&t at INC, [test x$pkgginc = xno]) +]) + + +#AC_CEDAR_LIBRARY(PrettyName, ReleaseNumber, action-if-true, action-if-false) +AC_DEFUN([AC_CEDAR_LIBRARY], [ + ## Define a bunch of case permutations + m4_define([cedar_PkgName], [$1])dnl + m4_define([cedar_PKGNAME], [translit([translit([$1], [a-z], [A-Z])], [.])])dnl + m4_define([cedar_pkgname], [translit([translit([$1], [A-Z], [a-z])], [.])])dnl + m4_define([cedar_SAFEPKGNAME], [translit(cedar_PKGNAME, [-], [_])])dnl + m4_define([cedar_safepkgname], [translit(cedar_pkgname, [-], [_])])dnl + m4_define([cedar_LibName], [cedar_PkgName])dnl + m4_define([cedar_LIBNAME], [cedar_PKGNAME])dnl + m4_define([cedar_libname], [cedar_pkgname])dnl + m4_define([cedar_LibName1], [translit(cedar_PkgName, [-], [_])])dnl + m4_define([cedar_LIBNAME1], [translit(cedar_PKGNAME, [-], [_])])dnl + m4_define([cedar_libname1], [translit(cedar_pkgname, [-], [_])])dnl + m4_define([cedar_LibName2], [translit(cedar_PkgName, [-], [])])dnl + m4_define([cedar_LIBNAME2], [translit(cedar_PKGNAME, [-], [])])dnl + m4_define([cedar_libname2], [translit(cedar_pkgname, [-], [])])dnl + m4_define([cedar_libversion], [$2])dnl + + ## We have a set of user-set variables: + pkgpath=""; pkglibpath=""; pkglibname="" + ## Also need some status variables: + pkglib=no + + ## Don't know why this isn't working by default: + test x${prefix} = xNONE && prefix=${ac_default_prefix} + + ## Environment variables for specifying paths + AC_ARG_VAR(@&t at cedar_SAFEPKGNAME@&t at PATH, + path to cedar_PkgName @<:@$prefix and various standard locations@:>@) + AC_ARG_VAR(@&t at cedar_SAFEPKGNAME@&t at LIBPATH, + path to the directory containing the cedar_PkgName library @<:@cedar_SAFEPKGNAME@&t at PATH/lib or cedar_SAFEPKGNAME@&t at PATH/lib/cedar_PkgName@:>@) + AC_ARG_VAR(@&t at cedar_SAFEPKGNAME@&t at LIBNAME, + name to be used when linking the cedar_PkgName library @<:@cedar_PkgName@:>@) + pkgpath=${cedar_SAFEPKGNAME@&t at PATH} + + ## "configure" option switches for specifying paths + AC_ARG_WITH([cedar_safepkgname], + [AC_HELP_STRING(--with-@&t at cedar_safepkgname, + path to cedar_PkgName @<:@$prefix and various standard locations@:>@)], + [pkgpath=$with_@&t at cedar_safepkgname], []) + + dnl echo "DEBUG: withval=$withval, with_@&t at cedar_safepkgname=$with_@&t at cedar_safepkgname -> pkgpath=$pkgpath" + if test "$pkgpath"; then cedar_SAFEPKGNAME@&t at PATH="$pkgpath"; fi + pkglibpath=${cedar_SAFEPKGNAME@&t at LIBPATH} + pkglibname=${cedar_SAFEPKGNAME@&t at LIBFLAG} + + AC_ARG_WITH(cedar_safepkgname@&t at -libpath, + AC_HELP_STRING(--with-@&t at cedar_safepkgname@&t at -libpath, + path to directory containing cedar_PkgName library @<:@cedar_SAFEPKGNAME@&t at PATH/lib or cedar_SAFEPKGNAME@&t at PATH/lib/cedar_PkgName@:>@), + [pkglibpath=$with_@&t at cedar_safepkgname@&t at _libpath], []) + AC_ARG_WITH(cedar_safepkgname@&t at -libname, + AC_HELP_STRING(--with-@&t at cedar_safepkgname@&t at -libname, + name to be used when linking the cedar_PkgName library @<:@cedar_PkgName@:>@), + [pkglibname=$with_@&t at cedar_safepkgname@&t at _libname], []) + + ## Has this lib been disabled? + if test x$pkgpath = xno; then + AC_MSG_NOTICE(Not building against cedar_PkgName) + $4 + else + ## Base paths + pkgbases="$prefix $ac_default_prefix /usr /" + if test "$pkgpath"; then pkgbases="$pkgpath"; fi + if test "x$CEDAR_M4_DEBUG" != "x"; then + echo "DEBUG: $pkgpath -> $pkgbases" + fi + + ## Build a list of library search locations, unless specified + libdirnames="lib" + + ## Test for 64-bit mode and add lib64 as first choice + ## library dir name if appropriate + if test -z "$UNAME"; then + AC_PATH_PROG(UNAME, [uname], [no]) + fi + if test x$UNAME != xno; then + if test -n `$UNAME -m | grep 64`; then + libdirnames="lib64 $libdirnames" + fi + fi + + libpaths="" + if test "$pkglibpath"; then + libpath=`echo $pkglibpath | sed -e 's://*:/:g' -e 's:/$::'` + libpaths="$libpath" + else + ## Outer loop over lib / lib64 part + for libdirname in $libdirnames; do + ## Inner loop over base path + for base in $pkgbases; do + libpath=`echo "$base/$libdirname" | sed -e 's://*:/:g' -e 's:/$::'` + libpaths="$libpaths $libpath" + done + done + libpaths="$libpaths ./src" + fi + + ## Use case permuatations on the package name (mixed, all-upper and + ## all-lower), plus punctuation replacements. + libnames="cedar_LibName cedar_LIBNAME cedar_libname" + if test "cedar_LibName" != "cedar_LibName1"; then + libnames="$libnames cedar_LibName1 cedar_LIBNAME1 cedar_libname1" + fi + if test "cedar_LibName" != "cedar_LibName2"; then + libnames="$libnames cedar_LibName2 cedar_LIBNAME2 cedar_libname2" + fi + if test "$pkglibname"; then libnames=$pkglibname; fi + + ## Define library versions + libversions="" + if test x"cedar_libversion" != x; then + libversions="-cedar_libversion cedar_libversion" + fi + + ## Look for library with various name permutations + for libpath in $libpaths; do + for libversion in $libversions ""; do + for libname in $libnames; do + for libextn in la so dylib dll a; do + testpath="${libpath}/lib${libname}${libversion}.${libextn}" + testpath=`echo $testpath | sed -e 's://*:/:g' -e 's:/$::'` + if test "x$CEDAR_M4_DEBUG" != "x"; then + echo "DEBUG: Testing $testpath" + fi + if test -e $testpath; then + pkglib=yes + break + else + pkglib=no + fi + done + if test x$pkglib != xno; then break; fi + done + if test x$pkglib != xno; then break; fi + done + if test x$pkglib != xno; then break; fi + done + + ## Announce success/failure and set variables + if test x$pkglib != xno; then + ## TODO: Can we just use $testpath here? + libfullpath=`echo ${libpath}/lib${libname}${libversion}.${libextn}` + libfullpath=`echo $libfullpath | sed -e 's://*:/:g' -e 's:/$::'` + AC_CEDAR_ABSPATH(libfullpath) + cedar_SAFEPKGNAME@&t at LIB="$libfullpath" + cedar_SAFEPKGNAME@&t at LIBPATH=`dirname $libfullpath` + ## TODO: Can we just use $libname here? + cedar_SAFEPKGNAME@&t at LIBNAME=`basename $libfullpath | sed -e s/'^lib'// -e s/'\.@<:@a-zA-Z@:>@*$'//` + cedar_SAFEPKGNAME@&t at LDFLAGS="-L$cedar_SAFEPKGNAME@&t at LIBPATH" + cedar_SAFEPKGNAME@&t at LDLIBS="-l$cedar_SAFEPKGNAME@&t at LIBNAME" + AC_MSG_NOTICE([Found cedar_PkgName library at ${libfullpath}]) + else + AC_MSG_WARN(cedar_PkgName library was not found) + fi + + ## Execute pass/fail shell code + if test "x$pkglib" = "xyes"; then + true + $3 + else + true + $4 + fi + fi + + ## Export variables to automake + AC_SUBST(cedar_SAFEPKGNAME@&t at LIB) + AC_SUBST(cedar_SAFEPKGNAME@&t at LIBPATH) + AC_SUBST(cedar_SAFEPKGNAME@&t at LIBNAME) + AC_SUBST(cedar_SAFEPKGNAME@&t at LDFLAGS) + AC_SUBST(cedar_SAFEPKGNAME@&t at LDLIBS) + AM_CONDITIONAL(WITH_@&t at cedar_SAFEPKGNAME@&t at LIB, [test x$pkglib != xno]) + AM_CONDITIONAL(WITHOUT_@&t at cedar_SAFEPKGNAME@&t at LIB, [test x$pkglib = xno]) +]) + + +# Create a variable called EMPTY with appropriate content +#AC_EMPTY_SUBST +AC_DEFUN([AC_EMPTY_SUBST], +[EMPTY="" +AC_SUBST(EMPTY) +]) Added: trunk/m4/python.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/m4/python.m4 Fri Mar 22 10:39:56 2013 (r579) @@ -0,0 +1,782 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/az_python.html +# =========================================================================== +# +# SYNOPSIS +# +# AZ_PYTHON_DEFAULT +# AZ_PYTHON_ENABLE +# AZ_PYTHON_WITH +# AZ_PYTHON_PATH +# AZ_PYTHON_VERSION_ENSURE( [2.2] ) +# AZ_PYTHON_CSPEC +# AZ_PYTHON_LSPEC +# +# DESCRIPTION +# +# This file provides autoconf support for those applications that want to +# embed python. It supports all pythons >= 2.2 which is the first official +# release containing distutils. Version 2.2 of python was released +# December 21, 2001. Since it actually executes the python, cross platform +# configuration will probably not work. Also, most of the platforms +# supported are consistent until you look into MacOSX. The python included +# with it is installed as a framework which is a very different +# environment to set up the normal tools such as gcc and libtool to deal +# with. Therefore, once we establish which python that we are going to +# use, we use its distutils to actually compile and link our modules or +# applications. +# +# At this time, it does NOT support linking with Python statically. It +# does support dynamic linking. +# +# This set of macros help define $PYTHON, $PYTHON_USE, $PYTHON_CSPEC and +# $PYTHON_LSPEC. $PYTHON defines the full executable path for the Python +# being linked to and is used within these macros to determine if that has +# been specified or found. These macros do execute this python version so +# it must be present on the system at configure time. +# +# $PYTHON_USE is an automake variable that defines whether Python support +# should be included or not in your application. $PYTHON_CSPEC is a +# variable that supplies additional CFLAGS for the compilation of the +# application/shared library. $PYTHON_LSPEC is a variable that supplies +# additional LDFLAGS for linking the application/shared library. +# +# The following is an example of how to set up for python usage within +# your application in your configure.in: +# +# AZ_PYTHON_DEFAULT( ) +# AZ_PYTHON_ENABLE( ) # Optional +# AZ_PYTHON_WITH( ) # Optional +# AZ_PYTHON_PATH( ) # or AZ_PYTHON_INSIST( ) +# # if $PYTHON is not defined, then the following do nothing. +# AZ_PYTHON_VERSION_ENSURE( [2.2] ) +# AZ_PYTHON_CSPEC +# AZ_PYTHON_LSPEC +# +# The AZ_PYTHON_DEFAULT sets the $PYTHON_USE to false. Thereby, excluding +# it if it was optional. +# +# The AZ_PYTHON_ENABLE looks for the optional configure parameters of +# --enable-python/--disable-python and establishes the $PYTHON and +# $PYTHON_USE variables accordingly. +# +# The AZ_PYTHON_WITH looks for the optional configure parameters of +# --with-python/--without-python and establishes the $PYTHON and +# $PYTHON_USE variables accordingly. +# +# The AZ_PYTHON_PATH looks for python assuming that none has been +# previously found or defined and issues an error if it does not find it. +# If it does find it, it establishes the $PYTHON and $PYTHON_USE variables +# accordingly. AZ_PYTHON_INSIST could be used here instead if you want to +# insist that Python support be included using the --enable-python or +# --with-python checks previously done. +# +# The AZ_PYTHON_VERSION_ENSURE issues an error if the Python previously +# found is not of version 2.2 or greater. +# +# Once that these macros have be run, we can use PYTHON_USE within the +# makefile.am file to conditionally add the Python support such as: +# +# Makefile.am example showing optional inclusion of directories: +# +# if PYTHON_USE +# plugins = plugins +# src = src +# else +# plugins = +# src = +# endif +# +# SUBDIRS = . $(plugins) $(src) +# +# Makefile.am example showing optional shared library build: +# +# if PYTHON_USE +# lib_LTLIBRARIES = libElemList.la +# libElemList_la_SOURCES = libElemList.c +# libElemList_la_CFLAGS = @PYTHON_CSPEC@ +# libElemList_la_LDFLAGS = @PYTHON_LSPEC@ +# endif +# +# Makefile.am example showing optional program build: +# +# if PYTHON_USE +# bin_PROGRAMS = runFunc +# runFunc_SOURCES = runFunc.c +# runFunc_CFLAGS = @PYTHON_CSPEC@ +# runFunc_LDFLAGS = @PYTHON_LSPEC@ +# endif +# +# The above compiles the modules only if PYTHON_USE was specified as true. +# Also, the else portion of the if was optional. +# +# LAST MODIFICATION +# +# 2008-04-12 +# +# COPYLEFT +# +# Copyright (c) 2008 Robert White <kranki at mac.com> +# Copyright (c) 2008 Dustin J. Mitchell <dustin at cs.uchicago.edu> +# +# 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. + +# AZ_PYTHON_DEFAULT( ) +# ----------------- +# Sets the default to not include Python support. + +AC_DEFUN([AZ_PYTHON_DEFAULT], +[ + az_python_use=false + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") +]) + + + +# AZ_PYTHON_ENABLE( [path] ) +# ----------------------------------------------------------------- +# Handles the various --enable-python commands. +# Input: +# $1 is the optional search path for the python executable if needed +# Ouput: +# PYTHON_USE (AM_CONDITIONAL) is true if python executable found +# and --enable-python was requested; otherwise false. +# $PYTHON contains the full executable path to python if PYTHON_ENABLE_USE +# is true. +# +# Example: +# AZ_PYTHON_ENABLE( ) +# or +# AZ_PYTHON_ENABLE( "/usr/bin" ) + +AC_DEFUN([AZ_PYTHON_ENABLE], +[ + AC_ARG_VAR([PYTHON],[Python Executable Path]) + + # unless PYTHON was supplied to us (as a precious variable), + # see if --enable-python[=PythonExecutablePath], --enable-python, + # --disable-python or --enable-python=no was given. + if test -z "$PYTHON" + then + AC_MSG_CHECKING(for --enable-python) + AC_ARG_ENABLE( + python, + AC_HELP_STRING([--enable-python@<:@=PYTHON@:>@], + [absolute path name of Python executable] + ), + [ + if test "$enableval" = "yes" + then + # "yes" was specified, but we don't have a path + # for the executable. + # So, let's searth the PATH Environment Variable. + AC_MSG_RESULT(yes) + AC_PATH_PROG( + [PYTHON], + python, + [], + $1 + ) + if test -z "$PYTHON" + then + AC_MSG_ERROR(no path to python found) + fi + az_python_use=true + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + AZ_PYTHON_PREFIX( ) + elif test "$enableval" = "no" + then + AC_MSG_RESULT(no) + az_python_use=false + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + else + # $enableval must be the executable path then. + AC_SUBST([PYTHON], ["${enableval}"]) + AC_MSG_RESULT($withval) + az_python_use=true + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + AZ_PYTHON_PREFIX( ) + fi + ], + [ + # --with-python was not specified. + AC_MSG_RESULT(no) + az_python_use=false + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + ] + ) + fi + +]) + + + +# AZ_PYTHON_CSPEC( ) +# ----------------- +# Set up the c compiler options to compile Python +# embedded programs/libraries in $PYTHON_CSPEC if +# $PYTHON has been defined. + +AC_DEFUN([AZ_PYTHON_CSPEC], +[ + AC_ARG_VAR( [PYTHON], [Python Executable Path] ) + if test -n "$PYTHON" + then + az_python_prefix=`${PYTHON} -c "import sys; print sys.prefix"` + if test -z "$az_python_prefix" + then + AC_MSG_ERROR([Python Prefix is not known]) + fi + az_python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"` + az_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"` + az_python_includespec="-I${az_python_prefix}/include/python${az_python_version}" + if test x"$python_prefix" != x"$python_execprefix"; then + az_python_execspec="-I${az_python_execprefix}/include/python${az_python_version}" + az_python_includespec="${az_python_includespec} $az_python_execspec" + fi + az_python_ccshared=`${PYTHON} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('CFLAGSFORSHARED')"` + az_python_cspec="${az_python_ccshared} ${az_python_includespec}" + AC_SUBST([PYTHON_CSPEC], [${az_python_cspec}]) + AC_MSG_NOTICE([PYTHON_CSPEC=${az_python_cspec}]) + fi +]) + + + +# AZ_PYTHON_INSIST( ) +# ----------------- +# Look for Python and set the output variable 'PYTHON' +# to 'python' if found, empty otherwise. + +AC_DEFUN([AZ_PYTHON_PATH], +[ + AC_ARG_VAR( [PYTHON], [Python Executable Path] ) + if test -z "$PYTHON" + then + AC_MSG_ERROR([Python Executable not found]) + fi +]) + + + +# AZ_PYTHON_LSPEC( ) +# ----------------- +# Set up the linker options to link Python embedded +# programs/libraries in $PYTHON_LSPEC if $PYTHON +# has been defined. + +AC_DEFUN([AZ_PYTHON_LSPEC], +[ + AC_ARG_VAR( [PYTHON], [Python Executable Path] ) + if test -n "$PYTHON" + then + AZ_PYTHON_RUN([ +import sys +import distutils.sysconfig +strUseFrameWork = "--enable-framework" +dictConfig = distutils.sysconfig.get_config_vars( ) +strConfigArgs = dictConfig.get("CONFIG_ARGS") +strLinkSpec = dictConfig.get('LDFLAGS') +if -1 == strConfigArgs.find(strUseFrameWork): + strLibPL = dictConfig.get("LIBPL") + if strLibPL and (strLibPL != ""): + strLinkSpec += " -L%s" % (strLibPL) + strSys = dictConfig.get("SYSLIBS") + if strSys and (strSys != ""): + strLinkSpec += " %s" % (strSys) + strSHL = dictConfig.get("SHLIBS") + if strSHL and (strSHL != ""): + strLinkSpec += " %s" % (strSHL) + # Construct the Python Library Name. + strTmplte = " -lpython%d.%d" + if (sys.platform == "win32") or (sys.platform == "os2emx"): + strTmplte = " -lpython%d%d" + strWrk = strTmplte % ( (sys.hexversion >> 24), + ((sys.hexversion >> 16) & 0xff)) + strLinkSpec += strWrk +else: + # This is not ideal since it changes the search path + # for Frameworks which could have side-effects on + # other included Frameworks. However, it is necessary + # where someone has installed more than one frameworked + # Python. Frameworks are really only used in MacOSX. + strLibFW = dictConfig.get("PYTHONFRAMEWORKPREFIX") + if strLibFW and (strLibFW != ""): + strLinkSpec += " -F%s" % (strLibFW) +strLinkSpec += " %s" % (dictConfig.get('LINKFORSHARED')) +print strLinkSpec + ]) + AC_SUBST([PYTHON_LSPEC], [${az_python_output}]) + AC_MSG_NOTICE([PYTHON_LSPEC=${az_python_output}]) + fi +]) + + + +# AZ_PYTHON_PATH( ) +# ----------------- +# Look for Python and set the output variable 'PYTHON' +# to 'python' if found, empty otherwise. + +AC_DEFUN([AZ_PYTHON_PATH], +[ + AC_ARG_VAR( [PYTHON], [Python Executable Path] ) + AC_PATH_PROG( PYTHON, python, [], $1 ) + if test -z "$PYTHON" + then + AC_MSG_ERROR([Python Executable not found]) + else + az_python_use=true + fi + AM_CONDITIONAL(PYTHON_USE, test "$az_python_use" = "true") +]) + + + +# AZ_PYTHON_PREFIX( ) +# ------------------- +# Use the values of $prefix and $exec_prefix for the corresponding +# values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. + +AC_DEFUN([AZ_PYTHON_PREFIX], +[ + if test -z "$PYTHON" + then + AC_MSG_ERROR([Python Executable Path is not known]) + fi + ax_python_prefix=`${PYTHON} -c "import sys; print sys.prefix"` + ax_python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"` + AC_SUBST([PYTHON_PREFIX], ["${ax_python_prefix}"]) + AC_SUBST([PYTHON_EXECPREFIX], ["${ax_python_execprefix}"]) +]) + + + +# AZ_PYTHON_RUN( PYTHON_PROGRAM ) +# ----------------- +# Run a Python Test Program saving its output +# in az_python_output and its condition code +# in az_python_cc. + +AC_DEFUN([AZ_PYTHON_RUN], +[ + AC_ARG_VAR( [PYTHON], [Python Executable Path] ) + if test -z "$PYTHON" + then + AC_MSG_ERROR([Python Executable not found]) + else + cat >conftest.py <<_ACEOF +$1 +_ACEOF + az_python_output=`$PYTHON conftest.py` + az_python_cc=$? + rm conftest.py + if test -f "conftest.pyc" + then + rm conftest.pyc + fi + fi +]) + + + +# AZ_PYTHON_VERSION_CHECK( VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE] ) +# ----------------------------------------------------------------------------- +# Run ACTION-IF-TRUE if the Python interpreter has version >= VERSION. +# Run ACTION-IF-FALSE otherwise. +# This test uses sys.hexversion instead of the string equivalant (first +# word of sys.version), in order to cope with versions such as 2.2c1. +# hexversion has been introduced in Python 1.5.2; it's probably not +# worth to support older versions (1.5.1 was released on October 31, 1998). + +AC_DEFUN([AZ_PYTHON_VERSION_CHECK], + [ + AC_ARG_VAR( [PYTHON], [Python Executable Path] ) + if test -n "$PYTHON" + then + AC_MSG_CHECKING([whether $PYTHON version >= $1]) + AZ_PYTHON_RUN([ +import sys, string +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +minver = map(int, string.split('$1', '.')) + [[0, 0, 0]] +minverhex = 0 +for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] +if sys.hexversion >= minverhex: + sys.exit( 0 ) +else: + sys.exit( 1 ) + ]) + if test $az_python_cc -eq 0 + then + $2 + m4_ifvaln( + [$3], + [else $3] + ) + fi + fi +]) + + + +# AZ_PYTHON_VERSION_ENSURE( VERSION ) +# ----------------- +# Insure that the Python Interpreter Version +# is greater than or equal to the VERSION +# parameter. + +AC_DEFUN([AZ_PYTHON_VERSION_ENSURE], +[ + AZ_PYTHON_VERSION_CHECK( + [$1], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR(too old)] + ) +]) + + + +# AZ_PYTHON_WITH( [path] ) +# ----------------------------------------------------------------- +# Handles the various --with-python commands. +# Input: +# $1 is the optional search path for the python executable if needed +# Ouput: +# PYTHON_USE (AM_CONDITIONAL) is true if python executable found +# and --with-python was requested; otherwise false. +# $PYTHON contains the full executable path to python if PYTHON_USE +# is true. +# +# Example: +# AZ_PYTHON_WITH( ) +# or +# AZ_PYTHON_WITH("/usr/bin") + +AC_DEFUN([AZ_PYTHON_WITH], +[ + AC_ARG_VAR([PYTHON],[Python Executable Path]) + + # unless PYTHON was supplied to us (as a precious variable), + # see if --with-python[=PythonExecutablePath], --with-python, + # --without-python or --with-python=no was given. + if test -z "$PYTHON" + then + AC_MSG_CHECKING(for --with-python) + AC_ARG_WITH( + python, + AC_HELP_STRING([--with-python@<:@=PYTHON@:>@], + [absolute path name of Python executable] + ), + [ + if test "$withval" = "yes" + then + # "yes" was specified, but we don't have a path + # for the executable. + # So, let's searth the PATH Environment Variable. + AC_MSG_RESULT(yes) + AC_PATH_PROG( + [PYTHON], + python, + [], + $1 + ) + if test -z "$PYTHON" + then + AC_MSG_ERROR(no path to python found) + fi + az_python_use=true + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + AZ_PYTHON_PREFIX( ) + elif test "$withval" = "no" + then + AC_MSG_RESULT(no) + az_python_use=false + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + else + # $withval must be the executable path then. + AC_SUBST([PYTHON], ["${withval}"]) + AC_MSG_RESULT($withval) + az_python_use=true + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + AZ_PYTHON_PREFIX( ) + fi + ], + [ + # --with-python was not specified. + AC_MSG_RESULT(no) + az_python_use=false + AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true") + ] + ) + fi + +]) + +# =========================================================================== +# http://autoconf-archive.cryp.to/ac_python_devel.html +# =========================================================================== +# +# SYNOPSIS +# +# AC_PYTHON_DEVEL([version]) +# +# DESCRIPTION +# +# Note: Defines as a precious variable "PYTHON_VERSION". Don't override it +# in your configure.ac. +# +# This macro checks for Python and tries to get the include path to +# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) +# output variables. It also exports $(PYTHON_EXTRA_LIBS) and +# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. +# +# You can search for some particular version of Python by passing a +# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please +# note that you *have* to pass also an operator along with the version to +# match, and pay special attention to the single quotes surrounding the +# version number. Don't use "PYTHON_VERSION" for this: that environment +# variable is declared as precious and thus reserved for the end-user. +# +# This macro should work for all versions of Python >= 2.1.0. As an end +# user, you can disable the check for the python version by setting the +# PYTHON_NOVERSIONCHECK environment variable to something else than the +# empty string. +# +# If you need to use this macro for an older Python version, please +# contact the authors. We're always open for feedback. +# +# LAST MODIFICATION +# +# 2008-04-12 +# +# COPYLEFT +# +# Copyright (c) 2008 Sebastian Huber <sebastian-huber at web.de> +# Copyright (c) 2008 Alan W. Irwin <irwin at beluga.phys.uvic.ca> +# Copyright (c) 2008 Rafael Laboissiere <rafael at laboissiere.net> +# Copyright (c) 2008 Andrew Collier <colliera at ukzn.ac.za> +# Copyright (c) 2008 Matteo Settenvini <matteo at member.fsf.org> +# Copyright (c) 2008 Horst Knorr <hk_classes at knoda.org> +# +# 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 Macro 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. + +AC_DEFUN([AC_PYTHON_DEVEL],[ + # + # Allow the use of a (user set) custom python version + # + AC_ARG_VAR([PYTHON_VERSION],[The installed Python + version to use, for example '2.3'. This string + will be appended to the Python interpreter + canonical name.]) + + AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) + if test -z "$PYTHON"; then + AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) + PYTHON_VERSION="" + fi + + # + # Check for a version of Python >= 2.1.0 + # + AC_MSG_CHECKING([for a version of Python >= '2.1.0']) + ac_supports_python_ver=`$PYTHON -c "import sys, string; \ + ver = string.split(sys.version)[[0]]; \ + print ver >= '2.1.0'"` + if test "$ac_supports_python_ver" != "True"; then + if test -z "$PYTHON_NOVERSIONCHECK"; then + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([ +This version of the AC@&t at _PYTHON_DEVEL macro +doesn't work properly with versions of Python before +2.1.0. You may need to re-run configure, setting the +variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, +PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. +Moreover, to disable this check, set PYTHON_NOVERSIONCHECK +to something else than an empty string. +]) + else + AC_MSG_RESULT([skip at user request]) + fi + else + AC_MSG_RESULT([yes]) + fi + + # + # if the macro parameter ``version'' is set, honour it + # + if test -n "$1"; then + AC_MSG_CHECKING([for a version of Python $1]) + ac_supports_python_ver=`$PYTHON -c "import sys, string; \ + ver = string.split(sys.version)[[0]]; \ + print ver $1"` + if test "$ac_supports_python_ver" = "True"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([this package requires Python $1. +If you have it installed, but it isn't the default Python +interpreter in your system path, please pass the PYTHON_VERSION +variable to configure. See ``configure --help'' for reference. +]) + PYTHON_VERSION="" + fi + fi + + # + # Check if you have distutils, else fail + # + AC_MSG_CHECKING([for the distutils Python package]) + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` + if test -z "$ac_distutils_result"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot import Python module "distutils". +Please check your Python installation. The error was: +$ac_distutils_result]) + PYTHON_VERSION="" + fi + + # + # Check for Python include path + # + AC_MSG_CHECKING([for Python include path]) + if test -z "$PYTHON_CPPFLAGS"; then + python_path=`$PYTHON -c "import distutils.sysconfig; \ + print distutils.sysconfig.get_python_inc();"` + if test -n "${python_path}"; then + python_path="-I$python_path" + fi + PYTHON_CPPFLAGS=$python_path + fi + AC_MSG_RESULT([$PYTHON_CPPFLAGS]) + AC_SUBST([PYTHON_CPPFLAGS]) + + # + # Check for Python library path + # + AC_MSG_CHECKING([for Python library path]) + if test -z "$PYTHON_LDFLAGS"; then + # (makes two attempts to ensure we've got a version number + # from the interpreter) + py_version=`$PYTHON -c "from distutils.sysconfig import *; \ + from string import join; \ + print join(get_config_vars('VERSION'))"` + if test "$py_version" == "[None]"; then + if test -n "$PYTHON_VERSION"; then + py_version=$PYTHON_VERSION + else + py_version=`$PYTHON -c "import sys; \ + print sys.version[[:3]]"` + fi + fi + + PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ + from string import join; \ + print '-L' + get_python_lib(0,1), \ + '-lpython';"`$py_version + fi + AC_MSG_RESULT([$PYTHON_LDFLAGS]) + AC_SUBST([PYTHON_LDFLAGS]) + + # + # Check for site packages + # + AC_MSG_CHECKING([for Python site-packages path]) + if test -z "$PYTHON_SITE_PKG"; then + PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ + print distutils.sysconfig.get_python_lib(0,0);"` + fi + AC_MSG_RESULT([$PYTHON_SITE_PKG]) + AC_SUBST([PYTHON_SITE_PKG]) + + # + # libraries which must be linked in when embedding + # + AC_MSG_CHECKING(python extra libraries) + if test -z "$PYTHON_EXTRA_LIBS"; then + PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ + conf = distutils.sysconfig.get_config_var; \ + print conf('LOCALMODLIBS'), conf('LIBS')"` + fi + AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) + AC_SUBST(PYTHON_EXTRA_LIBS) + + # + # linking flags needed when embedding + # + AC_MSG_CHECKING(python extra linking flags) + if test -z "$PYTHON_EXTRA_LDFLAGS"; then + PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ + conf = distutils.sysconfig.get_config_var; \ + print conf('LINKFORSHARED')"` + fi + AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) + AC_SUBST(PYTHON_EXTRA_LDFLAGS) + + # + # final check to see if everything compiles alright + # + AC_MSG_CHECKING([consistency of all components of python development environment]) + AC_LANG_PUSH([C]) + # save current global flags + LIBS="$ac_save_LIBS $PYTHON_LDFLAGS" + CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" + AC_TRY_LINK([ + #include <Python.h> + ],[ + Py_Initialize(); + ],[pythonexists=yes],[pythonexists=no]) + + AC_MSG_RESULT([$pythonexists]) + + if test ! "$pythonexists" = "yes"; then + AC_MSG_ERROR([ + Could not link test program to Python. Maybe the main Python library has been + installed in some non-standard library path. If so, pass it to configure, + via the LDFLAGS environment variable. + Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" + ============================================================================ + ERROR! + You probably have to install the development version of the Python package + for your distribution. The exact name of this package varies among them. + ============================================================================ + ]) + PYTHON_VERSION="" + fi + AC_LANG_POP + # turn back to default flags + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" + + # + # all done! + # +])
More information about the yoda-svn mailing list |