1 dnl Check if the C compiler accepts a certain C flag, and if so adds it to
3 AC_DEFUN(DIA_CHECK_CFLAG, [
4 AC_MSG_CHECKING(if C compiler accepts $1)
7 AC_TRY_COMPILE([#include <stdio.h>], [printf("hello");],
8 [AC_MSG_RESULT(yes)],dnl
10 CFLAGS="$save_CFLAGS"])
13 ## ------------------------
14 ## Python file handling
16 ## Updated by James Henstridge
17 ## ------------------------
19 # AM_PATH_PYTHON([MINIMUM-VERSION])
21 # Adds support for distributing Python modules and packages. To
22 # install modules, copy them to $(pythondir), using the python_PYTHON
23 # automake variable. To install a package with the same name as the
24 # automake package, install to $(pkgpythondir), or use the
25 # pkgpython_PYTHON automake variable.
27 # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
28 # locations to install python extension modules (shared libraries).
29 # Another macro is required to find the appropriate flags to compile
32 # If your package is configured with a different prefix to python,
33 # users will have to add the install directory to the PYTHONPATH
34 # environment variable, or create a .pth file (see the python
35 # documentation for details).
37 # If the MINIUMUM-VERSION argument is passed, AM_PATH_PYTHON will
38 # cause an error if the version of python installed on the system
39 # doesn't meet the requirement. MINIMUM-VERSION should consist of
40 # numbers and dots only.
43 AC_DEFUN([AM_PATH_PYTHON],
45 dnl Find a version of Python. I could check for python versions 1.4
46 dnl or earlier, but the default installation locations changed from
47 dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
48 dnl in 1.5, and I don't want to maintain that logic.
50 if test -z "$PYTHON"; then
51 AC_PATH_PROGS(PYTHON, python python2.1 python2.0 python1.6 python1.5)
54 dnl should we do the version check?
56 AC_MSG_CHECKING(if Python version >= $1)
57 changequote(<<, >>)dnl
61 pyver = string.split(sys.version)[0] # first word is version string
62 # split strings by '.' and convert to numeric
63 minver = map(string.atoi, string.split(minver, '.'))
64 if hasattr(sys, 'version_info'):
65 pyver = sys.version_info[:3]
67 pyver = map(string.atoi, string.split(pyver, '.'))
68 # we can now do comparisons on the two lists:
74 if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
82 AC_MSG_CHECKING([local Python configuration])
84 dnl Query Python for its version number. Getting [:3] seems to be
85 dnl the best way to do this; it's what "site.py" does in the standard
86 dnl library. Need to change quote character because of [:3]
88 AC_SUBST(PYTHON_VERSION)
89 changequote(<<, >>)dnl
90 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
94 dnl Use the values of $prefix and $exec_prefix for the corresponding
95 dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
96 dnl distinct variables so they can be overridden if need be. However,
97 dnl general consensus is that you shouldn't need this ability.
99 AC_SUBST(PYTHON_PREFIX)
100 PYTHON_PREFIX='${prefix}'
102 AC_SUBST(PYTHON_EXEC_PREFIX)
103 PYTHON_EXEC_PREFIX='${exec_prefix}'
105 dnl At times (like when building shared libraries) you may want
106 dnl to know which OS platform Python thinks this is.
108 AC_SUBST(PYTHON_PLATFORM)
109 PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
112 dnl Set up 4 directories:
114 dnl pythondir -- where to install python scripts. This is the
115 dnl site-packages directory, not the python standard library
116 dnl directory like in previous automake betas. This behaviour
117 dnl is more consistent with lispdir.m4 for example.
119 dnl Also, if the package prefix isn't the same as python's prefix,
120 dnl then the old $(pythondir) was pretty useless.
123 pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
125 dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
126 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
127 dnl more consistent with the rest of automake.
128 dnl Maybe this should be put in python.am?
130 AC_SUBST(pkgpythondir)
131 pkgpythondir=\${pythondir}/$PACKAGE
133 dnl pyexecdir -- directory for installing python extension modules
134 dnl (shared libraries) Was PYTHON_SITE_EXEC in previous betas.
137 pyexecdir=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
139 dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
140 dnl Maybe this should be put in python.am?
142 AC_SUBST(pkgpyexecdir)
143 pkgpyexecdir=\${pyexecdir}/$PACKAGE
145 AC_MSG_RESULT([looks good])
148 dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
149 dnl Check if a module containing a given symbol is visible to python.
150 AC_DEFUN(AM_CHECK_PYMOD,
151 [AC_REQUIRE([AM_PATH_PYTHON])
152 py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
153 AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
154 AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
155 ifelse([$2],[], [prog="
163 sys.exit(0)"], [prog="
166 if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
168 eval "py_cv_mod_$py_mod_var=yes"
170 eval "py_cv_mod_$py_mod_var=no"
173 py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
174 if test "x$py_val" != xno; then
176 ifelse([$3], [],, [$3
180 ifelse([$4], [],, [$4
185 dnl a macro to check for ability to create python extensions
186 dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
187 dnl function also defines PYTHON_INCLUDES
188 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
189 [AC_REQUIRE([AM_PATH_PYTHON])
190 AC_MSG_CHECKING(for headers required to compile python extensions)
191 dnl deduce PYTHON_INCLUDES
192 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
193 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
194 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
195 if test "$py_prefix" != "$py_exec_prefix"; then
196 PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
198 AC_SUBST(PYTHON_INCLUDES)
199 dnl check if the headers exist:
200 save_CPPFLAGS="$CPPFLAGS"
201 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
202 AC_TRY_CPP([#include <Python.h>],dnl
203 [AC_MSG_RESULT(found)
205 [AC_MSG_RESULT(not found)
207 CPPFLAGS="$save_CPPFLAGS"
210 AC_DEFUN([AM_CHECK_PYTHON_LIB],
211 [AC_REQUIRE([AM_PATH_PYTHON])
212 AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])
214 AC_MSG_CHECKING(for libpython${PYTHON_VERSION}.a)
216 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
218 py_makefile="${py_exec_prefix}/lib/python${PYTHON_VERSION}/config/Makefile"
219 if test -f "$py_makefile"; then
220 dnl extra required libs
221 py_localmodlibs=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $py_makefile`
222 py_basemodlibs=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $py_makefile`
223 py_other_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $py_makefile`
225 dnl now the actual libpython
226 if test -e "${py_exec_prefix}/lib/python${PYTHON_VERSION}/config/libpython${PYTHON_VERSION}.a"; then
227 PYTHON_LIBS="-L${py_exec_prefix}/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION} $py_localmodlibs $py_basemodlibs $py_other_libs"
230 AC_MSG_RESULT(not found)
233 AC_MSG_RESULT(not found)
235 AC_SUBST(PYTHON_LIBS)])
237 # We need this because freetype is optional
238 # Configure paths for FreeType2
239 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
241 dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
242 dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
244 AC_DEFUN(AC_CHECK_FT2,
246 dnl Get the cflags and libraries from the freetype-config script
248 AC_ARG_WITH(ft-prefix,
249 [ --with-ft-prefix=PREFIX
250 Prefix where FreeType is installed (optional)],
251 ft_config_prefix="$withval", ft_config_prefix="")
252 AC_ARG_WITH(ft-exec-prefix,
253 [ --with-ft-exec-prefix=PREFIX
254 Exec prefix where FreeType is installed (optional)],
255 ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
256 AC_ARG_ENABLE(freetypetest,
257 [ --disable-freetypetest Do not try to compile and run
258 a test FreeType program],
259 [], enable_fttest=yes)
261 if test x$ft_config_exec_prefix != x ; then
262 ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
263 if test x${FT2_CONFIG+set} != xset ; then
264 FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
267 if test x$ft_config_prefix != x ; then
268 ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
269 if test x${FT2_CONFIG+set} != xset ; then
270 FT2_CONFIG=$ft_config_prefix/bin/freetype-config
273 AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
275 min_ft_version=ifelse([$1], ,6.1.0,$1)
276 AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
278 if test "$FT2_CONFIG" = "no" ; then
281 FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
282 FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
283 ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
284 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
285 ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
286 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
287 ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
288 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
289 ft_min_major_version=`echo $min_ft_version | \
290 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
291 ft_min_minor_version=`echo $min_ft_version | \
292 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
293 ft_min_micro_version=`echo $min_ft_version | \
294 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
295 if test x$enable_fttest = xyes ; then
297 if test $ft_config_major_version -lt $ft_min_major_version ; then
300 if test $ft_config_major_version -eq $ft_min_major_version ; then
301 if test $ft_config_minor_version -lt $ft_min_minor_version ; then
304 if test $ft_config_minor_version -eq $ft_min_minor_version ; then
305 if test $ft_config_micro_version -lt $ft_min_micro_version ; then
312 if test x$ft_config_is_lt = xyes ; then
315 ac_save_CFLAGS="$CFLAGS"
317 CFLAGS="$CFLAGS $FT2_CFLAGS"
318 LIBS="$FT2_LIBS $LIBS"
320 dnl Sanity checks for the results of freetype-config to some extent
323 #include <ft2build.h>
324 #include FT_FREETYPE_H
334 error = FT_Init_FreeType(&library);
340 FT_Done_FreeType(library);
344 ],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
345 CFLAGS="$ac_save_CFLAGS"
347 fi # test $ft_config_version -lt $ft_min_version
348 fi # test x$enable_fttest = xyes
349 fi # test "$FT2_CONFIG" = "no"
350 if test x$no_ft = x ; then
352 ifelse([$2], , :, [$2])
355 if test "$FT2_CONFIG" = "no" ; then
356 echo "*** The freetype-config script installed by FreeType 2 could not be found."
357 echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
358 echo "*** your path, or set the FT2_CONFIG environment variable to the"
359 echo "*** full path to freetype-config."
361 if test x$ft_config_is_lt = xyes ; then
362 echo "*** Your installed version of the FreeType 2 library is too old."
363 echo "*** If you have different versions of FreeType 2, make sure that"
364 echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix"
365 echo "*** are used, or set the FT2_CONFIG environment variable to the"
366 echo "*** full path to freetype-config."
368 echo "*** The FreeType test program failed to run. If your system uses"
369 echo "*** shared libraries and they are installed outside the normal"
370 echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
371 echo "*** (or whatever is appropiate for your system) is correctly set."
376 ifelse([$3], , :, [$3])