Imported Upstream version 1.40.0
[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, 40)
7 m4_define(gi_micro_version, 0)
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 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.36.0])
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 AM_PATH_PYTHON([2.6])
255 case "$host" in
256 *-*-mingw*)
257         # Change backslashes to forward slashes in pyexecdir to avoid
258         # quoting issues
259         pyexecdir=`echo $pyexecdir | tr '\\\\' '/'`
260         ;;
261 esac
262 AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
263 if test "x$os_win32" = "xyes"; then
264   AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.]))
265 fi
266
267 dnl Not enabled by default until 3.6 cycle when we can propose mako as
268 dnl an external dependency
269 AC_ARG_ENABLE(doctool,[  --disable-doctool           disable g-ir-doctool ],,enable_doctool=auto)
270 AS_IF([ test x$enable_doctool != xno], [
271    AM_CHECK_PYMOD(mako,,have_python_mako=yes,have_python_mako=no)
272 ])
273 AS_IF([ test x$enable_doctool = xauto && test x$have_python_mako = xyes ],
274       [ enable_doctool=yes ],
275       [ test x$enable_doctool = xauto && test x$have_python_mako = xno ],
276       [ enable_doctool=no ],
277       [ test x$enable_doctool = xyes && test x$have_python_mako = xno ],
278       [ AC_MSG_ERROR([Python mako module not found]) ])
279 AM_CONDITIONAL(BUILD_DOCTOOL, test x$enable_doctool != xno)
280
281 # Glib documentation
282
283 GLIBSRC=
284 AC_MSG_CHECKING([for glib source directory to use for documentation])
285
286 AC_ARG_WITH(glib-src,
287         [  --with-glib-src=PATH    Source directory for glib - needed to add docs to gir],
288         GLIBSRC=$withval
289
290 AM_CONDITIONAL(WITH_GLIBSRC, test x"$GLIBSRC" != x)
291 AC_SUBST(GLIBSRC)
292 AC_MSG_RESULT([$GLIBSRC])
293
294 dnl
295 dnl Check for -Bsymbolic-functions linker flag used to avoid
296 dnl intra-library PLT jumps, if available.
297 dnl
298 AC_ARG_ENABLE(Bsymbolic,
299               [AS_HELP_STRING([--disable-Bsymbolic],
300                               [avoid linking with -Bsymbolic])],,
301               [SAVED_LDFLAGS="${LDFLAGS}"
302                AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
303                LDFLAGS=-Wl,-Bsymbolic-functions
304                AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int main (void) { return 0; }]])],
305                               [AC_MSG_RESULT(yes)
306                                enable_Bsymbolic=yes],
307                               [AC_MSG_RESULT(no)
308                                enable_Bsymbolic=no])
309                LDFLAGS="${SAVED_LDFLAGS}"])
310
311 if test "x${enable_Bsymbolic}" = "xyes"; then
312   EXTRA_LINK_FLAGS=-Wl,-Bsymbolic-functions
313 fi
314
315 AC_SUBST(EXTRA_LINK_FLAGS)
316
317 AC_CONFIG_FILES([
318 Makefile
319 tests/Makefile
320 tests/offsets/Makefile
321 tests/scanner/Makefile
322 tests/scanner/annotationparser/Makefile
323 tests/repository/Makefile
324 tests/warn/Makefile
325 docs/Makefile
326 docs/reference/Makefile
327 docs/reference/version.xml
328 gobject-introspection-1.0.pc
329 gobject-introspection-no-export-1.0.pc
330 config.h.win32
331 build/Makefile
332 build/win32/Makefile
333 build/win32/vs9/Makefile
334 build/win32/vs10/Makefile])
335 AC_OUTPUT