2 dnl Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 dnl 2011 Free Software Foundation, Inc.
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 AC_DEFUN([GNASH_PATH_PYTHON],
22 dnl Look for the header
23 AC_ARG_WITH(python_incl, AC_HELP_STRING([--with-python-incl], [directory where libpython header is (w/out the python/ prefix)]), with_python_incl=${withval})
24 AC_CACHE_VAL(ac_cv_path_python_incl,[
25 if test x"${with_python_incl}" != x ; then
26 if test -f ${with_python_incl}/python/python.h ; then
27 ac_cv_path_python_incl="`(cd ${with_python_incl}; pwd)`"
29 AC_MSG_ERROR([${with_python_incl} directory doesn't contain python/python.h])
34 if test x"${python}" = x"yes"; then
35 # Look for the python-config script
37 AC_PATH_PROG(pythonconfig, python-config, ,[${pathlist}])
38 if test x"${pythonconfig}" = x; then
39 AC_MSG_CHECKING([for versioned python-config])
40 for i in `echo ${pathlist} | sed 's|:| |g' 2>/dev/null`; do
41 pythonconfig="`ls ${i}/python2.*-config 2>/dev/null | head -1`"
42 if test x"${pythonconfig}" != x; then
46 if test x"${pythonconfig}" != x; then
47 AC_MSG_RESULT([${pythonconfig}])
54 dnl If the path hasn't been specified, go look for it.
55 if test x"${ac_cv_path_python_incl}" = x; then
56 if test x"${pythonconfig}" != "x"; then
57 ac_cv_path_python_incl="`${pythonconfig} --include`"
59 for i in $incllist; do
60 for j in `ls -dr $i/python2.* 2>/dev/null`;do
61 if test -f $j/pythonrun.h; then
62 ac_cv_path_python_incl="-I$j"
69 if test x"${ac_cv_path_python_incl}" = x ; then
70 AC_CHECK_HEADERS(pythonrun.h)
73 AC_MSG_CHECKING([for libpython header])
74 if test x"${ac_cv_path_python_incl}" != x ; then
82 if test x"${ac_cv_path_python_incl}" != x"/usr/include"; then
83 ac_cv_path_python_incl="${ac_cv_path_python_incl}"
85 ac_cv_path_python_incl=""
88 dnl Look for the library
89 AC_ARG_WITH(python_lib, AC_HELP_STRING([--with-python-lib], [directory where python library is]), with_python_lib=${withval})
90 AC_CACHE_VAL(ac_cv_path_python_lib,[
91 if test x"${with_python_lib}" != x ; then # {
92 if test -f ${with_python_lib}/libpython.a -o -f ${with_python_lib}/libpython.${shlibext}; then # {
93 ac_cv_path_python_lib="-L`(cd ${with_python_lib}; pwd)`"
95 AC_MSG_ERROR([${with_python_lib} directory doesn't contain libpython.])
100 dnl If the path hasn't been specified, go look for it.
101 if test x"${ac_cv_path_python_lib}" = x; then # {
102 if test x"${pythonconfig}" != "x" -a x"${darwin}" = xno; then # {
103 dnl python-config gives us way to many libraries, which create nasty linking
104 dnl dependancy issue, so we strip them off here. The real dependencies are
105 dnl are taken care of by other config tests.
106 ac_cv_path_python_lib=`${pythonconfig} --libs`
108 AC_MSG_CHECKING([for libpython library])
109 for i in $libslist; do # {
110 if test -f $i/libpython.a -o -f $i/libpython.${shlibext}; then # {
111 if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then # {
112 ac_cv_path_python_lib="-L$i -lpython"
113 AC_MSG_RESULT(${ac_cv_path_python_lib})
116 ac_cv_path_python_lib="-lpython2.5"
122 if test x"${ac_cv_path_python_lib}" = x; then # {
128 if test x"${ac_cv_path_python_incl}" != x ; then
129 PYTHON_CFLAGS="${ac_cv_path_python_incl}"
134 if test x"${ac_cv_path_python_lib}" != x ; then
135 PYTHON_LIBS="${ac_cv_path_python_lib}"
140 if test -n "$PYTHON_LIBS"; then
141 AC_DEFINE(HAS_PYTHON, [1], [Define this if you want to enable python usage])
148 AC_PATH_PROG(PYGOBJECT_CODEGEN, pygobject-codegen-2.0, no)
149 if test x"${PYGOBJECT_CODEGEN}" = xno; then
150 AC_MSG_WARN(could not find pygobject-codegen-2.0 script)
151 AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no)
152 if test x"${PYGTK_CODEGEN}" = xno; then
153 AC_MSG_ERROR(could not find pygtk-codegen-2.0 script)
157 PKG_CHECK_MODULES(PYGTK, pygtk-2.0)
159 PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
162 AC_SUBST(PYGOBJECT_CODEGEN)
163 AC_SUBST(PYGTK_CODEGEN)
164 AC_SUBST(PYGTK_DEFSDIR)
165 AC_SUBST(PYTHON_CFLAGS)
166 AC_SUBST(PYTHON_LIBS)
172 # indent-tabs-mode: nil