1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_boost_python.html
3 # ===========================================================================
11 # This macro checks to see if the Boost.Python library is installed. It
12 # also attempts to guess the currect library name using several attempts.
13 # It tries to build the library name using a user supplied name or suffix
14 # and then just the raw library.
16 # If the library is found, HAVE_BOOST_PYTHON is defined and
17 # BOOST_PYTHON_LIB is set to the name of the library.
19 # This macro calls AC_SUBST(BOOST_PYTHON_LIB).
21 # In order to ensure that the Python headers are specified on the include
22 # path, this macro requires AX_PYTHON to be called.
30 # Copyright (c) 2008 Michael Tindal
32 # This program is free software; you can redistribute it and/or modify it
33 # under the terms of the GNU General Public License as published by the
34 # Free Software Foundation; either version 2 of the License, or (at your
35 # option) any later version.
37 # This program is distributed in the hope that it will be useful, but
38 # WITHOUT ANY WARRANTY; without even the implied warranty of
39 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
40 # Public License for more details.
42 # You should have received a copy of the GNU General Public License along
43 # with this program. If not, see <http://www.gnu.org/licenses/>.
45 # As a special exception, the respective Autoconf Macro's copyright owner
46 # gives unlimited permission to copy, distribute and modify the configure
47 # scripts that are the output of Autoconf when processing the Macro. You
48 # need not follow the terms of the GNU General Public License when using
49 # or distributing such scripts, even though portions of the text of the
50 # Macro appear in them. The GNU General Public License (GPL) does govern
51 # all other use of the material that constitutes the Autoconf Macro.
53 # This special exception to the GPL applies to versions of the Autoconf
54 # Macro released by the Autoconf Macro Archive. When you make and
55 # distribute a modified version of the Autoconf Macro, you may extend this
56 # special exception to the GPL to apply to your modified version as well.
58 AC_DEFUN([AX_BOOST_PYTHON],
59 [AC_REQUIRE([AX_PYTHON])dnl
60 AC_CACHE_CHECK(whether the Boost::Python library is available,
64 CPPFLAGS_SAVE=$CPPFLAGS
65 if test x$PYTHON_INCLUDE_DIR != x; then
66 CPPFLAGS=-I$PYTHON_INCLUDE_DIR $CPPFLAGS
68 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
69 #include <boost/python/module.hpp>
70 using namespace boost::python;
71 BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }]],
73 ac_cv_boost_python=yes, ac_cv_boost_python=no)
75 CPPFLAGS=$CPPFLAGS_SAVE
77 if test "$ac_cv_boost_python" = "yes"; then
79 AC_DEFINE(HAVE_BOOST_PYTHON,,[define if the Boost::Python library is available])
80 ax_python_lib=boost_python
81 AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify the boost python library or suffix to use]),
82 [if test "x$with_boost_python" != "xno"; then
83 ax_python_lib=$with_boost_python
84 ax_boost_python_lib=boost_python-$with_boost_python
86 for ax_lib in $ax_python_lib $ax_boost_python_lib boost_python; do
87 AC_CHECK_LIB($ax_lib, exit, [BOOST_PYTHON_LIB=$ax_lib break])
89 AC_SUBST(BOOST_PYTHON_LIB)