6b88bbadcc33a3ae85768d7f2371f0c81de2546c
[platform/upstream/pygobject2.git] / configure.ac
1 -*- mode: m4 -*-
2 AC_PREREQ([2.68])
3
4 # The version of python used is determined by the executable pointed to by the
5 # --with-python switch, or if that's not set, by the PYTHON environment
6 # variable.  For instance if your system installs Python 3 as python3 to
7 # configure to compile pygobject under Python 3 you would do this:
8 #   $ ./configure --with-python=python3
9 # or
10 #   $ PYTHON=python3 ./configure
11 #
12 # You can also build against a full interpreter path, such as
13 #   $ ./configure --with-python=~/my-patched-python/python
14
15 m4_define(python_min_ver, 2.6)
16 m4_define(python3_min_ver, 3.1)
17
18 dnl the pygobject version number
19 m4_define(pygobject_major_version, 3)
20 m4_define(pygobject_minor_version, 7)
21 m4_define(pygobject_micro_version, 4)
22 m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
23
24 dnl versions of packages we require ...
25 m4_define(introspection_required_version, 1.34.2)
26 m4_define(py2cairo_required_version, 1.2.0)
27 m4_define(py3cairo_required_version, 1.10.0)
28 m4_define(glib_required_version, 2.34.2)
29 m4_define(gio_required_version, 2.34.2)
30
31 AC_INIT([pygobject],[pygobject_version],
32         [http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject],
33         [pygobject],[https://live.gnome.org/PyGObject/])
34 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I .")
35 AC_CONFIG_MACRO_DIR([m4])
36 AC_CONFIG_SRCDIR([gi/gimodule.c])
37
38 AC_DEFINE(PYGOBJECT_MAJOR_VERSION, pygobject_major_version, [pygobject major version])
39 AC_SUBST(PYGOBJECT_MAJOR_VERSION, pygobject_major_version)
40 AC_DEFINE(PYGOBJECT_MINOR_VERSION, pygobject_minor_version, [pygobject minor version])
41 AC_SUBST(PYGOBJECT_MINOR_VERSION, pygobject_minor_version)
42 AC_DEFINE(PYGOBJECT_MICRO_VERSION, pygobject_micro_version, [pygobject micro version])
43 AC_SUBST(PYGOBJECT_MICRO_VERSION, pygobject_micro_version)
44
45 AC_CONFIG_HEADERS(config.h)
46 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
47 AM_INIT_AUTOMAKE([1.11.1 foreign no-dist-gzip dist-xz])
48
49 dnl put the ACLOCAL flags in the makefile
50 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
51
52 AC_CANONICAL_BUILD
53 AC_CANONICAL_HOST
54 AC_MSG_CHECKING([for some Win32 platform])
55 case "$host" in
56   *-*-mingw*|*-*-cygwin*)
57     platform_win32=yes
58     ;;
59   *)
60     platform_win32=no
61     ;;
62 esac
63 AC_MSG_RESULT([$platform_win32])
64 AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
65
66 AC_MSG_CHECKING([for native Win32])
67 case "$host" in
68   *-*-mingw*)
69     os_win32=yes
70     ;;
71   *)
72     os_win32=no
73     ;;
74 esac
75 AC_MSG_RESULT([$os_win32])
76 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
77
78 LT_PREREQ([2.2.6])
79 LT_INIT([dlopen win32-dll disable-static])
80
81 AC_SEARCH_LIBS([strerror],[cposix])
82 AC_PROG_CC
83 AM_PROG_CC_C_O
84
85 # option to specify python interpreter to use; this just sets $PYTHON, so that
86 # we will fallback to reading $PYTHON if --with-python is not given, and
87 # python.m4 will get the expected input
88 AC_ARG_WITH(python,
89   AS_HELP_STRING([--with-python=PATH],[Path to Python interpreter; searches $PATH if only a program name is given; if not given, searches for a few standard names such as "python3" or "python2"]),
90   [PYTHON="$withval"], [])
91 if test x"$PYTHON" = xyes; then
92         AC_MSG_ERROR([--with-python option requires a path or program argument])
93 fi
94 if test -n "$PYTHON" && ! which "$PYTHON"; then
95         AC_MSG_ERROR([Python interpreter $PYTHON does not exist])
96 fi
97
98 # check that we have the minimum version of python necessary to build
99 JD_PATH_PYTHON(python_min_ver)
100
101 # check if we are building for python 3
102 JD_PYTHON_CHECK_VERSION([$PYTHON], [3.0],
103                          build_py3k=true,
104                          build_py3k=false)
105
106 # if building for python 3 make sure we have the minimum version supported
107 if test $build_py3k = true ; then
108   AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver)
109   JD_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver,
110                           [AC_MSG_RESULT(yes)],
111                           [AC_MSG_ERROR(too old)])
112 fi
113
114 AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
115 if test "x$os_win32" = "xyes"; then
116   AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.]))
117 fi
118
119 AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
120 old_CPPFLAGS=$CPPFLAGS
121 CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
122 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[PySignal_SetWakeupFd(0);]])],
123                   [setwakeupfd_ok=yes],[setwakeupfd_ok=no])
124 AC_MSG_RESULT($setwakeupfd_ok)
125 if test "x$setwakeupfd_ok" != xno; then
126   AC_DEFINE(HAVE_PYSIGNAL_SETWAKEUPFD, 1,
127                 [Define to 1 if PySignal_SetWakeupFd is available])
128 fi
129 CPPFLAGS=$old_CPPFLAGS
130
131 PLATFORM=`$PYTHON -c "import sys; from distutils import util; sys.stdout.write(util.get_platform())"`
132 AC_SUBST(PLATFORM)
133
134 AC_ARG_ENABLE(thread,
135   AS_HELP_STRING([--disable-thread],[Disable pygobject threading support]),,
136   enable_thread=yes)
137
138 AM_CHECK_PYMOD(thread,,,enable_thread=check_for_py3_module)
139 if test "x$enable_thread" = xcheck_for_py3_module; then
140   dnl Python 3 uses the _thread module so check for that
141   AM_CHECK_PYMOD(_thread,,enable_thread=yes,enable_thread=no)
142 fi
143
144 AC_MSG_CHECKING(whether to enable threading in pygobject)
145 if test "x$enable_thread" != xno; then
146   extra_mods=gthread
147   THREADING_CFLAGS=
148   AC_MSG_RESULT(yes)
149 else
150   extra_mods=
151   THREADING_CFLAGS="-DDISABLE_THREADING"
152   AC_MSG_RESULT(no)
153 fi
154 AC_SUBST(THREADING_CFLAGS)
155 CPPFLAGS="${CPPFLAGS} $THREADING_CFLAGS"
156
157 dnl get rid of the -export-dynamic stuff from the configure flags ...
158 export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
159
160 dnl glib
161 AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(maybe you want the pygobject-2-4 branch?)],gobject $extra_mods)
162 if test -n "$export_dynamic"; then
163   GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"`
164 fi
165 PYTHON_BASENAME=`basename $PYTHON`
166 AC_SUBST([PYTHON_BASENAME])
167
168 AS_AC_EXPAND(DATADIR, $datadir)
169
170 dnl libffi
171 AC_MSG_CHECKING(for ffi)
172 AC_ARG_WITH(ffi,
173   AS_HELP_STRING([--without-ffi],[Disable libffi support]),
174   with_libffi=$withval,
175   with_libffi=auto)
176 if test x"$with_libffi" = xno ; then
177   have_libffi=false
178 else
179   PKG_CHECK_MODULES(FFI, libffi >= 3.0, have_libffi=yes, have_libffi=no)
180 fi
181 if test x"$with_libffi" = xyes && test x"$have_libffi" = xno ; then
182   AC_MSG_ERROR([ffi requested, but not found])
183 fi
184 if test x"$have_libffi" = xyes; then
185   LIBFFI_PC=libffi
186 fi
187 AM_CONDITIONAL(HAVE_LIBFFI, test "$have_libffi" = "yes")
188 AC_SUBST(FFI_CFLAGS)
189 AC_SUBST(FFI_LIBS)
190 AC_SUBST(LIBFFI_PC)
191
192 dnl gio
193 PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version)
194
195 AC_ARG_ENABLE(cairo,
196     AS_HELP_STRING([--enable-cairo],[Enable Cairo bindings using introspection information]),
197     enable_cairo=$enableval,
198     enable_cairo=yes)
199
200 PKG_CHECK_MODULES(GI,
201     glib-2.0 >= glib_required_version
202     gobject-introspection-1.0 >= introspection_required_version
203 )
204
205 GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
206 AC_SUBST(GI_DATADIR)
207
208 if test "$enable_cairo" != no; then
209     PKG_CHECK_MODULES(CAIRO, cairo cairo-gobject)
210
211     if test $build_py3k = true; then
212         PKG_CHECK_MODULES(PYCAIRO,
213             py3cairo >= py3cairo_required_version
214         )
215     else
216         PKG_CHECK_MODULES(PYCAIRO,
217             pycairo >= py2cairo_required_version
218         )
219     fi
220 fi
221 AM_CONDITIONAL(ENABLE_CAIRO, test "$enable_cairo" = "yes")
222
223 INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
224 INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
225
226 AC_SUBST(INTROSPECTION_SCANNER)
227 AC_SUBST(INTROSPECTION_COMPILER)
228
229 dnl add required cflags ...
230 if test "x$GCC" = "xyes"; then
231   JH_ADD_CFLAG([-Wall])
232   #JH_ADD_CFLAG([-Werror=missing-prototypes])
233   JH_ADD_CFLAG([-Werror=implicit-function-declaration])
234   JH_ADD_CFLAG([-Werror=pointer-arith])
235   JH_ADD_CFLAG([-Werror=format-security])
236   JH_ADD_CFLAG([-Werror=missing-include-dirs])
237   JH_ADD_CFLAG([-Werror=format])
238   JH_ADD_CFLAG([-Werror=unused-variable])
239   JH_ADD_CFLAG([-fno-strict-aliasing])
240
241   case $host_os in
242   solaris*)
243     ;;
244   *)
245     JH_ADD_CFLAG([-std=c9x])
246     ;;
247   esac
248
249 fi
250
251 # enable code coverage support
252 GNOME_CODE_COVERAGE
253 CFLAGS="$CFLAGS $CODE_COVERAGE_CFLAGS"
254 LDFLAGS="$LDFLAGS $CODE_COVERAGE_CFLAGS"
255
256 AC_CONFIG_FILES(
257   Makefile
258   pygobject-3.0.pc
259   pygobject-3.0-uninstalled.pc
260   gi/Makefile
261   gi/repository/Makefile
262   gi/overrides/Makefile
263   gi/_glib/Makefile
264   gi/_gobject/Makefile
265   examples/Makefile
266   tests/Makefile
267   pygtkcompat/Makefile
268   PKG-INFO)
269 AC_OUTPUT
270
271 AC_MSG_RESULT([
272         pygobject $VERSION
273
274         Using python interpreter:       $PYTHON
275         libffi support:                 $have_libffi
276         cairo support:                  $enable_cairo
277         thread support:                 $enable_thread
278         code coverage support:          $enable_code_coverage
279 ])
280