| 234 | | # SWIG_PYTHON([use-shadow-classes = {no, yes}]) |
| 235 | | # |
| 236 | | # Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), |
| 237 | | # and $(SWIG_PYTHON_OPT) output variables. |
| 238 | | # |
| 239 | | # $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate |
| 240 | | # code for Python. Shadow classes are enabled unless the value of the |
| 241 | | # optional first argument is exactly 'no'. If you need multi module |
| 242 | | # support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use |
| 243 | | # $(SWIG_PYTHON_LIBS) to link against the appropriate library. It |
| 244 | | # contains the SWIG Python runtime library that is needed by the type |
| 245 | | # check system for example. |
| 246 | | AC_DEFUN([SWIG_PYTHON],[ |
| 247 | | AC_REQUIRE([AC_PROG_SWIG]) |
| 248 | | AC_REQUIRE([AC_PYTHON_DEVEL]) |
| 249 | | test "x$1" != "xno" || swig_shadow=" -noproxy" |
| 250 | | AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow]) |
| 251 | | AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) |
| 252 | | ]) |
| 253 | | |
| 254 | | AC_DEFUN([AC_PYTHON_DEVEL],[ |
| 255 | | # |
| 256 | | # should allow for checking of python version here... |
| 257 | | # |
| 258 | | AC_REQUIRE([AM_PATH_PYTHON]) |
| 259 | | |
| 260 | | # Check for Python include path |
| 261 | | AC_MSG_CHECKING([for Python include path]) |
| 262 | | python_path=`echo $PYTHON | sed "s,/bin.*$,,"` |
| 263 | | for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do |
| 264 | | python_path=`find $i -type f -name Python.h -print | sed "1q"` |
| 265 | | if test -n "$python_path" ; then |
| 266 | | break |
| 267 | | fi |
| 268 | | done |
| 269 | | python_path=`echo $python_path | sed "s,/Python.h$,,"` |
| 270 | | AC_MSG_RESULT([$python_path]) |
| 271 | | if test -z "$python_path" ; then |
| 272 | | AC_MSG_ERROR([cannot find Python include path]) |
| 273 | | fi |
| 274 | | AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path]) |
| 275 | | |
| 276 | | # Check for Python library path |
| 277 | | AC_MSG_CHECKING([for Python library path]) |
| 278 | | python_path=`echo $PYTHON | sed "s,/bin.*$,,"` |
| 279 | | 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 |
| 280 | | python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"` |
| 281 | | if test -n "$python_path" ; then |
| 282 | | break |
| 283 | | fi |
| 284 | | done |
| 285 | | python_path=`echo $python_path | sed "s,/libpython.*$,,"` |
| 286 | | AC_MSG_RESULT([$python_path]) |
| 287 | | if test -z "$python_path" ; then |
| 288 | | AC_MSG_ERROR([cannot find Python library path]) |
| 289 | | fi |
| 290 | | AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"]) |
| 291 | | # |
| 292 | | python_site=`echo $python_path | sed "s/config/site-packages/"` |
| 293 | | AC_SUBST([PYTHON_SITE_PKG],[$python_site]) |
| 294 | | # |
| 295 | | # libraries which must be linked in when embedding |
| 296 | | # |
| 297 | | AC_MSG_CHECKING(python extra libraries) |
| 298 | | PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ |
| 299 | | conf = distutils.sysconfig.get_config_var; \ |
| 300 | | print conf('LOCALMODLIBS')+' '+conf('LIBS')" |
| 301 | | AC_MSG_RESULT($PYTHON_EXTRA_LIBS)` |
| 302 | | AC_SUBST(PYTHON_EXTRA_LIBS) |
| 303 | | ]) |
| 304 | | |