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 dnl FIXME: avoid getting NONE/lib/sitepackages below --hb
100 if test "x$prefix" != "xNONE"; then
101 AC_SUBST([PYTHON_PREFIX], [${prefix}])
103 AC_SUBST([PYTHON_PREFIX], [/usr])
105 if test "x$exec_prefix" != "xNONE"; then
106 AC_SUBST([PYTHON_EXEC_PREFIX], [${exec_prefix}])
108 AC_SUBST([PYTHON_EXEC_PREFIX], [/usr])
111 dnl At times (like when building shared libraries) you may want
112 dnl to know which OS platform Python thinks this is.
114 AC_SUBST(PYTHON_PLATFORM)
115 PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
118 dnl Set up 4 directories:
120 dnl pythondir -- where to install python scripts. This is the
121 dnl site-packages directory, not the python standard library
122 dnl directory like in previous automake betas. This behaviour
123 dnl is more consistent with lispdir.m4 for example.
125 dnl Also, if the package prefix isn't the same as python's prefix,
126 dnl then the old $(pythondir) was pretty useless.
128 AC_CACHE_CHECK([for $am_display_PYTHON script directory],
129 [am_cv_python_pythondir],
130 [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
131 echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
132 AC_SUBST([pythondir], [$am_cv_python_pythondir])
134 dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
135 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
136 dnl more consistent with the rest of automake.
137 dnl Maybe this should be put in python.am?
139 AC_SUBST(pkgpythondir)
140 pkgpythondir=\${pythondir}/$PACKAGE
142 dnl pyexecdir -- directory for installing python extension modules
143 dnl (shared libraries) Was PYTHON_SITE_EXEC in previous betas.
145 AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
146 [am_cv_python_pyexecdir],
147 [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
148 echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
149 AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
151 dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
152 dnl Maybe this should be put in python.am?
154 AC_SUBST(pkgpyexecdir)
155 pkgpyexecdir=\${pyexecdir}/$PACKAGE
157 AC_MSG_RESULT([looks good])
160 dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
161 dnl Check if a module containing a given symbol is visible to python.
162 AC_DEFUN([AM_CHECK_PYMOD],
163 [AC_REQUIRE([AM_PATH_PYTHON])
164 py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
165 AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
166 AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
167 ifelse([$2],[], [prog="
175 sys.exit(0)"], [prog="
178 if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
180 eval "py_cv_mod_$py_mod_var=yes"
182 eval "py_cv_mod_$py_mod_var=no"
185 py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
186 if test "x$py_val" != xno; then
188 ifelse([$3], [],, [$3
192 ifelse([$4], [],, [$4
197 dnl a macro to check for ability to create python extensions
198 dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
199 dnl function also defines PYTHON_INCLUDES
200 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
201 [AC_REQUIRE([AM_PATH_PYTHON])
202 AC_MSG_CHECKING(for headers required to compile python extensions)
203 dnl deduce PYTHON_INCLUDES
204 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
205 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
206 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
207 if test "$py_prefix" != "$py_exec_prefix"; then
208 PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
210 AC_SUBST(PYTHON_INCLUDES)
211 dnl check if the headers exist:
212 save_CPPFLAGS="$CPPFLAGS"
213 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
214 AC_TRY_CPP([#include <Python.h>],dnl
215 [AC_MSG_RESULT(found)
217 [AC_MSG_RESULT(not found)
219 CPPFLAGS="$save_CPPFLAGS"
222 AC_DEFUN([AM_CHECK_PYTHON_LIB],
223 [AC_REQUIRE([AM_PATH_PYTHON])
224 AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])
226 AC_MSG_CHECKING(for libpython${PYTHON_VERSION}.a)
228 py_config_dir=`$PYTHON -c "import os; print os.path.abspath('$pyexecdir/../config')"`
230 py_makefile="${py_config_dir}/Makefile"
231 if test -f "$py_makefile"; then
232 dnl extra required libs
233 py_localmodlibs=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $py_makefile`
234 py_basemodlibs=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $py_makefile`
235 py_other_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $py_makefile`
237 dnl now the actual libpython
238 if test -e "${py_config_dir}/libpython${PYTHON_VERSION}.a"; then
239 PYTHON_LIBS="-L${py_config_dir} -lpython${PYTHON_VERSION} $py_localmodlibs $py_basemodlibs $py_other_libs"
242 AC_MSG_RESULT(not found)
245 AC_MSG_RESULT(not found)
247 AC_SUBST(PYTHON_LIBS)])
249 # We need this because freetype is optional
250 # Configure paths for FreeType2
251 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
253 dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
254 dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
256 AC_DEFUN([AC_CHECK_FT2],
258 dnl Get the cflags and libraries from the freetype-config script
260 AC_ARG_WITH(ft-prefix,
261 [ --with-ft-prefix=PREFIX
262 Prefix where FreeType is installed (optional)],
263 ft_config_prefix="$withval", ft_config_prefix="")
264 AC_ARG_WITH(ft-exec-prefix,
265 [ --with-ft-exec-prefix=PREFIX
266 Exec prefix where FreeType is installed (optional)],
267 ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
268 AC_ARG_ENABLE(freetypetest,
269 [ --disable-freetypetest Do not try to compile and run
270 a test FreeType program],
271 [], enable_fttest=yes)
273 if test x$ft_config_exec_prefix != x ; then
274 ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
275 if test x${FT2_CONFIG+set} != xset ; then
276 FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
279 if test x$ft_config_prefix != x ; then
280 ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
281 if test x${FT2_CONFIG+set} != xset ; then
282 FT2_CONFIG=$ft_config_prefix/bin/freetype-config
285 AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
287 min_ft_version=ifelse([$1], ,6.1.0,$1)
288 AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
290 if test "$FT2_CONFIG" = "no" ; then
293 FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
294 FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
295 ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
296 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
297 ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
298 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
299 ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
300 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
301 ft_min_major_version=`echo $min_ft_version | \
302 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
303 ft_min_minor_version=`echo $min_ft_version | \
304 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
305 ft_min_micro_version=`echo $min_ft_version | \
306 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
307 if test x$enable_fttest = xyes ; then
309 if test $ft_config_major_version -lt $ft_min_major_version ; then
312 if test $ft_config_major_version -eq $ft_min_major_version ; then
313 if test $ft_config_minor_version -lt $ft_min_minor_version ; then
316 if test $ft_config_minor_version -eq $ft_min_minor_version ; then
317 if test $ft_config_micro_version -lt $ft_min_micro_version ; then
324 if test x$ft_config_is_lt = xyes ; then
327 ac_save_CFLAGS="$CFLAGS"
329 CFLAGS="$CFLAGS $FT2_CFLAGS"
330 LIBS="$FT2_LIBS $LIBS"
332 dnl Sanity checks for the results of freetype-config to some extent
335 #include <ft2build.h>
336 #include FT_FREETYPE_H
346 error = FT_Init_FreeType(&library);
352 FT_Done_FreeType(library);
356 ],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
357 CFLAGS="$ac_save_CFLAGS"
359 fi # test $ft_config_version -lt $ft_min_version
360 fi # test x$enable_fttest = xyes
361 fi # test "$FT2_CONFIG" = "no"
362 if test x$no_ft = x ; then
364 ifelse([$2], , :, [$2])
367 if test "$FT2_CONFIG" = "no" ; then
368 echo "*** The freetype-config script installed by FreeType 2 could not be found."
369 echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
370 echo "*** your path, or set the FT2_CONFIG environment variable to the"
371 echo "*** full path to freetype-config."
373 if test x$ft_config_is_lt = xyes ; then
374 echo "*** Your installed version of the FreeType 2 library is too old."
375 echo "*** If you have different versions of FreeType 2, make sure that"
376 echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix"
377 echo "*** are used, or set the FT2_CONFIG environment variable to the"
378 echo "*** full path to freetype-config."
380 echo "*** The FreeType test program failed to run. If your system uses"
381 echo "*** shared libraries and they are installed outside the normal"
382 echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
383 echo "*** (or whatever is appropiate for your system) is correctly set."
388 ifelse([$3], , :, [$3])