Imported Upstream version 3.2.1
[platform/upstream/pygobject2.git] / configure.ac
1 -*- mode: m4 -*-
2 AC_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
9 m4_define(python_min_ver, 2.5.2)
10 m4_define(python3_min_ver, 3.1)
11
12 dnl the pygobject version number
13 m4_define(pygobject_major_version, 3)
14 m4_define(pygobject_minor_version, 2)
15 m4_define(pygobject_micro_version, 1)
16 m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
17
18 dnl versions of packages we require ...
19 m4_define(introspection_required_version, 1.31.20)
20 m4_define(py2cairo_required_version, 1.2.0)
21 m4_define(py3cairo_required_version, 1.10.0)
22 m4_define(glib_required_version, 2.31.0)
23 m4_define(gio_required_version, 2.31.0)
24
25 AC_INIT(pygobject, pygobject_version,
26         [http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject])
27 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I .")
28 AC_CONFIG_MACRO_DIR([m4])
29 AC_CONFIG_SRCDIR([gi/gimodule.c])
30
31 AC_DEFINE(PYGOBJECT_MAJOR_VERSION, pygobject_major_version, [pygobject major version])
32 AC_SUBST(PYGOBJECT_MAJOR_VERSION, pygobject_major_version)
33 AC_DEFINE(PYGOBJECT_MINOR_VERSION, pygobject_minor_version, [pygobject minor version])
34 AC_SUBST(PYGOBJECT_MINOR_VERSION, pygobject_minor_version)
35 AC_DEFINE(PYGOBJECT_MICRO_VERSION, pygobject_micro_version, [pygobject micro version])
36 AC_SUBST(PYGOBJECT_MICRO_VERSION, pygobject_micro_version)
37
38 AM_CONFIG_HEADER(config.h)
39 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
40 AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
41 AM_MAINTAINER_MODE([enable])
42
43 dnl put the ACLOCAL flags in the makefile
44 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
45
46 AC_CANONICAL_BUILD
47 AC_CANONICAL_HOST
48 AC_MSG_CHECKING([for some Win32 platform])
49 case "$host" in
50   *-*-mingw*|*-*-cygwin*)
51     platform_win32=yes
52     ;;
53   *)
54     platform_win32=no
55     ;;
56 esac
57 AC_MSG_RESULT([$platform_win32])
58 AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
59
60 AC_MSG_CHECKING([for native Win32])
61 case "$host" in
62   *-*-mingw*)
63     os_win32=yes
64     ;;
65   *)
66     os_win32=no
67     ;;
68 esac
69 AC_MSG_RESULT([$os_win32])
70 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
71
72 AC_DISABLE_STATIC
73
74 dnl XXXX hack to kill off all the libtool tags ...
75 dnl it isn't like we are using C++ or Fortran.
76 dnl (copied from libglade/configure.in)
77 m4_define([_LT_AC_TAGCONFIG],[])
78
79 AC_LIBTOOL_WIN32_DLL
80 AC_PROG_LIBTOOL
81 dnl when using libtool 2.x create libtool early, because it's used in configure
82 m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
83 AC_ISC_POSIX
84 AC_PROG_CC
85 AM_PROG_CC_STDC
86 AM_PROG_CC_C_O
87
88 # check that we have the minimum version of python necisary to build
89 JD_PATH_PYTHON(python_min_ver)
90
91 # check if we are building for python 3
92 JD_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
97 if 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)])
102 fi
103
104 AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
105 if test "x$os_win32" = "xyes"; then
106   AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.]))
107 fi
108
109 AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
110 old_CPPFLAGS=$CPPFLAGS
111 CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
112 AC_TRY_COMPILE([#include <Python.h>],
113   [PySignal_SetWakeupFd(0);],
114   setwakeupfd_ok=yes,
115   setwakeupfd_ok=no)
116 AC_MSG_RESULT($setwakeupfd_ok)
117 if test "x$setwakeupfd_ok" != xno; then
118   AC_DEFINE(HAVE_PYSIGNAL_SETWAKEUPFD, 1,
119                 [Define to 1 if PySignal_SetWakeupFd is available])
120 fi
121 CPPFLAGS=$old_CPPFLAGS
122
123 PLATFORM=`$PYTHON -c "import sys; from distutils import util; sys.stdout.write(util.get_platform())"`
124 AC_SUBST(PLATFORM)
125
126 AC_ARG_ENABLE(thread,
127   AC_HELP_STRING([--disable-thread], [Disable pygobject threading support]),,
128   enable_thread=yes)
129
130 AM_CHECK_PYMOD(thread,,,enable_thread=check_for_py3_module)
131 if test "x$enable_thread" = xcheck_for_py3_module; then
132   dnl Python 3 uses the _thread module so check for that
133   AM_CHECK_PYMOD(_thread,,,enable_thread=no)
134 fi
135
136 AC_MSG_CHECKING(whether to enable threading in pygobject)
137 if test "x$enable_thread" != xno; then
138   extra_mods=gthread
139   THREADING_CFLAGS=
140   AC_MSG_RESULT(yes)
141 else
142   extra_mods=
143   THREADING_CFLAGS="-DDISABLE_THREADING"
144   AC_MSG_RESULT(no)
145 fi
146 AC_SUBST(THREADING_CFLAGS)
147 CPPFLAGS="${CPPFLAGS} $THREADING_CFLAGS"
148
149 dnl get rid of the -export-dynamic stuff from the configure flags ...
150 export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
151
152 dnl glib
153 AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(maybe you want the pygobject-2-4 branch?)],gobject $extra_mods)
154 if test -n "$export_dynamic"; then
155   GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"`
156 fi
157 PYTHON_BASENAME=`basename $PYTHON`
158 AC_SUBST([PYTHON_BASENAME])
159
160 AS_AC_EXPAND(DATADIR, $datadir)
161
162 dnl libffi
163 AC_MSG_CHECKING(for ffi)
164 AC_ARG_WITH(ffi,
165   AC_HELP_STRING([--without-ffi], [Disable libffi support]),
166   with_libffi=$withval,
167   with_libffi=auto)
168 if test x"$with_libffi" = xno ; then
169   have_libffi=false
170 else
171   PKG_CHECK_MODULES(FFI, libffi >= 3.0, have_libffi=yes, have_libffi=no)
172 fi
173 if test x"$with_libffi" = xyes && test x"$have_libffi" = xno ; then
174   AC_MSG_ERROR([ffi requested, but not found])
175 fi
176 if test x"$have_libffi" = xyes; then
177   LIBFFI_PC=libffi
178 fi
179 AM_CONDITIONAL(HAVE_LIBFFI, test "$have_libffi" = "yes")
180 AC_SUBST(FFI_CFLAGS)
181 AC_SUBST(FFI_LIBS)
182 AC_SUBST(LIBFFI_PC)
183
184 dnl gio
185 PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version)
186
187 AC_ARG_ENABLE(cairo,
188     AC_HELP_STRING([--enable-cairo], [Enable Cairo bindings using introspection information]),
189     enable_cairo=$enableval,
190     enable_cairo=yes)
191
192 PKG_CHECK_MODULES(GI,
193     glib-2.0 >= glib_required_version
194     gobject-introspection-1.0 >= introspection_required_version
195 )
196
197 GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
198 AC_SUBST(GI_DATADIR)
199
200 if test "$enable_cairo" != no; then
201     if test $build_py3k = true; then
202         PKG_CHECK_MODULES(PYCAIRO,
203             py3cairo >= py3cairo_required_version
204         )
205     else
206         PKG_CHECK_MODULES(PYCAIRO,
207             pycairo >= py2cairo_required_version
208         )
209     fi
210 fi
211 AM_CONDITIONAL(ENABLE_CAIRO, test "$enable_cairo" = "yes")
212
213 INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
214 INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
215
216 AC_SUBST(INTROSPECTION_SCANNER)
217 AC_SUBST(INTROSPECTION_COMPILER)
218
219 dnl add required cflags ...
220 if test "x$GCC" = "xyes"; then
221   JH_ADD_CFLAG([-Wall])
222   JH_ADD_CFLAG([-fno-strict-aliasing])
223
224   case $host_os in
225   solaris*)
226     ;;
227   *)
228     JH_ADD_CFLAG([-std=c9x])
229     ;;
230   esac
231
232 fi
233
234 AC_CONFIG_FILES(
235   Makefile
236   pygobject-3.0.pc
237   pygobject-3.0-uninstalled.pc
238   gi/Makefile
239   gi/repository/Makefile
240   gi/overrides/Makefile
241   gi/_glib/Makefile
242   gi/_gobject/Makefile
243   examples/Makefile
244   tests/Makefile
245   PKG-INFO)
246 AC_OUTPUT
247
248 echo
249 echo "libffi support: $have_libffi"
250 echo