1 # original version contributed by Sebastian Huber
3 # this version by Mark Asbach
4 # Institute of Communications Engineering
5 # RWTH Aachen University
8 # SWIG_PROG([required-version = N[.N[.N]]])
10 # Checks for the SWIG program. If found you can (and should) call
11 # SWIG via $(SWIG). You can use the optional first argument to check
12 # if the version of the available SWIG is greater than or equal to the
13 # value of the argument. It should have the format: N[.N[.N]] (N is a
14 # number between 0 and 999. Only the first N is mandatory.)
16 AC_DEFUN([SWIG_PROG],[
17 AC_DIAGNOSE([obsolete],[Please replace calls to SWIG_PROG by AC_PATH_SWIG])
22 # AC_PATH_SWIG([required-version = N[.N[.N]]])
24 # Checks for the SWIG program. If found you can (and should) call
25 # SWIG via $(SWIG). You can use the optional first argument to check
26 # if the version of the available SWIG is greater than or equal to the
27 # value of the argument. It should have the format: N[.N[.N]] (N is a
28 # number between 0 and 999. Only the first N is mandatory.)
30 AC_DEFUN([AC_PATH_SWIG],[
32 # define SWIG as precious variable
33 AC_ARG_VAR([SWIG],[Simplified Wrapper and Interface Generator, used for Python bindings])
35 # check where to find the swig executable
36 AC_PATH_PROG([SWIG],[swig])
37 if test -n "$SWIG"; then
39 # inquire version number
40 if test -n "$SWIG"; then
41 AC_MSG_CHECKING([for SWIG version])
42 dnl command is m4 quoted, otherwise, the sed command line breaks on some platforms
43 [SWIG_VERSION=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed -e 's/^[^0-9]*//g' -e 's/ .*//g'`]
44 AC_MSG_RESULT([$SWIG_VERSION])
49 # if a user requested a given number, check for that now
51 if test -n "$SWIG_VERSION"; then
53 # compare version strings
54 AC_VERSION_AT_LEAST([$SWIG_VERSION],[$1])
55 if test x"$ac_version_at_least" = "xyes"; then
56 # everything is perfect
59 # version requirement not fulfilled
60 # we could stop with an error, but instead we just pretend
61 # that there is no swig installed
62 AC_MSG_WARN([SWIG version $1 is required, you have $SWIG_VERSION])
66 # there was no version number available from swig
67 # and because the user has given requirements, we take
68 # this for a version mismatch
69 AC_MSG_WARN([SWIG version $1 is required, you have $SWIG_VERSION])
73 # there was no version number available from swig
74 # but because no requirement was given, just warn and go on
75 AC_MSG_WARN([cannot determine SWIG version])
79 # just in case someone wants to link swig libraries,
80 # we try to determine their path
81 if test -n "$SWIG" ; then
82 SWIG_RUNTIME_LIBS_DIR="${SWIG%/bin*}/lib"
83 AC_MSG_NOTICE([SWIG runtime library directory is '$SWIG_RUNTIME_LIBS_DIR'])
86 # AC_SUBST([SWIG]) -- already done by AC_PATH_PROG([SWIG],[swig])
87 AC_SUBST([SWIG_VERSION])
88 AC_SUBST([SWIG_RUNTIME_LIBS_DIR])
94 # Enable SWIG C++ support. This effects all invocations of $(SWIG).
95 AC_DEFUN([SWIG_ENABLE_CXX],[
96 AC_REQUIRE([AC_PATH_SWIG])
97 AC_REQUIRE([AC_PROG_CXX])
98 if test -z "$SWIG" ; then
99 AC_MSG_ERROR([swig not found])
105 # SWIG_MULTI_MODULE_SUPPORT()
107 # Enable support for multiple modules. This effects all invocations
108 # of $(SWIG). You have to link all generated modules against the
109 # appropriate SWIG runtime library. If you want to build Python
110 # modules for example, use the SWIG_PYTHON() macro and link the
111 # modules against $(SWIG_PYTHON_LIBS).
112 AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
113 AC_REQUIRE([AC_PATH_SWIG])
114 AC_MSG_CHECKING([for swig multi module support])
116 if test -n "$SWIG_VERSION"; then
118 AC_VERSION_AT_LEAST([$SWIG_VERSION],[1.3.24])
119 if test x"$ac_version_at_least" = "xyes"; then
121 AC_MSG_RESULT([[always working (SWIG >= 1.3.24)]])
124 # there were some older versions that need special treatment
125 # in form of additional command line flags and/or library
127 AC_VERSION_AT_LEAST([$SWIG_VERSION],[1.3.20])
128 if test x"$ac_version_at_least" = "xyes"; then
129 SWIG="$SWIG -noruntime"
130 AC_MSG_RESULT([[interim syntax (SWIG >= 1.3.20 < 1.3.24)]])
133 AC_MSG_RESULT([[old syntax (SWIG < 1.3.20)]])
137 AC_MSG_ERROR([SWIG version number unknown - cannot set flags for multi module support])
139 # AC_SUBST([SWIG]) -- already done by AC_PATH_SWIG()
143 # SWIG_PYTHON([use-shadow-classes = {no, yes}])
145 # Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS),
146 # $(SWIG_PYTHON_LIBS) and $(SWIG_PYTHON_OPT) output variables.
147 # $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
148 # code for Python. Shadow classes are enabled unless the value of the
149 # optional first argument is exactly 'no'. If you need multi module
150 # support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use
151 # $(SWIG_PYTHON_LIBS) to link against the appropriate library. It
152 # contains the SWIG Python runtime library that is needed by the type
153 # check system for example.
155 AC_DEFUN([SWIG_PYTHON],[
156 AC_REQUIRE([AC_PATH_SWIG])
157 AC_REQUIRE([AM_PATH_PYTHON])
159 test "x$1" != "xno" || swig_shadow=" -noproxy"
161 if test -n "$SWIG_VERSION"; then
162 AC_VERSION_AT_LEAST([$SWIG_VERSION],[1.3.24])
163 if test x"$ac_version_at_least" = "xyes"; then
166 SWIG_PYTHON_LIBS="-L$SWIG_RUNTIME_LIBS_DIR -lswigpy"
169 AC_MSG_ERROR([SWIG version number unknown - cannot set python libs])
172 AC_SUBST([SWIG_PYTHON_OPT], "-python$swig_shadow")
173 AC_SUBST([SWIG_PYTHON_LIBS])
178 # Checks for Python and tries to get the include path to 'Python.h'.
179 # It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output variable.
180 AC_DEFUN([PYTHON_DEVEL],[
181 AC_REQUIRE([AM_PATH_PYTHON])[]dnl
183 # Check for Python include path
184 AC_MSG_CHECKING([for Python include path])
185 python_path=${PYTHON%/bin*}
186 for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
187 python_path=`find $i -type f -name Python.h -print`
188 if test -n "$python_path" ; then
192 for i in $python_path ; do
193 python_path=${python_path%/Python.h}
196 AC_MSG_RESULT([$python_path])
197 if test -z "$python_path" ; then
198 AC_MSG_ERROR([cannot find Python include path])
200 AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
202 # Check for Python library path
203 AC_MSG_CHECKING([for Python library path])
204 python_path=${PYTHON%/bin*}
205 for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do
206 python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print`
207 if test -n "$python_path" ; then
211 for i in $python_path ; do
212 python_path=${python_path%/libpython*}
215 AC_MSG_RESULT([$python_path])
216 if test -z "$python_path" ; then
217 AC_MSG_ERROR([cannot find Python library path])
219 AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])