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