use the VERSION instead of master in the revno.h generated from a src tarball
[gnash.git] / macros / python.m4
blobfb91018dd129efc7420f9923b7efbcce14f974a8
1 dnl  
2 dnl    Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
3 dnl  
4 dnl  This program is free software; you can redistribute it and/or modify
5 dnl  it under the terms of the GNU General Public License as published by
6 dnl  the Free Software Foundation; either version 3 of the License, or
7 dnl  (at your option) any later version.
8 dnl  
9 dnl  This program is distributed in the hope that it will be useful,
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl  GNU General Public License for more details.
13 dnl  You should have received a copy of the GNU General Public License
14 dnl  along with this program; if not, write to the Free Software
15 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 AC_DEFUN([GNASH_PATH_PYTHON],
21   dnl Look for the header
22   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})
23     AC_CACHE_VAL(ac_cv_path_python_incl,[
24     if test x"${with_python_incl}" != x ; then
25       if test -f ${with_python_incl}/python/python.h ; then
26               ac_cv_path_python_incl="`(cd ${with_python_incl}; pwd)`"
27       else
28               AC_MSG_ERROR([${with_python_incl} directory doesn't contain python/python.h])
29       fi
30     fi
31   ])
33   if test x"${python}" = x"yes"; then
34     # Look for the python-config script
35     pythonconfig=""
36     AC_PATH_PROG(pythonconfig, python-config, ,[${pathlist}])
38     dnl If the path hasn't been specified, go look for it.
39     if test x"${ac_cv_path_python_incl}" = x; then
40       if test x"${pythonconfig}" != "x"; then
41         ac_cv_path_python_incl="`${pythonconfig} --include`"
42       else
43         for i in $incllist; do
44           if test -f $i/pythonrun.h; then
45             ac_cv_path_python_incl="-I$i"
46                   break
47           fi
48         done
49       fi
51       if test x"${ac_cv_path_python_incl}" = x ; then
52         AC_CHECK_HEADERS(pythonrun.h)
53       fi
55       AC_MSG_CHECKING([for libpython header])
56       if test x"${ac_cv_path_python_incl}" != x ; then
57         AC_MSG_RESULT(yes)
58       else
59         AC_MSG_RESULT(no)
60       fi
61     fi
64     if test x"${ac_cv_path_python_incl}" != x"/usr/include"; then
65       ac_cv_path_python_incl="${ac_cv_path_python_incl}"
66     else
67       ac_cv_path_python_incl=""
68     fi
70     dnl Look for the library
71     AC_ARG_WITH(python_lib, AC_HELP_STRING([--with-python-lib], [directory where python library is]), with_python_lib=${withval})
72       AC_CACHE_VAL(ac_cv_path_python_lib,[
73       if test x"${with_python_lib}" != x ; then # {
74         if test -f ${with_python_lib}/libpython.a -o -f ${with_python_lib}/libpython.${shlibext}; then # {
75           ac_cv_path_python_lib="-L`(cd ${with_python_lib}; pwd)`"
76         else # }{
77           AC_MSG_ERROR([${with_python_lib} directory doesn't contain libpython.])
78         fi # }
79       fi # }
80     ])
82     dnl If the path hasn't been specified, go look for it.
83     if test x"${ac_cv_path_python_lib}" = x; then # {
84       if test x"${pythonconfig}" != "x" -a x"${darwin}" = xno; then # {
85         dnl python-config gives us way to many libraries, which create nasty linking
86         dnl dependancy issue, so we strip them off here. The real dependencies are
87         dnl are taken care of by other config tests.
88         ac_cv_path_python_lib=`${pythonconfig} --libs`
89       else # }{
90         AC_MSG_CHECKING([for libpython library])
91         for i in $libslist; do # {
92           if test -f $i/libpython.a -o -f $i/libpython.${shlibext}; then # {
93             if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then # {
94               ac_cv_path_python_lib="-L$i -lpython"
95               AC_MSG_RESULT(${ac_cv_path_python_lib})
96               break
97             else # }{
98               ac_cv_path_python_lib="-lpython2.5"
99               AC_MSG_RESULT(yes)
100               break
101             fi # }
102           fi # }
103         done # }
104         if test x"${ac_cv_path_python_lib}" = x; then # {
105           AC_MSG_RESULT(no)
106         fi # }
107       fi # }
108     fi # }
110     if test x"${ac_cv_path_python_incl}" != x ; then
111       PYTHON_CFLAGS="${ac_cv_path_python_incl}"
112     else
113       PYTHON_CFLAGS=""
114     fi
116     if test x"${ac_cv_path_python_lib}" != x ; then
117       PYTHON_LIBS="${ac_cv_path_python_lib}"
118     else
119       PYTHON_LIBS=""
120     fi
122     if test -n "$PYTHON_LIBS"; then
123       AC_DEFINE(HAS_PYTHON, [1], [Define this if you want to enable python usage])
124       has_python=yes
125     else
126       has_python=no
127     fi
129     AM_PATH_PYTHON
130     AC_PATH_PROG(PYGOBJECT_CODEGEN, pygobject-codegen-2.0, no)
131     if test x"${PYGOBJECT_CODEGEN}" = xno; then
132       AC_MSG_WARN(could not find pygobject-codegen-2.0 script)
133       AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no)
134       if test x"${PYGTK_CODEGEN}" = xno; then
135         AC_MSG_ERROR(could not find pygtk-codegen-2.0 script)
136        fi
137      fi
139     PKG_CHECK_MODULES(PYGTK, pygtk-2.0)
141     PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
142   fi
144   AC_SUBST(PYGOBJECT_CODEGEN)
145   AC_SUBST(PYGTK_CODEGEN)
146   AC_SUBST(PYGTK_DEFSDIR)
147   AC_SUBST(PYTHON_CFLAGS)  
148   AC_SUBST(PYTHON_LIBS)
151 # Local Variables:
152 # c-basic-offset: 2
153 # tab-width: 2
154 # indent-tabs-mode: nil
155 # End: