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