1
dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
dnl pandora-build: A pedantic build system
6
dnl Copyright (C) 2009 Sun Microsystems, Inc.
7
dnl Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
8
dnl Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
9
dnl Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
10
dnl Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
11
dnl Copyright (c) 2008 Matteo Settenvini <matteo@member.fsf.org>
12
dnl Copyright (c) 2008 Horst Knorr <hk_classes@knoda.org>
14
dnl This program is free software: you can redistribute it and/or modify it
15
dnl under the terms of the GNU General Public License as published by the
16
dnl Free Software Foundation, either version 3 of the License, or (at your
17
dnl option) any later version.
19
dnl This program is distributed in the hope that it will be useful, but
20
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
21
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
22
dnl Public License for more details.
24
dnl You should have received a copy of the GNU General Public License along
25
dnl with this program. If not, see <http://www.gnu.org/licenses/>.
27
dnl As a special exception, the respective Autoconf Macro's copyright owner
28
dnl gives unlimited permission to copy, distribute and modify the configure
29
dnl scripts that are the output of Autoconf when processing the Macro. You
30
dnl need not follow the terms of the GNU General Public License when using
31
dnl or distributing such scripts, even though portions of the text of the
32
dnl Macro appear in them. The GNU General Public License (GPL) does govern
33
dnl all other use of the material that constitutes the Autoconf Macro.
35
dnl This special exception to the GPL applies to versions of the Autoconf
36
dnl Macro released by the Autoconf Macro Archive. When you make and
37
dnl distribute a modified version of the Autoconf Macro, you may extend this
38
dnl special exception to the GPL to apply to your modified version as well.
42
dnl PANDORA_PYTHON3_DEVEL([version])
46
dnl Note: Defines as a precious variable "PYTHON3_VERSION". Don't override it
47
dnl in your configure.ac.
49
dnl This macro checks for Python and tries to get the include path to
50
dnl 'Python.h'. It provides the $(PYTHON3_CPPFLAGS) and $(PYTHON3_LDFLAGS)
51
dnl output variables. It also exports $(PYTHON3_EXTRA_LIBS) and
52
dnl $(PYTHON3_EXTRA_LDFLAGS) for embedding Python in your code.
54
dnl You can search for some particular version of Python by passing a
55
dnl parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please
56
dnl note that you *have* to pass also an operator along with the version to
57
dnl match, and pay special attention to the single quotes surrounding the
58
dnl version number. Don't use "PYTHON3_VERSION" for this: that environment
59
dnl variable is declared as precious and thus reserved for the end-user.
65
AC_DEFUN([PANDORA_PYTHON3_DEVEL],[
67
# Allow the use of a (user set) custom python version
69
AC_ARG_VAR([PYTHON3_VERSION],[The installed Python
70
version to use, for example '3.0'. This string
71
will be appended to the Python interpreter
75
AS_IF([test -z "$PYTHON3"],[
76
AC_PATH_PROG([PYTHON3],[python[$PYTHON3_VERSION]])
78
AS_IF([test -z "$PYTHON3"],[
79
AC_MSG_ERROR([Cannot find python$PYTHON3_VERSION in your system path])
84
# if the macro parameter ``version'' is set, honour it
87
AC_MSG_CHECKING([for a version of Python $1])
88
ac_supports_python3_ver=`$PYTHON3 -c "import sys, string; \
89
ver = string.split(sys.version)[[0]]; \
91
if test "$ac_supports_python3_ver" = "True"; then
95
AC_MSG_ERROR([this package requires Python $1.
96
If you have it installed, but it isn't the default Python
97
interpreter in your system path, please pass the PYTHON3_VERSION
98
variable to configure. See ``configure --help'' for reference.
105
# Check if you have distutils, else fail
107
AC_MSG_CHECKING([for Python3 distutils package])
108
ac_python3_distutils_result=`$PYTHON3 -c "import distutils" 2>&1`
109
if test -z "$ac_python3_distutils_result"; then
113
AC_MSG_ERROR([cannot import Python3 module "distutils".
114
Please check your Python3 installation. The error was:
115
$ac_python3_distutils_result])
120
# Check for Python include path
122
AC_MSG_CHECKING([for Python3 include path])
123
if test -z "$PYTHON3_CPPFLAGS"; then
124
python3_path=`$PYTHON3 -c "import distutils.sysconfig; \
125
print(distutils.sysconfig.get_python_inc());"`
126
if test -n "${python3_path}"; then
127
python3_path="-I$python3_path"
129
PYTHON3_CPPFLAGS=$python3_path
131
AC_MSG_RESULT([$PYTHON3_CPPFLAGS])
132
AC_SUBST([PYTHON3_CPPFLAGS])
135
# Check for Python library path
137
AC_MSG_CHECKING([for Python3 library path])
138
if test -z "$PYTHON3_LDFLAGS"; then
139
# (makes two attempts to ensure we've got a version number
140
# from the interpreter)
141
py3_version=`$PYTHON3 -c "from distutils.sysconfig import *; \
142
print(' '.join(get_config_vars('VERSION')))"`
143
if test "$py3_version" == "[None]"; then
144
if test -n "$PYTHON3_VERSION"; then
145
py3_version=$PYTHON3_VERSION
147
py3_version=`$PYTHON3 -c "import sys; \
148
print(sys.version[[:3]])"`
152
PYTHON3_LDFLAGS=`$PYTHON3 -c "from distutils.sysconfig import *; \
153
print('-L' + get_python_lib(0,1), \
154
'-lpython');"`$py3_version
156
AC_MSG_RESULT([$PYTHON3_LDFLAGS])
157
AC_SUBST([PYTHON3_LDFLAGS])
160
# Check for site packages
162
AC_MSG_CHECKING([for Python3 site-packages path])
163
if test -z "$PYTHON3_SITE_PKG"; then
164
PYTHON3_SITE_PKG=`$PYTHON3 -c "import distutils.sysconfig; \
165
print(distutils.sysconfig.get_python_lib(0,0));"`
167
AC_MSG_RESULT([$PYTHON3_SITE_PKG])
168
AC_SUBST([PYTHON3_SITE_PKG])
171
# libraries which must be linked in when embedding
173
AC_MSG_CHECKING(for Python3 embedding libraries)
174
if test -z "$PYTHON3_EMBED_LIBS"; then
175
PYTHON3_EMBED_LIBS=`$PYTHON3 -c "import distutils.sysconfig; \
176
conf = distutils.sysconfig.get_config_var; \
177
print(conf('LOCALMODLIBS'), conf('LIBS'))"`
179
AC_MSG_RESULT([$PYTHON3_EMBED_LIBS])
180
AC_SUBST(PYTHON3_EMBED_LIBS)
183
# linking flags needed when embedding
185
AC_MSG_CHECKING(for Python3 embedding linking flags)
186
if test -z "$PYTHON3_EMBED_LDFLAGS"; then
187
PYTHON3_EMBED_LDFLAGS=`$PYTHON3 -c "import distutils.sysconfig; \
188
conf = distutils.sysconfig.get_config_var; \
189
print(conf('LINKFORSHARED'))"`
191
AC_MSG_RESULT([$PYTHON3_EMBED_LDFLAGS])
192
AC_SUBST(PYTHON3_EMBED_LDFLAGS)
195
# final check to see if everything compiles alright
197
AC_MSG_CHECKING([for Python3 development environment consistency])
199
# save current global flags
201
ac_save_CPPFLAGS="$CPPFLAGS"
202
LIBS="$ac_save_LIBS $PYTHON3_LDFLAGS"
203
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON3_CPPFLAGS"
208
],[python3exists=yes],[python3exists=no])
210
AC_MSG_RESULT([$python3exists])
212
if test ! "$python3exists" = "yes"; then
214
Could not link test program to Python3.
215
Maybe the main Python3 library has been installed in some non-standard
216
library path. If so, pass it to configure, via the LDFLAGS environment
218
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python3/lib"
219
============================================================================
221
You probably have to install the development version of the Python3 package
222
for your distribution. The exact name of this package varies among them.
223
============================================================================
228
# turn back to default flags
229
CPPFLAGS="$ac_save_CPPFLAGS"