Commit e7a63ff2 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Update autoconf macros for boost::python and python

parent d7a3c85d
# ===========================================================================
# http://autoconf-archive.cryp.to/ax_boost_python.html
# http://www.gnu.org/software/autoconf-archive/ax_boost_python.html
# ===========================================================================
#
# SYNOPSIS
......@@ -9,7 +9,7 @@
# DESCRIPTION
#
# This macro checks to see if the Boost.Python library is installed. It
# also attempts to guess the currect library name using several attempts.
# also attempts to guess the correct library name using several attempts.
# It tries to build the library name using a user supplied name or suffix
# and then just the raw library.
#
......@@ -18,16 +18,14 @@
#
# This macro calls AC_SUBST(BOOST_PYTHON_LIB).
#
# In order to ensure that the Python headers are specified on the include
# path, this macro requires AX_PYTHON to be called.
# In order to ensure that the Python headers and the Boost libraries are
# specified on the include path, this macro requires AX_PYTHON_DEVEL and
# AX_BOOST_BASE to be called.
#
# LAST MODIFICATION
#
# 2008-04-12
#
# COPYLEFT
# LICENSE
#
# Copyright (c) 2008 Michael Tindal
# Copyright (c) 2013 Daniel Mullner <muellner@math.stanford.edu>
#
# 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
......@@ -51,48 +49,42 @@
# 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.
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 18
AC_DEFUN([AX_BOOST_PYTHON],
[ dnl AC_REQUIRE([AX_PYTHON])dnl
[AC_REQUIRE([AX_PYTHON_DEVEL])dnl
AC_CACHE_CHECK(whether the Boost::Python library is available,
ac_cv_boost_python,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
CPPFLAGS_SAVE=$CPPFLAGS
if test "x$PYTHON_INCLUDE_DIR" != "x"; then
CPPFLAGS="-I$PYTHON_INCLUDE_DIR $CPPFLAGS"
CPPFLAGS_SAVE="$CPPFLAGS"
if test x$PYTHON_CPPFLAGS != x; then
CPPFLAGS="$PYTHON_CPPFLAGS $CPPFLAGS"
fi
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <boost/python/module.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }]],
[[return 0;]]),
ac_cv_boost_python=yes, ac_cv_boost_python=no)
[[return 0;]])],
ac_cv_boost_python=yes, ac_cv_boost_python=no)
AC_LANG_RESTORE
CPPFLAGS="$CPPFLAGS_SAVE"
])
if test "$ac_cv_boost_python" = "yes"; then
AC_DEFINE(HAVE_BOOST_PYTHON,,[define if the Boost::Python library is available])
ax_python_lib=boost_python
AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify the boost python library or suffix to use]),
AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify yes/no or the boost python library or suffix to use]),
[if test "x$with_boost_python" != "xno"; then
ax_python_lib=$with_boost_python
ax_boost_python_lib=boost_python-$with_boost_python
fi])
pyver=`$PYTHON -c "import sys; ver = sys.version.split()[[0]].split('.'); print(''.join(ver[[:2]]))"`
for ax_lib in $ax_python_lib $ax_boost_python_lib boost_python boost_python-mt; do
AC_CHECK_LIB($ax_lib, exit, [BOOST_PYTHON_LIB=$ax_lib break])
ax_lib_alt=${ax_lib}-py$PYTHON_VERSION
AC_CHECK_LIB($ax_lib_alt, exit, [BOOST_PYTHON_LIB=$ax_lib_alt break])
ax_lib_alt=${ax_lib}-$PYTHON_VERSION
AC_CHECK_LIB($ax_lib_alt, exit, [BOOST_PYTHON_LIB=$ax_lib_alt break])
ax_lib_alt=${ax_lib}-py$pyver
AC_CHECK_LIB($ax_lib_alt, exit, [BOOST_PYTHON_LIB=$ax_lib_alt break])
ax_lib_alt=${ax_lib}-$pyver
AC_CHECK_LIB($ax_lib_alt, exit, [BOOST_PYTHON_LIB=$ax_lib_alt break])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
for ax_lib in `ls $BOOSTLIBDIR/libboost_python*.so* $BOOSTLIBDIR/libboost_python*.dylib* $BOOSTLIBDIR/libboost_python*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_python.*\)\.so.*$;\1;' -e 's;^lib\(boost_python.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_python.*\)\.a.*$;\1;' ` $ax_python_lib $ax_boost_python_lib boost_python; do
AC_CHECK_LIB($ax_lib, exit, [BOOST_PYTHON_LIB=$ax_lib break], , [$PYTHON_LDFLAGS])
done
AC_SUBST(BOOST_PYTHON_LIB)
fi
......
......@@ -34,11 +34,12 @@
# LICENSE
#
# Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
# Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
# Copyright (c) 2009 Alan W. Irwin
# Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
# Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za>
# Copyright (c) 2009 Andrew Collier
# Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
# Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
# Copyright (c) 2013 Daniel Mullner <muellner@math.stanford.edu>
#
# 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
......@@ -66,7 +67,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 8
#serial 17
AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
AC_DEFUN([AX_PYTHON_DEVEL],[
......@@ -153,8 +154,14 @@ $ac_distutils_result])
if test -z "$PYTHON_CPPFLAGS"; then
python_path=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_python_inc ());"`
plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
if test -n "${python_path}"; then
python_path="-I$python_path"
if test "${plat_python_path}" != "${python_path}"; then
python_path="-I$python_path -I$plat_python_path"
else
python_path="-I$python_path"
fi
fi
PYTHON_CPPFLAGS=$python_path
fi
......@@ -173,11 +180,9 @@ $ac_distutils_result])
# join all versioning strings, on some systems
# major/minor numbers could be in different list elements
from distutils.sysconfig import *
ret = ''
for e in get_config_vars ('VERSION'):
if (e != None):
ret += e
print (ret)
e = get_config_var('VERSION')
if e is not None:
print(e)
EOD`
if test -z "$ac_python_version"; then
......@@ -198,33 +203,27 @@ EOD`
# There should be only one
import distutils.sysconfig
for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
if e != None:
print (e)
break
e = distutils.sysconfig.get_config_var('LIBDIR')
if e is not None:
print (e)
EOD`
# Before checking for libpythonX.Y, we need to know
# the extension the OS we're on uses for libraries
# (we take the first one, if there's more than one fix me!):
ac_python_soext=`$PYTHON -c \
"import distutils.sysconfig; \
print (distutils.sysconfig.get_config_vars('SO')[[0]])"`
# Now, for the library:
ac_python_soname=`$PYTHON -c \
"import distutils.sysconfig; \
print (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"`
ac_python_library=`cat<<EOD | $PYTHON -
# Strip away extension from the end to canonicalize its name:
ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"`
import distutils.sysconfig
c = distutils.sysconfig.get_config_vars()
if 'LDVERSION' in c:
print ('python'+c[['LDVERSION']])
else:
print ('python'+c[['VERSION']])
EOD`
# This small piece shamelessly adapted from PostgreSQL python macro;
# credits goes to momjian, I think. I'd like to put the right name
# in the credits, if someone can point me in the right direction... ?
#
if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
-a x"$ac_python_library" != x"$ac_python_soname"
if test -n "$ac_python_libdir" -a -n "$ac_python_library"
then
# use the official shared library
ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
......@@ -266,7 +265,7 @@ EOD`
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'))"`
print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
fi
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
AC_SUBST(PYTHON_EXTRA_LIBS)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment