Update annotations from glib git
[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, 35)
7 m4_define(gi_micro_version, 2)
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 AC_PROG_MKDIR_P
41
42 # Initialize libtool
43 LT_PREREQ([2.2])
44 LT_INIT
45
46 PKG_PROG_PKG_CONFIG
47
48 AC_PROG_LEX
49 if test "$LEX" = :; then
50         AC_MSG_ERROR([flex not found but required])
51 fi
52
53 AC_CHECK_PROGS(YACC, 'bison -y', :)
54 if test "$YACC" = :; then
55         AC_MSG_ERROR([bison not found but required])
56 fi
57
58
59 changequote(,)dnl
60 ensureflag() {
61   flag="$1"; shift
62   result="$@"
63
64   case " ${result} " in
65   *[\ \ ]${flag}[\ \    ]*) ;;
66   *) result="${flag} ${result}" ;;
67   esac
68
69   echo ${result}
70 }
71 changequote([,])dnl
72
73 if test "$GCC" = "yes"; then
74     for flag in -Wall -Wchar-subscripts -Wmissing-declarations \
75         -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align \
76         -Wsign-compare -fno-strict-aliasing;
77     do
78         CFLAGS="$(ensureflag $flag $CFLAGS)"
79     done
80 fi
81
82 # Checks for libraries.
83 AC_CHECK_LIB([dl], [dlopen])
84
85 AC_MSG_CHECKING(for the suffix of shared libraries)
86 # libtool variables are immediately available since 2.0, prior to that we need
87 # to call libtool --config explicitly
88 if test "x$shrext_cmds" = x; then
89     shrext_cmds=`SED=$SED ./libtool --config | grep '^shrext_cmds='`
90     eval $shrext_cmds
91 fi
92 eval std_shrext=$shrext_cmds
93 # chop the initial dot
94 SHLIB_SUFFIX=${std_shrext#.}
95 AC_MSG_RESULT(.$SHLIB_SUFFIX)
96 # any reason it may fail?
97 if test "x$SHLIB_SUFFIX" = x; then
98         AC_MSG_ERROR(Cannot determine shared library suffix from libtool)
99 fi
100 AC_DEFINE_UNQUOTED([SHLIB_SUFFIX], "$SHLIB_SUFFIX", [Define to the platform's shared library suffix])
101
102 # Copied from dbus configure.in
103 #### find the actual value for $prefix that we'll end up with
104 ##   (I know this is broken and should be done in the Makefile, but
105 ##    that's a major pain and almost nobody actually seems to care)
106 AS_AC_EXPAND(EXPANDED_LOCALSTATEDIR, "$localstatedir")
107 AS_AC_EXPAND(EXPANDED_SYSCONFDIR, "$sysconfdir")
108 AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir")
109 AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir")
110 AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir")
111 AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir")
112
113 #### Directory to install the libexec binaries
114 GOBJECT_INTROSPECTION_LIBDIR="$EXPANDED_LIBDIR"
115 AC_SUBST(GOBJECT_INTROSPECTION_LIBDIR)
116 AC_DEFINE_UNQUOTED(GOBJECT_INTROSPECTION_LIBDIR,"$GOBJECT_INTROSPECTION_LIBDIR", [Directory prefix for typelib installation])
117
118 #### Directory to install the gir files
119 GIR_SUFFIX="gir-1.0"
120 AC_SUBST(GIR_SUFFIX)
121 AC_DEFINE_UNQUOTED(GIR_SUFFIX, "$GIR_SUFFIX", [Name of the gir directory])
122
123 GIR_DIR="$EXPANDED_DATADIR/$GIR_SUFFIX"
124 AC_SUBST(GIR_DIR)
125 AC_DEFINE_UNQUOTED(GIR_DIR, "$GIR_DIR", [Director prefix for gir installation])
126
127 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.35.0])
128 PKG_CHECK_MODULES(GOBJECT, [gobject-2.0])
129 PKG_CHECK_MODULES(GMODULE, [gmodule-2.0])
130 PKG_CHECK_MODULES(GIO, [gio-2.0])
131 PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0], have_gio_unix=true, have_gio_unix=false)
132 AM_CONDITIONAL(HAVE_GIO_UNIX, test x$have_gio_unix = xtrue)
133
134 AC_ARG_ENABLE(tests,
135         AS_HELP_STRING([--disable-tests], [disable test libraries]),
136         enable_tests=$enableval,
137         enable_tests=maybe)
138
139 AS_IF([test x${enable_tests} != xno], [
140   PKG_CHECK_MODULES(CAIRO, [cairo cairo-gobject], have_cairo=yes, have_cairo=no)
141   AS_IF([test x$have_cairo != xyes], [
142     AS_IF([ test x$enable_tests = xmaybe ], [
143       enable_tests=no
144     ], [
145       AC_MSG_ERROR([Tests enabled but cairo not found; pass --disable-tests or install cairo])
146     ])
147   ], [
148     enable_tests=yes
149   ])
150 ])
151 AM_CONDITIONAL(BUILD_TESTS, test x$enable_tests != xno)
152
153 case "$host" in
154   *-*-darwin*)
155     CAIRO_SHARED_LIBRARY="libcairo-gobject.2.dylib"
156     ;;
157   *-*-mingw*)
158     CAIRO_SHARED_LIBRARY="libcairo-gobject-2.dll"
159     ;;
160   *-*-openbsd*)
161     CAIRO_SHARED_LIBRARY="libcairo-gobject.so"
162     ;;
163   *)
164     CAIRO_SHARED_LIBRARY="libcairo-gobject.so.2"
165     ;;
166 esac
167 CAIRO_GIR_PACKAGE="cairo-gobject"
168
169 AC_SUBST(CAIRO_SHARED_LIBRARY)
170 AC_SUBST(CAIRO_GIR_PACKAGE)
171
172
173 PKG_CHECK_MODULES(SCANNER, [gobject-2.0 gio-2.0])
174
175 dnl libffi
176 PKG_CHECK_MODULES(FFI, libffi, have_ffi_pkgconfig=yes, have_ffi_pkgconfig=no)
177 FFI_PC_CFLAGS=""
178 FFI_PC_LIBS=""
179 FFI_PC_PACKAGES=""
180 if test x"$have_ffi_pkgconfig" = xyes ; then
181     FFI_PC_PACKAGES="libffi"
182 else
183   AC_MSG_CHECKING(for ffi.h)
184
185   AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <ffi.h>]])],
186                     [have_ffi_h=yes],[have_ffi_h=no])
187   if test x"$have_ffi_h" = x"yes"; then
188
189     save_LIBS=$LIBS
190     if test x"$with_ffi" = x"yes" || test x"$with_ffi" = x"auto"; then
191       other_LIBS=
192     else
193       other_LIBS=$with_ffi
194     fi
195
196     AC_SEARCH_LIBS(ffi_call,ffi,,AC_MSG_ERROR([libffi not found]),$other_LIBS)
197     if test x"$ac_cv_search_ffi_call" = x"none required" ; then
198       FFI_LIBS=$other_LIBS
199     else
200       FFI_LIBS="$ac_cv_search_ffi_call $other_LIBS"
201     fi
202
203     LIBS=$save_LIBS
204   fi
205   if test x"$have_ffi_h" != x"yes" ; then
206     AC_MSG_ERROR([ffi.h not found])
207   fi
208
209   FFI_PC_LIBS=$FFI_LIBS
210   FFI_PC_CFLAGS=$FFI_CFLAGS
211   FFI_CFLAGS=
212   AC_MSG_RESULT([$have_ffi_h])
213   AC_SUBST(FFI_LIBS)
214   AC_SUBST(FFI_CFLAGS)
215 fi
216 AC_SUBST(FFI_PC_CFLAGS)
217 AC_SUBST(FFI_PC_LIBS)
218 AC_SUBST(FFI_PC_PACKAGES)
219
220 AC_CHECK_SIZEOF(char)
221 AC_CHECK_SIZEOF(short)
222 AC_CHECK_SIZEOF(int)
223 AC_CHECK_SIZEOF(long)
224
225 PKG_CHECK_MODULES(GIREPO, [glib-2.0 >= 2.24.0 gobject-2.0 gmodule-2.0 gio-2.0])
226
227 # if we ever remove manual check for ffi and require .pc file, then
228 # just put libffi in the PKG_CHECK_MODULES(GIREPO) deps
229 GIREPO_LIBS="$GIREPO_LIBS $GCOV_LIBS $FFI_LIBS"
230 GIREPO_CFLAGS="$GIREPO_CFLAGS $FFI_CFLAGS"
231
232 GIREPO_CFLAGS="$GIREPO_CFLAGS $GCOV_CFLAGS"
233
234 # gtk-doc
235 # gtkdocize greps for ^GTK_DOC_CHECK and parses it, so you need to have
236 # it on it's own line.
237 m4_ifdef([GTK_DOC_CHECK], [
238 GTK_DOC_CHECK([1.15], [--flavour no-tmpl])
239 ],[
240 AM_CONDITIONAL([ENABLE_GTK_DOC],[false])
241 ])
242
243 # Checks for header files.
244 AC_HEADER_STDC
245 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h])
246
247 # Checks for typedefs, structures, and compiler characteristics.
248 AC_C_CONST
249
250 # Checks for library functions.
251 AC_FUNC_STRTOD
252 AC_CHECK_FUNCS([memchr strchr strspn strstr strtol strtoull])
253 AC_CHECK_FUNCS([backtrace backtrace_symbols])
254
255 # Python
256 AM_PATH_PYTHON([2.5])
257 case "$host" in
258 *-*-mingw*)
259         # Change backslashes to forward slashes in pyexecdir to avoid
260         # quoting issues
261         pyexecdir=`echo $pyexecdir | tr '\\\\' '/'`
262         ;;
263 esac
264 AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
265 if test "x$os_win32" = "xyes"; then
266   AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.]))
267 fi
268
269 dnl Not enabled by default until 3.6 cycle when we can propose mako as
270 dnl an external dependency
271 AC_ARG_ENABLE(doctool,[  --enable-doctool           enable g-ir-doctool ], enable_doctool=$enableval,enable_doctool=no)
272 if test x$enable_doctool != xno; then
273    AM_CHECK_PYMOD(mako,,,[AC_MSG_ERROR(Could not find python module: mako)])
274 fi
275 AM_CONDITIONAL(BUILD_DOCTOOL, test x$enable_doctool != xno)
276
277 # Glib documentation
278
279 GLIBSRC=
280 AC_MSG_CHECKING([for glib source directory to use for documentation])
281
282 AC_ARG_WITH(glib-src,
283         [  --with-glib-src=PATH    Source directory for glib - needed to add docs to gir],
284         GLIBSRC=$withval
285
286 AM_CONDITIONAL(WITH_GLIBSRC, test x"$GLIBSRC" != x)
287 AC_SUBST(GLIBSRC)
288 AC_MSG_RESULT([$GLIBSRC])
289
290 dnl
291 dnl Check for -Bsymbolic-functions linker flag used to avoid
292 dnl intra-library PLT jumps, if available.
293 dnl
294 AC_ARG_ENABLE(Bsymbolic,
295               [AS_HELP_STRING([--disable-Bsymbolic],
296                               [avoid linking with -Bsymbolic])],,
297               [SAVED_LDFLAGS="${LDFLAGS}"
298                AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
299                LDFLAGS=-Wl,-Bsymbolic-functions
300                AC_TRY_LINK([], [int main (void) { return 0; }],
301                            AC_MSG_RESULT(yes)
302                            enable_Bsymbolic=yes,
303                            AC_MSG_RESULT(no)
304                            enable_Bsymbolic=no)
305                LDFLAGS="${SAVED_LDFLAGS}"])
306
307 if test "x${enable_Bsymbolic}" = "xyes"; then
308   EXTRA_LINK_FLAGS=-Wl,-Bsymbolic-functions
309 fi
310
311 AC_SUBST(EXTRA_LINK_FLAGS)
312
313 AC_CONFIG_FILES([
314 Makefile
315 m4/Makefile
316 tests/Makefile
317 tests/offsets/Makefile
318 tests/scanner/Makefile
319 tests/repository/Makefile
320 tests/warn/Makefile
321 tests/doctool/Makefile
322 docs/Makefile
323 docs/reference/Makefile
324 gobject-introspection-1.0.pc
325 gobject-introspection-no-export-1.0.pc
326 config.h.win32
327 build/Makefile
328 build/win32/Makefile
329 build/win32/vs9/Makefile
330 build/win32/vs10/Makefile])
331 AC_OUTPUT
332
333 echo "
334     gobject-introspection $VERSION
335     ===============
336
337     tests: ${enable_tests}
338 "