Imported Upstream version 3.21.91
[platform/upstream/python-gobject.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.7)
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, 21)
21 m4_define(pygobject_micro_version, 91)
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.46.0)
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.38.0)
29 m4_define(gio_required_version, 2.38.0)
30
31 AC_INIT([pygobject],[pygobject_version],
32         [http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject],
33         [pygobject],[https://wiki.gnome.org/Projects/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 # 1.12.6 to get a py-compile supporting newer Python 3 versions.
48 # See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=8847
49 AM_INIT_AUTOMAKE([1.12.6 foreign no-dist-gzip dist-xz])
50
51 dnl put the ACLOCAL flags in the makefile
52 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
53
54 AC_CANONICAL_BUILD
55 AC_CANONICAL_HOST
56 AC_MSG_CHECKING([for build time linking with Python (Darwin and Win32)])
57 case "$host" in
58   *-*-mingw*|*-*-cygwin*)
59     os_win32=yes
60     link_python_libs=yes
61     OS_EXT=dll
62     ;;
63   *-*-darwin*)
64     os_win32=no
65     link_python_libs=yes
66     OS_EXT=dylib
67     ;;
68   *)
69     os_win32=no
70     link_python_libs=no
71     OS_EXT=so
72     ;;
73 esac
74 AC_MSG_RESULT([$link_python_libs])
75 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
76
77 AC_SUBST(OS_EXT)
78 AC_DEFINE_UNQUOTED(OS_EXT, "$OS_EXT", [Define shared library extension])
79
80 LT_PREREQ([2.2.6])
81 LT_INIT([dlopen win32-dll disable-static])
82
83 AC_SEARCH_LIBS([strerror],[cposix])
84 AC_PROG_CC
85 AM_PROG_CC_C_O
86
87 # option to specify python interpreter to use; this just sets $PYTHON, so that
88 # we will fallback to reading $PYTHON if --with-python is not given, and
89 # python.m4 will get the expected input
90 AC_ARG_WITH(python,
91   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"]),
92   [PYTHON="$withval"], [])
93 if test x"$PYTHON" = xyes; then
94         AC_MSG_ERROR([--with-python option requires a path or program argument])
95 fi
96 if test -n "$PYTHON" && ! which "$PYTHON"; then
97         AC_MSG_ERROR([Python interpreter $PYTHON does not exist])
98 fi
99
100 # check that we have the minimum version of python necessary to build
101 JD_PATH_PYTHON(python_min_ver)
102
103 # check if we are building for python 3
104 AM_PYTHON_CHECK_VERSION([$PYTHON], [3.0],
105                          build_py3k=true,
106                          build_py3k=false)
107
108 # if building for python 3 make sure we have the minimum version supported
109 if test $build_py3k = true ; then
110   AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver)
111   AM_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver,
112                           [AC_MSG_RESULT(yes)],
113                           [AC_MSG_ERROR(too old)])
114 fi
115
116 # - 'SO' for PyPy, CPython 2.7-3.2
117 # - 'EXT_SUFFIX' for CPython3.3+ (http://bugs.python.org/issue16754)
118 # - fallback to '.so'
119 PYTHON_SO=`$PYTHON -c "import distutils.sysconfig, sys; get = distutils.sysconfig.get_config_var; sys.stdout.write(get('EXT_SUFFIX') or get('SO') or '.so');"`
120 AC_SUBST(PYTHON_SO)
121
122 AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
123 if test "x$link_python_libs" = "xyes"; then
124   AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows and Darwin require Python modules to be explicitly linked to libpython.]))
125 fi
126
127 AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
128 old_CPPFLAGS=$CPPFLAGS
129 CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
130 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Python.h>]], [[PySignal_SetWakeupFd(0);]])],
131                   [setwakeupfd_ok=yes],[setwakeupfd_ok=no])
132 AC_MSG_RESULT($setwakeupfd_ok)
133 if test "x$setwakeupfd_ok" != xno; then
134   AC_DEFINE(HAVE_PYSIGNAL_SETWAKEUPFD, 1,
135                 [Define to 1 if PySignal_SetWakeupFd is available])
136 fi
137 CPPFLAGS=$old_CPPFLAGS
138
139 PLATFORM=`$PYTHON -c "import sys; from distutils import util; sys.stdout.write(util.get_platform())"`
140 AC_SUBST(PLATFORM)
141
142 AC_ARG_ENABLE(thread,
143   AS_HELP_STRING([--disable-thread],[Disable pygobject threading support]),,
144   enable_thread=yes)
145
146 AM_CHECK_PYMOD(thread,,,enable_thread=check_for_py3_module)
147 if test "x$enable_thread" = xcheck_for_py3_module; then
148   dnl Python 3 uses the _thread module so check for that
149   AM_CHECK_PYMOD(_thread,,enable_thread=yes,enable_thread=no)
150 fi
151
152 AC_MSG_CHECKING(whether to enable threading in pygobject)
153 if test "x$enable_thread" != xno; then
154   extra_mods=gthread
155   THREADING_CFLAGS=
156   AC_MSG_RESULT(yes)
157 else
158   extra_mods=
159   THREADING_CFLAGS="-DDISABLE_THREADING"
160   AC_MSG_RESULT(no)
161 fi
162 AC_SUBST(THREADING_CFLAGS)
163 CPPFLAGS="${CPPFLAGS} $THREADING_CFLAGS"
164
165 dnl get rid of the -export-dynamic stuff from the configure flags ...
166 export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
167
168 dnl glib
169 AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(maybe you want the pygobject-2-4 branch?)],gobject $extra_mods)
170 if test -n "$export_dynamic"; then
171   GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"`
172 fi
173 PYTHON_BASENAME=`basename $PYTHON`
174 AC_SUBST([PYTHON_BASENAME])
175
176 AS_AC_EXPAND(DATADIR, $datadir)
177
178 dnl libffi
179 PKG_CHECK_MODULES(FFI, libffi >= 3.0)
180 LIBFFI_PC=libffi
181
182 AC_SUBST(FFI_CFLAGS)
183 AC_SUBST(FFI_LIBS)
184 AC_SUBST(LIBFFI_PC)
185
186 dnl gio
187 PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version)
188
189 AC_ARG_ENABLE(cairo,
190     AS_HELP_STRING([--enable-cairo],[Enable Cairo bindings using introspection information]),
191     enable_cairo=$enableval,
192     enable_cairo=yes)
193
194 PKG_CHECK_MODULES(GI,
195     glib-2.0 >= glib_required_version
196     gobject-introspection-1.0 >= introspection_required_version
197 )
198
199 GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
200 AC_SUBST(GI_DATADIR)
201
202 if test "$enable_cairo" != no; then
203     PKG_CHECK_MODULES(CAIRO, cairo cairo-gobject)
204
205     if test $build_py3k = true; then
206         PKG_CHECK_MODULES(PYCAIRO,
207             py3cairo >= py3cairo_required_version
208         )
209     else
210         PKG_CHECK_MODULES(PYCAIRO,
211             pycairo >= py2cairo_required_version
212         )
213     fi
214 fi
215 AM_CONDITIONAL(ENABLE_CAIRO, test "$enable_cairo" = "yes")
216
217 AC_ARG_WITH(common,
218     AS_HELP_STRING([--without-common],
219         [For package maintainers: do not install Python version independent files]),
220     with_common=$enableval,
221     with_common=yes)
222 AM_CONDITIONAL(WITH_COMMON, test "$with_common" = "yes")
223
224 INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
225 INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
226
227 AC_SUBST(INTROSPECTION_SCANNER)
228 AC_SUBST(INTROSPECTION_COMPILER)
229
230 # compiler warnings, errors, required cflags, and code coverage support
231 GNOME_COMPILE_WARNINGS([maximum])
232 AC_MSG_CHECKING(for Gnome code coverage support)
233 m4_ifdef([GNOME_CODE_COVERAGE],
234          [AC_MSG_RESULT(yes)
235           GNOME_CODE_COVERAGE],
236          [AC_MSG_RESULT(no)
237           GNOME_CODE_COVERAGE_RULES=''
238           AC_SUBST([GNOME_CODE_COVERAGE_RULES])
239           enable_code_coverage="no"])
240
241 if test "x$GCC" = "xyes"; then
242   JH_ADD_CFLAG([-Wall])
243   JH_ADD_CFLAG([-Werror=unused-variable])
244   JH_ADD_CFLAG([-fno-strict-aliasing])
245   JH_ADD_CFLAG([-Werror=declaration-after-statement])
246 fi
247
248 CFLAGS="$CFLAGS $WARN_CFLAGS $CODE_COVERAGE_CFLAGS"
249 LDFLAGS="$LDFLAGS $CODE_COVERAGE_CFLAGS"
250
251 AC_CONFIG_FILES(
252   Makefile
253   pygobject-3.0.pc
254   pygobject-3.0-uninstalled.pc
255   gi/Makefile
256   gi/repository/Makefile
257   gi/overrides/Makefile
258   gi/_gobject/Makefile
259   examples/Makefile
260   tests/Makefile
261   pygtkcompat/Makefile
262   PKG-INFO)
263 AC_OUTPUT
264
265 AC_MSG_RESULT([
266         pygobject $VERSION
267
268         Using python interpreter:       $PYTHON
269         cairo support:                  $enable_cairo
270         thread support:                 $enable_thread
271         code coverage support:          $enable_code_coverage
272 ])
273