1-*- mode: m4 -*-
2AC_PREREQ(2.52)
3
4# The version of python used is determined by the executable pointed to by
5# the PYTHON environment variable.  For instance if your system installs
6# Python 3 as python3 to configure to compile pygobject under Python 3
7# you would do this:
8# $> PYTHON=python3 ./configure
9m4_define(python_min_ver, 2.5.2)
10m4_define(python3_min_ver, 3.1)
11
12dnl the pygobject version number
13m4_define(pygobject_major_version, 2)
14m4_define(pygobject_minor_version, 28)
15m4_define(pygobject_micro_version, 6)
16m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
17
18dnl versions of packages we require ...
19m4_define(introspection_required_version, 0.10.2)
20m4_define(pycairo_required_version, 1.2.0)
21m4_define(glib_required_version, 2.24.0)
22m4_define(gio_required_version, 2.24.0)
23m4_define(giounix_required_version, 2.22.4)
24
25AC_INIT(pygobject, pygobject_version,
26        [http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject])
27AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I .")
28AC_CONFIG_MACRO_DIR([m4])
29AC_CONFIG_SRCDIR([gobject/gobjectmodule.c])
30
31AC_DEFINE(PYGOBJECT_MAJOR_VERSION, pygobject_major_version, [pygobject major version])
32AC_SUBST(PYGOBJECT_MAJOR_VERSION, pygobject_major_version)
33AC_DEFINE(PYGOBJECT_MINOR_VERSION, pygobject_minor_version, [pygobject minor version])
34AC_SUBST(PYGOBJECT_MINOR_VERSION, pygobject_minor_version)
35AC_DEFINE(PYGOBJECT_MICRO_VERSION, pygobject_micro_version, [pygobject micro version])
36AC_SUBST(PYGOBJECT_MICRO_VERSION, pygobject_micro_version)
37
38AM_CONFIG_HEADER(config.h)
39m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
40AM_INIT_AUTOMAKE(foreign)
41AM_MAINTAINER_MODE
42
43dnl put the ACLOCAL flags in the makefile
44ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
45
46AC_CANONICAL_BUILD
47AC_CANONICAL_HOST
48AC_MSG_CHECKING([for some Win32 platform])
49case "$host" in
50  *-*-mingw*|*-*-cygwin*)
51    platform_win32=yes
52    ;;
53  *)
54    platform_win32=no
55    ;;
56esac
57AC_MSG_RESULT([$platform_win32])
58AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
59
60AC_MSG_CHECKING([for native Win32])
61case "$host" in
62  *-*-mingw*)
63    os_win32=yes
64    ;;
65  *)
66    os_win32=no
67    ;;
68esac
69AC_MSG_RESULT([$os_win32])
70AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
71
72AC_DISABLE_STATIC
73
74dnl XXXX hack to kill off all the libtool tags ...
75dnl it isn't like we are using C++ or Fortran.
76dnl (copied from libglade/configure.in)
77m4_define([_LT_AC_TAGCONFIG],[])
78
79AC_LIBTOOL_WIN32_DLL
80AC_PROG_LIBTOOL
81dnl when using libtool 2.x create libtool early, because it's used in configure
82m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
83AC_ISC_POSIX
84AC_PROG_CC
85AM_PROG_CC_STDC
86AM_PROG_CC_C_O
87
88# check that we have the minimum version of python necisary to build
89JD_PATH_PYTHON(python_min_ver)
90
91# check if we are building for python 3
92JD_PYTHON_CHECK_VERSION([$PYTHON], [3.0],
93			 build_py3k=true,
94			 build_py3k=false)
95
96# if building for python 3 make sure we have the minimum version supported
97if test $build_py3k = true ; then
98  AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver)
99  JD_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver,
100			  [AC_MSG_RESULT(yes)],
101			  [AC_MSG_ERROR(too old)])
102fi
103
104AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
105
106AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
107old_CPPFLAGS=$CPPFLAGS
108CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
109AC_TRY_COMPILE([#include <Python.h>],
110  [PySignal_SetWakeupFd(0);],
111  setwakeupfd_ok=yes,
112  setwakeupfd_ok=no)
113AC_MSG_RESULT($setwakeupfd_ok)
114if test "x$setwakeupfd_ok" != xno; then
115  AC_DEFINE(HAVE_PYSIGNAL_SETWAKEUPFD, 1,
116                [Define to 1 if PySignal_SetWakeupFd is available])
117fi
118CPPFLAGS=$old_CPPFLAGS
119
120PLATFORM=`$PYTHON -c "import sys; from distutils import util; sys.stdout.write(util.get_platform())"`
121AC_SUBST(PLATFORM)
122
123AC_ARG_ENABLE(thread,
124  AC_HELP_STRING([--disable-thread], [Disable pygobject threading support]),,
125  enable_thread=yes)
126
127dnl Building documentation
128AC_ARG_ENABLE(docs,
129  AC_HELP_STRING([--enable-docs], [Enable documentation building]),enable_docs=$enableval,
130  enable_docs=no)
131if test "${enable_docs}" != no; then
132  dnl
133  dnl Check for xsltproc
134  dnl
135  AC_PATH_PROG([XSLTPROC], [xsltproc])
136  if test -z "$XSLTPROC"; then
137    enable_docs=no
138  fi
139
140  dnl check for DocBook DTD and stylesheets in the local catalog.
141  dnl JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
142  dnl   [DocBook XML DTD V4.1.2],,enable_docs=no)
143  dnl JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
144  dnl   [DocBook XSL Stylesheets],,enable_docs=no)
145fi
146
147AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs != xno)
148
149AM_CHECK_PYMOD(thread,,,enable_thread=check_for_py3_module)
150if test "x$enable_thread" = xcheck_for_py3_module; then
151  dnl Python 3 uses the _thread module so check for that
152  AM_CHECK_PYMOD(_thread,,,enable_thread=no)
153fi
154
155AC_MSG_CHECKING(whether to enable threading in pygobject)
156if test "x$enable_thread" != xno; then
157  extra_mods=gthread
158  THREADING_CFLAGS=
159  AC_MSG_RESULT(yes)
160else
161  extra_mods=
162  THREADING_CFLAGS="-DDISABLE_THREADING"
163  AC_MSG_RESULT(no)
164fi
165AC_SUBST(THREADING_CFLAGS)
166CPPFLAGS="${CPPFLAGS} $THREADING_CFLAGS"
167
168dnl get rid of the -export-dynamic stuff from the configure flags ...
169export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
170
171dnl glib
172AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(maybe you want the pygobject-2-4 branch?)],gobject $extra_mods)
173if test -n "$export_dynamic"; then
174  GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"`
175fi
176PYTHON_BASENAME=`basename $PYTHON`
177AC_SUBST([PYTHON_BASENAME])
178
179pygobject_CODEGEN_DEFINES=""
180AC_SUBST([pygobject_CODEGEN_DEFINES])
181
182AS_AC_EXPAND(DATADIR, $datadir)
183
184dnl libffi
185AC_MSG_CHECKING(for ffi)
186AC_ARG_WITH(ffi,
187  AC_HELP_STRING([--without-ffi], [Disable libffi support]),
188  with_libffi=$withval,
189  with_libffi=auto)
190if test x"$with_libffi" = xno ; then
191  have_libffi=false
192else
193  PKG_CHECK_MODULES(FFI, libffi >= 3.0, have_libffi=yes, have_libffi=no)
194fi
195if test x"$with_libffi" = xyes && test x"$have_libffi" = xno ; then
196  AC_MSG_ERROR([ffi requested, but not found])
197fi
198if test x"$have_libffi" = xyes; then
199  AC_DEFINE(HAVE_FFI_H,1,[Have libffi include files])
200  LIBFFI_PC=libffi
201fi
202AM_CONDITIONAL(HAVE_LIBFFI, test "$have_libffi" = "yes")
203AC_SUBST(FFI_CFLAGS)
204AC_SUBST(FFI_LIBS)
205AC_SUBST(LIBFFI_PC)
206
207dnl gio
208PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version,
209	have_gio=true, have_gio=false)
210AC_SUBST(GIO_CFLAGS)
211AC_SUBST(GIO_LIBS)
212
213# Do not build GIO if the python version >= 3.0
214# We use GI to access GIO in python 3
215AM_CONDITIONAL(BUILD_GIO, test $have_gio = true -a $build_py3k = false)
216
217if test -n "$export_dynamic"; then
218  GIO_LIBS=`echo $GIO_LIBS | sed -e "s/$export_dynamic//"`
219fi
220
221dnl giounix
222PKG_CHECK_MODULES(GIOUNIX, gio-unix-2.0 >= giounix_required_version,
223	have_giounix=true, have_giounix=false)
224AC_SUBST(GIOUNIX_CFLAGS)
225AC_SUBST(GIOUNIX_LIBS)
226AM_CONDITIONAL(BUILD_GIOUNIX, test $have_giounix = true -a $build_py3k = false)
227if test -n "$export_dynamic"; then
228  GIOUNIX_LIBS=`echo $GIOUNIX_LIBS | sed -e "s/$export_dynamic//"`
229fi
230
231AC_ARG_ENABLE(cairo,
232    AC_HELP_STRING([--enable-cairo], [Enable Cairo bindings using introspection information]),
233    enable_cairo=$enableval,
234    enable_cairo=yes)
235
236AC_ARG_ENABLE(introspection,
237  AC_HELP_STRING([--enable-introspection], [Use introspection information]),
238  enable_introspection=$enableval,
239  enable_introspection=yes)
240if test "$enable_introspection" != no; then
241    AC_DEFINE(ENABLE_INTROSPECTION,1,Use introspection information)
242    PKG_CHECK_MODULES(GI,
243        glib-2.0 >= glib_required_version
244        gobject-introspection-1.0 >= introspection_required_version
245    )
246
247    GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
248    AC_SUBST(GI_DATADIR)
249
250    if test "$enable_cairo" != no; then
251        PKG_CHECK_MODULES(PYCAIRO,
252            pycairo >= pycairo_required_version
253        )
254    fi
255fi
256AM_CONDITIONAL(ENABLE_INTROSPECTION, test "$enable_introspection" = "yes")
257AM_CONDITIONAL(ENABLE_CAIRO, test "$enable_cairo" = "yes")
258
259INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
260INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
261
262AC_SUBST(INTROSPECTION_SCANNER)
263AC_SUBST(INTROSPECTION_COMPILER)
264
265dnl add required cflags ...
266if test "x$GCC" = "xyes"; then
267  JH_ADD_CFLAG([-Wall])
268  JH_ADD_CFLAG([-fno-strict-aliasing])
269
270  case $host_os in
271  solaris*)
272    ;;
273  *)
274    JH_ADD_CFLAG([-std=c9x])
275    ;;
276  esac
277
278fi
279
280AC_CONFIG_FILES(
281  Makefile
282  pygobject-2.0.pc
283  pygobject-2.0-uninstalled.pc
284  codegen/Makefile
285  codegen/pygobject-codegen-2.0
286  docs/Makefile
287  docs/reference/entities.docbook
288  docs/xsl/fixxref.py
289  gi/Makefile
290  gi/repository/Makefile
291  gi/overrides/Makefile
292  glib/Makefile
293  gobject/Makefile
294  gio/Makefile
295  examples/Makefile
296  tests/Makefile
297  PKG-INFO)
298AC_OUTPUT
299
300echo
301echo "libffi support: $have_libffi"
302echo "introspection support: $enable_introspection"
303echo
304