source: m4/ac_python_devel.m4 @ 8835f5a

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 8835f5a was 47de0aa, checked in by Daniel Lawson <dlawson@…>, 15 years ago
  • Cosmetic changes to trace_help() output
  • inclusion of some m4 handlers to deal with swig and python, lifted from http://autoconf-archive.cryp.to/. These are GPLd, which needs to be taken into account if libtrace licensing changes!
  • updated the swig bindings for python. Mostly api compliant now. Still possibly a memory leak to do with displaying ip addresses - I haven't touched this particular part of the code yet.
  • Property mode set to 100644
File size: 7.3 KB
Line 
1dnl @synopsis AC_PYTHON_DEVEL([version])
2dnl
3dnl Note: Defines as a precious variable "PYTHON_VERSION". Don't
4dnl override it in your configure.ac.
5dnl
6dnl This macro checks for Python and tries to get the include path to
7dnl 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and
8dnl $(PYTHON_LDFLAGS) output variables. It also exports
9dnl $(PYTHON_EXTRA_LIBS) and $(PYTHON_EXTRA_LDFLAGS) for embedding
10dnl Python in your code.
11dnl
12dnl You can search for some particular version of Python by passing a
13dnl parameter to this macro, for example ">= '2.3.1'", or "== '2.4'".
14dnl Please note that you *have* to pass also an operator along with the
15dnl version to match, and pay special attention to the single quotes
16dnl surrounding the version number. Don't use "PYTHON_VERSION" for
17dnl this: that environment variable is declared as precious and thus
18dnl reserved for the end-user.
19dnl
20dnl This macro should work for all versions of Python >= 2.1.0. As an
21dnl end user, you can disable the check for the python version by
22dnl setting the PYTHON_NOVERSIONCHECK environment variable to something
23dnl else than the empty string.
24dnl
25dnl If you need to use this macro for an older Python version, please
26dnl contact the authors. We're always open for feedback.
27dnl
28dnl @category InstalledPackages
29dnl @author Sebastian Huber <sebastian-huber@web.de>
30dnl @author Alan W. Irwin <irwin@beluga.phys.uvic.ca>
31dnl @author Rafael Laboissiere <laboissiere@psy.mpg.de>
32dnl @author Andrew Collier <colliera@nu.ac.za>
33dnl @author Matteo Settenvini <matteo@member.fsf.org>
34dnl @author Horst Knorr <hk_classes@knoda.org>
35dnl @version 2006-05-27
36dnl @license GPLWithACException
37
38AC_DEFUN([AC_PYTHON_DEVEL],[
39        #
40        # Allow the use of a (user set) custom python version
41        #
42        AC_ARG_VAR([PYTHON_VERSION],[The installed Python
43                version to use, for example '2.3'. This string
44                will be appended to the Python interpreter
45                canonical name.])
46
47        AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
48        if test -z "$PYTHON"; then
49           AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
50           PYTHON_VERSION=""
51        fi
52
53        #
54        # Check for a version of Python >= 2.1.0
55        #
56        AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
57        ac_supports_python_ver=`$PYTHON -c "import sys, string; \
58                ver = string.split(sys.version)[[0]]; \
59                print ver >= '2.1.0'"`
60        if test "$ac_supports_python_ver" != "True"; then
61                if test -z "$PYTHON_NOVERSIONCHECK"; then
62                        AC_MSG_RESULT([no])
63                        AC_MSG_FAILURE([
64This version of the AC@&t@_PYTHON_DEVEL macro
65doesn't work properly with versions of Python before
662.1.0. You may need to re-run configure, setting the
67variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
68PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
69Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
70to something else than an empty string.
71])
72                else
73                        AC_MSG_RESULT([skip at user request])
74                fi
75        else
76                AC_MSG_RESULT([yes])
77        fi
78
79        #
80        # if the macro parameter ``version'' is set, honour it
81        #
82        if test -n "$1"; then
83                AC_MSG_CHECKING([for a version of Python $1])
84                ac_supports_python_ver=`$PYTHON -c "import sys, string; \
85                        ver = string.split(sys.version)[[0]]; \
86                        print ver $1"`
87                if test "$ac_supports_python_ver" = "True"; then
88                   AC_MSG_RESULT([yes])
89                else
90                        AC_MSG_RESULT([no])
91                        AC_MSG_ERROR([this package requires Python $1.
92If you have it installed, but it isn't the default Python
93interpreter in your system path, please pass the PYTHON_VERSION
94variable to configure. See ``configure --help'' for reference.
95])
96                        PYTHON_VERSION=""
97                fi
98        fi
99
100        #
101        # Check if you have distutils, else fail
102        #
103        AC_MSG_CHECKING([for the distutils Python package])
104        ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
105        if test -z "$ac_distutils_result"; then
106                AC_MSG_RESULT([yes])
107        else
108                AC_MSG_RESULT([no])
109                AC_MSG_ERROR([cannot import Python module "distutils".
110Please check your Python installation. The error was:
111$ac_distutils_result])
112                PYTHON_VERSION=""
113        fi
114
115        #
116        # Check for Python include path
117        #
118        AC_MSG_CHECKING([for Python include path])
119        if test -z "$PYTHON_CPPFLAGS"; then
120                python_path=`$PYTHON -c "import distutils.sysconfig; \
121                        print distutils.sysconfig.get_python_inc();"`
122                if test -n "${python_path}"; then
123                        python_path="-I$python_path"
124                fi
125                PYTHON_CPPFLAGS=$python_path
126        fi
127        AC_MSG_RESULT([$PYTHON_CPPFLAGS])
128        AC_SUBST([PYTHON_CPPFLAGS])
129
130        #
131        # Check for Python library path
132        #
133        AC_MSG_CHECKING([for Python library path])
134        if test -z "$PYTHON_LDFLAGS"; then
135                # (makes two attempts to ensure we've got a version number
136                # from the interpreter)
137                py_version=`$PYTHON -c "from distutils.sysconfig import *; \
138                        from string import join; \
139                        print join(get_config_vars('VERSION'))"`
140                if test "$py_version" == "[None]"; then
141                        if test -n "$PYTHON_VERSION"; then
142                                py_version=$PYTHON_VERSION
143                        else
144                                py_version=`$PYTHON -c "import sys; \
145                                        print sys.version[[:3]]"`
146                        fi
147                fi
148
149                PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
150                        from string import join; \
151                        print '-L' + get_python_lib(0,1), \
152                        '-lpython';"`$py_version
153        fi
154        AC_MSG_RESULT([$PYTHON_LDFLAGS])
155        AC_SUBST([PYTHON_LDFLAGS])
156
157        #
158        # Check for site packages
159        #
160        AC_MSG_CHECKING([for Python site-packages path])
161        if test -z "$PYTHON_SITE_PKG"; then
162                PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
163                        print distutils.sysconfig.get_python_lib(0,0);"`
164        fi
165        AC_MSG_RESULT([$PYTHON_SITE_PKG])
166        AC_SUBST([PYTHON_SITE_PKG])
167
168        #
169        # libraries which must be linked in when embedding
170        #
171        AC_MSG_CHECKING(python extra libraries)
172        if test -z "$PYTHON_EXTRA_LIBS"; then
173           PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
174                conf = distutils.sysconfig.get_config_var; \
175                print conf('LOCALMODLIBS'), conf('LIBS')"`
176        fi
177        AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
178        AC_SUBST(PYTHON_EXTRA_LIBS)
179
180        #
181        # linking flags needed when embedding
182        #
183        AC_MSG_CHECKING(python extra linking flags)
184        if test -z "$PYTHON_EXTRA_LDFLAGS"; then
185                PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
186                        conf = distutils.sysconfig.get_config_var; \
187                        print conf('LINKFORSHARED')"`
188        fi
189        AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
190        AC_SUBST(PYTHON_EXTRA_LDFLAGS)
191
192        #
193        # final check to see if everything compiles alright
194        #
195        AC_MSG_CHECKING([consistency of all components of python development environment])
196        AC_LANG_PUSH([C])
197        # save current global flags
198        LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
199        CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
200        AC_TRY_LINK([
201                #include <Python.h>
202        ],[
203                Py_Initialize();
204        ],[pythonexists=yes],[pythonexists=no])
205
206        AC_MSG_RESULT([$pythonexists])
207
208        if test ! "$pythonexists" = "yes"; then
209           AC_MSG_ERROR([
210  Could not link test program to Python. Maybe the main Python library has been
211  installed in some non-standard library path. If so, pass it to configure,
212  via the LDFLAGS environment variable.
213  Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
214  ============================================================================
215   ERROR!
216   You probably have to install the development version of the Python package
217   for your distribution.  The exact name of this package varies among them.
218  ============================================================================
219           ])
220          PYTHON_VERSION=""
221        fi
222        AC_LANG_POP
223        # turn back to default flags
224        CPPFLAGS="$ac_save_CPPFLAGS"
225        LIBS="$ac_save_LIBS"
226
227        #
228        # all done!
229        #
230])
Note: See TracBrowser for help on using the repository browser.