[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AM_PATH_PYTHON and Python C interface headers
From: |
Paul F. Kunz |
Subject: |
Re: AM_PATH_PYTHON and Python C interface headers |
Date: |
Thu, 20 Feb 2003 14:58:40 -0800 |
>>>>> On Thu, 20 Feb 2003 23:46:53 +0100, =?iso-8859-1?q?Rapha=EBl?= Poss
>>>>> <address@hidden> said:
> This is a feature request.
> I have been writing several SWIG interfaces for a while, and I
> suffer with Autoconf/Automake when looking for the correct include
> path to find Python C interface headers. Could something be done
> about this ?
Write an M4 macro. Here's a primative one below.
---
dnl @synopsis PFK_PYTHON_PATH
dnl
dnl PFK_PYTHON_PATH adds configure command line option
dnl
dnl -with-python-include
dnl
dnl to set the output variable PY_INCLUDE to the path of the Python.h
dnl file. If the option is not given, then attempts to run the python
dnl intepreter to find path to the binary and the version number in order
dnl to construct the path. For example, if python is /usr/bin/python and
dnl version 1.5, then PY_INCLUDE is set to /usr/include/python1.5
dnl
dnl @author Paul F. Kunz <address@hidden>
dnl @version $Id: pfk_python_include.m4,v 1.4 2002/12/18 23:23:34 pfkeb Exp $
dnl
AC_DEFUN(PFK_PYTHON_PATH,[
AC_MSG_CHECKING("Python include path" )
AC_ARG_WITH(python-include,
[ --with-python-include=PATH path to where Python.h lives
(default: /usr/local/include/pythonN.M],
PY_INCLUDE=$withval )
if test -z "$PY_INCLUDE" ; then
AC_PATH_PROG(PY_INCLUDE, python)
pfk_py_include_path=`echo $PY_INCLUDE | sed -e "s/bin/include/"`
pfk_py_lib_path=`echo $PY_INCLUDE | sed -e "s/bin/lib/"`
pfk_py_version="`python -c "import sys; print sys.version[[0:3]]"`";
PY_INCLUDE="$pfk_py_include_path$pfk_py_version"
PY_LIB="$pfk_py_lib_path$pfk_py_version"
fi
AC_MSG_RESULT($PY_INCLUDE)
AC_MSG_RESULT($PY_LIB)
AC_SUBST(PY_INCLUDE)dnl
AC_SUBST( PY_LIB)dnl
])