1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
@node ax_python_embed
@unnumberedsec ax_python_embed
@majorheading Synopsis
@smallexample
AX_PYTHON_DEFAULT
AX_PYTHON_ENABLE
AX_PYTHON_WITH
AX_PYTHON_PATH
AX_PYTHON_VERSION_ENSURE( [2.2] )
AX_PYTHON_CSPEC
AX_PYTHON_LSPEC
@end smallexample
@majorheading 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 Mac OS X. 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:
@smallexample
AX_PYTHON_DEFAULT( )
AX_PYTHON_ENABLE( ) # Optional
AX_PYTHON_WITH( ) # Optional
AX_PYTHON_PATH( ) # or AX_PYTHON_INSIST( )
# if $PYTHON is not defined, then the following do nothing.
AX_PYTHON_VERSION_ENSURE( [2.2] )
AX_PYTHON_CSPEC
AX_PYTHON_LSPEC
@end smallexample
The AX_PYTHON_DEFAULT sets the $PYTHON_USE to false. Thereby, excluding
it if it was optional.
The AX_PYTHON_ENABLE looks for the optional configure parameters of
--enable-python/--disable-python and establishes the $PYTHON and
$PYTHON_USE variables accordingly.
The AX_PYTHON_WITH looks for the optional configure parameters of
--with-python/--without-python and establishes the $PYTHON and
$PYTHON_USE variables accordingly.
The AX_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. AX_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 AX_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:
@smallexample
if PYTHON_USE
plugins = plugins
src = src
else
plugins =
src =
endif
@end smallexample
@smallexample
SUBDIRS = . $(plugins) $(src)
@end smallexample
Makefile.am example showing optional shared library build:
@smallexample
if PYTHON_USE
lib_LTLIBRARIES = libElemList.la
libElemList_la_SOURCES = libElemList.c
libElemList_la_CFLAGS = @@PYTHON_CSPEC@@
libElemList_la_LDFLAGS = @@PYTHON_LSPEC@@
endif
@end smallexample
Makefile.am example showing optional program build:
@smallexample
if PYTHON_USE
bin_PROGRAMS = runFunc
runFunc_SOURCES = runFunc.c
runFunc_CFLAGS = @@PYTHON_CSPEC@@
runFunc_LDFLAGS = @@PYTHON_LSPEC@@
endif
@end smallexample
The above compiles the modules only if PYTHON_USE was specified as true.
Also, the else portion of the if was optional.
@majorheading Source Code
Download the
@uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_python_embed.m4,latest
version of @file{ax_python_embed.m4}} or browse
@uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=m4/ax_python_embed.m4,the
macro's revision history}.
@majorheading License
@w{Copyright @copyright{} 2008 Robert White @email{kranki@@mac.com}} @* @w{Copyright @copyright{} 2008 Dustin J. Mitchell @email{dustin@@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. This file is offered as-is, without any
warranty.
|