Fix linking against libpython
[platform/upstream/gobject-introspection.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 dnl the gi version number
5 m4_define(gi_major_version, 1)
6 m4_define(gi_minor_version, 29)
7 m4_define(gi_micro_version, 18)
8 m4_define(gi_version, gi_major_version.gi_minor_version.gi_micro_version)
9
10 AC_PREREQ([2.63])
11 AC_INIT([gobject-introspection],
12         [gi_version],
13         [http://bugzilla.gnome.org/enter_bug.cgi?product=glib&component=introspection],
14         [gobject-introspection])
15
16 AC_CONFIG_HEADER([config.h])
17 AC_CONFIG_MACRO_DIR([m4])
18 AC_CONFIG_AUX_DIR([build-aux])
19
20 AM_INIT_AUTOMAKE([1.11 tar-ustar dist-xz no-dist-gzip foreign -Wno-portability])
21 AM_MAINTAINER_MODE([enable])
22
23 AM_SILENT_RULES([yes])
24
25 # Check for Win32
26 AC_CANONICAL_HOST
27 case "$host" in
28 *-*-mingw*)
29         os_win32=yes
30         ;;
31 *)
32         os_win32=no
33         ;;
34 esac
35 AM_CONDITIONAL(OS_WIN32, [test "x$os_win32" = "xyes"])
36
37 # Checks for programs.
38 AC_PROG_CC
39 AM_PROG_CC_C_O
40
41 # Initialize libtool
42 LT_PREREQ([2.2])
43 LT_INIT
44
45 PKG_PROG_PKG_CONFIG
46
47 AC_PROG_LEX
48 if test "$LEX" = :; then
49         AC_MSG_ERROR([flex not found but required])
50 fi
51
52 AC_CHECK_PROGS(YACC, 'bison -y', :)
53 if test "$YACC" = :; then
54         AC_MSG_ERROR([bison not found but required])
55 fi
56
57
58 changequote(,)dnl
59 ensureflag() {
60   flag="$1"; shift
61   result="$@"
62
63   case " ${result} " in
64   *[\ \ ]${flag}[\ \    ]*) ;;
65   *) result="${flag} ${result}" ;;
66   esac
67
68   echo ${result}
69 }
70 changequote([,])dnl
71
72 if test "$GCC" = "yes"; then
73     for flag in -Wall -Wchar-subscripts -Wmissing-declarations \
74         -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align \
75         -Wsign-compare -fno-strict-aliasing;
76     do
77         CFLAGS="$(ensureflag $flag $CFLAGS)"
78     done
79 fi
80
81 # Checks for libraries.
82 AC_CHECK_LIB([dl], [dlopen])
83
84 AC_MSG_CHECKING(for the suffix of shared libraries)
85 # libtool variables are immediately available since 2.0, prior to that we need
86 # to call libtool --config explicitly
87 if test "x$shrext_cmds" = x; then
88     shrext_cmds=`SED=$SED ./libtool --config | grep '^shrext_cmds='`
89     eval $shrext_cmds
90 fi
91 eval std_shrext=$shrext_cmds
92 # chop the initial dot
93 SHLIB_SUFFIX=${std_shrext#.}
94 AC_MSG_RESULT(.$SHLIB_SUFFIX)
95 # any reason it may fail?
96 if test "x$SHLIB_SUFFIX" = x; then
97         AC_MSG_ERROR(Cannot determine shared library suffix from libtool)
98 fi
99 AC_DEFINE_UNQUOTED([SHLIB_SUFFIX], "$SHLIB_SUFFIX", [Define to the platform's shared library suffix])
100
101 # Copied from dbus configure.in
102 #### find the actual value for $prefix that we'll end up with
103 ##   (I know this is broken and should be done in the Makefile, but
104 ##    that's a major pain and almost nobody actually seems to care)
105 AS_AC_EXPAND(EXPANDED_LOCALSTATEDIR, "$localstatedir")
106 AS_AC_EXPAND(EXPANDED_SYSCONFDIR, "$sysconfdir")
107 AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir")
108 AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir")
109 AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir")
110 AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir")
111
112 #### Directory to install the libexec binaries
113 GOBJECT_INTROSPECTION_LIBDIR="$EXPANDED_LIBDIR"
114 AC_SUBST(GOBJECT_INTROSPECTION_LIBDIR)
115 AC_DEFINE_UNQUOTED(GOBJECT_INTROSPECTION_LIBDIR,"$GOBJECT_INTROSPECTION_LIBDIR", [Directory prefix for typelib installation])
116
117 #### Directory to install the gir files
118 GIR_SUFFIX="gir-1.0"
119 AC_SUBST(GIR_SUFFIX)
120 AC_DEFINE_UNQUOTED(GIR_SUFFIX, "$GIR_SUFFIX", [Name of the gir directory])
121
122 GIR_DIR="$EXPANDED_DATADIR/$GIR_SUFFIX"
123 AC_SUBST(GIR_DIR)
124 AC_DEFINE_UNQUOTED(GIR_DIR, "$GIR_DIR", [Director prefix for gir installation])
125
126 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.29.7])
127 PKG_CHECK_MODULES(GOBJECT, [gobject-2.0])
128 PKG_CHECK_MODULES(GIO, [gio-2.0])
129 PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0], have_gio_unix=true, have_gio_unix=false)
130 AM_CONDITIONAL(HAVE_GIO_UNIX, test x$have_gio_unix = xtrue)
131
132 AC_ARG_ENABLE(tests,[  --disable-tests           disable test libraries ], enable_tests=$enableval,enable_tests=yes)
133 have_cairo=no
134 PKG_CHECK_MODULES(CAIRO, [cairo], have_cairo=yes, have_cairo=no)
135 if test x$have_cairo != xyes && test x$enable_tests != xno; then
136   AC_MSG_ERROR([Tests enabled but cairo not found; pass --disable-tests or install cairo])
137 fi
138
139 have_cairo_gobject=no
140 if test x$have_cairo = xyes; then
141   PKG_CHECK_MODULES(CAIRO_GOBJECT, [cairo-gobject], have_cairo_gobject=yes, have_cairo_gobject=no)
142 fi
143
144 if test x$have_cairo_gobject = xyes; then
145   case "$host" in
146     *-*-darwin*)
147       CAIRO_SHARED_LIBRARY="libcairo-gobject.2.dylib"
148       ;;
149     *-*-mingw*)
150       CAIRO_SHARED_LIBRARY="libcairo-gobject-2.dll"
151       ;;
152     *)
153       CAIRO_SHARED_LIBRARY="libcairo-gobject.so.2"
154       ;;
155   esac
156   CAIRO_GIR_PACKAGE="cairo-gobject"
157 elif test x$have_cairo = xyes; then
158   case "$host" in
159     *-*-darwin*)
160       CAIRO_SHARED_LIBRARY="libcairo.2.dylib"
161       ;;
162     *-*-mingw*)
163       CAIRO_SHARED_LIBRARY="libcairo-2.dll"
164       ;;
165     *)
166       CAIRO_SHARED_LIBRARY="libcairo.so.2"
167       ;;
168   esac
169   CAIRO_GIR_PACKAGE="cairo"
170 fi
171 AC_SUBST(CAIRO_SHARED_LIBRARY)
172 AC_SUBST(CAIRO_GIR_PACKAGE)
173
174 AM_CONDITIONAL(BUILD_TESTS, test x$enable_tests != xno)
175 AM_CONDITIONAL(HAVE_CAIRO, test x$have_cairo != xno)
176 AM_CONDITIONAL(HAVE_CAIRO_GOBJECT, test x$have_cairo_gobject != xno)
177
178 PKG_CHECK_MODULES(SCANNER, [gobject-2.0 gthread-2.0 gio-2.0])
179
180 dnl libffi
181 PKG_CHECK_MODULES(FFI, libffi, have_ffi_pkgconfig=yes, have_ffi_pkgconfig=no)
182 FFI_PC_CFLAGS=""
183 FFI_PC_LIBS=""
184 FFI_PC_PACKAGES=""
185 if test x"$have_ffi_pkgconfig" = xyes ; then
186     FFI_PC_PACKAGES="libffi"
187 else
188   AC_MSG_CHECKING(for ffi.h)
189
190   AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <ffi.h>]])],
191                     [have_ffi_h=yes],[have_ffi_h=no])
192   if test x"$have_ffi_h" = x"yes"; then
193
194     save_LIBS=$LIBS
195     if test x"$with_ffi" = x"yes" || test x"$with_ffi" = x"auto"; then
196       other_LIBS=
197     else
198       other_LIBS=$with_ffi
199     fi
200
201     AC_SEARCH_LIBS(ffi_call,ffi,,AC_MSG_ERROR([libffi not found]),$other_LIBS)
202     if test x"$ac_cv_search_ffi_call" = x"none required" ; then
203       FFI_LIBS=$other_LIBS
204     else
205       FFI_LIBS="$ac_cv_search_ffi_call $other_LIBS"
206     fi
207
208     LIBS=$save_LIBS
209   fi
210   if test x"$have_ffi_h" != x"yes" ; then
211     AC_MSG_ERROR([ffi.h not found])
212   fi
213
214   FFI_PC_LIBS=$FFI_LIBS
215   FFI_PC_CFLAGS=$FFI_CFLAGS
216   FFI_CFLAGS=
217   AC_MSG_RESULT([$have_ffi_h])
218   AC_SUBST(FFI_LIBS)
219   AC_SUBST(FFI_CFLAGS)
220 fi
221 AC_SUBST(FFI_PC_CFLAGS)
222 AC_SUBST(FFI_PC_LIBS)
223 AC_SUBST(FFI_PC_PACKAGES)
224
225 AC_CHECK_SIZEOF(char)
226 AC_CHECK_SIZEOF(short)
227 AC_CHECK_SIZEOF(int)
228 AC_CHECK_SIZEOF(long)
229
230 PKG_CHECK_MODULES(GIREPO, [glib-2.0 >= 2.24.0 gobject-2.0 gmodule-2.0 gio-2.0])
231
232 # if we ever remove manual check for ffi and require .pc file, then
233 # just put libffi in the PKG_CHECK_MODULES(GIREPO) deps
234 GIREPO_LIBS="$GIREPO_LIBS $GCOV_LIBS $FFI_LIBS"
235 GIREPO_CFLAGS="$GIREPO_CFLAGS $FFI_CFLAGS"
236
237 GIREPO_CFLAGS="$GIREPO_CFLAGS $GCOV_CFLAGS"
238
239 # gtk-doc
240 GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
241
242 # Checks for header files.
243 AC_HEADER_STDC
244 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h])
245
246 # Checks for typedefs, structures, and compiler characteristics.
247 AC_C_CONST
248
249 # Checks for library functions.
250 AC_FUNC_STRTOD
251 AC_CHECK_FUNCS([memchr strchr strspn strstr strtol strtoull])
252 AC_CHECK_FUNCS([backtrace backtrace_symbols])
253
254 # Python
255 AM_PATH_PYTHON([2.5])
256 case "$host" in
257 *-*-mingw*)
258         # Change backslashes to forward slashes in pyexecdir to avoid
259         # quoting issues
260         pyexecdir=`echo $pyexecdir | tr '\\\\' '/'`
261         ;;
262 esac
263 AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
264 if test "x$os_win32" = "xyes"; then
265   AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.]))
266 fi
267
268 # Glib documentation
269
270 GLIBSRC=
271 AC_MSG_CHECKING([for glib source directory to use for documentation])
272
273 AC_ARG_WITH(glib-src,
274         [  --with-glib-src=PATH    Source directory for glib - needed to add docs to gir],
275         GLIBSRC=$withval
276
277 AM_CONDITIONAL(WITH_GLIBSRC, test x"$GLIBSRC" != x)
278 AC_SUBST(GLIBSRC)
279 AC_MSG_RESULT([$GLIBSRC])
280
281
282
283 AC_CONFIG_FILES([
284 Makefile
285 m4/Makefile
286 tests/Makefile
287 tests/offsets/Makefile
288 tests/scanner/Makefile
289 tests/repository/Makefile
290 tests/warn/Makefile
291 tests/doctool/Makefile
292 docs/Makefile
293 docs/reference/Makefile
294 gobject-introspection-1.0.pc
295 gobject-introspection-no-export-1.0.pc])
296 AC_OUTPUT