Add Gio Unix bits to the Gio.gir if available
[gnome.gobject-introspection] / 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, 0)
6 m4_define(gi_minor_version, 6)
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.59)
11 AC_INIT(gobject-introspection, gi_version,
12         http://bugzilla.gnome.org/enter_bug.cgi?product=glib&component=introspection)
13 AM_INIT_AUTOMAKE([1.7 -Wno-portability])
14 AM_MAINTAINER_MODE
15 AC_CONFIG_HEADER([config.h])
16
17 AC_CONFIG_MACRO_DIR([m4])
18
19 # Check for Win32
20 AC_CANONICAL_HOST
21 AC_MSG_CHECKING([for Win32])
22 case "$host" in
23 *-*-mingw*)
24         os_win32=yes
25         ;;
26 *)
27         os_win32=no
28         ;;
29 esac
30 AC_MSG_RESULT([$os_win32])
31 AM_CONDITIONAL(OS_WIN32, [test "$os_win32" = "yes"])
32
33 # Checks for programs.
34 AC_PROG_CC
35 AM_PROG_CC_C_O
36 AC_PROG_LIBTOOL
37 PKG_PROG_PKG_CONFIG
38
39 AC_PROG_LEX
40 if test "$LEX" = :; then
41         AC_MSG_ERROR([flex not found but required])
42 fi
43
44 AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc, :)
45 if test "$YACC" = :; then
46         AC_MSG_ERROR([bison not found but required])
47 fi
48
49 changequote(,)dnl
50 ensureflag() {
51   flag="$1"; shift
52   result="$@"
53
54   case " ${result} " in
55   *[\ \ ]${flag}[\ \    ]*) ;;
56   *) result="${flag} ${result}" ;;
57   esac
58
59   echo ${result}
60 }
61 changequote([,])dnl
62
63 if test "$GCC" = "yes"; then
64     for flag in -Wall -Wchar-subscripts -Wmissing-declarations \
65         -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align \
66         -Wsign-compare -fno-strict-aliasing;
67     do
68         CFLAGS="$(ensureflag $flag $CFLAGS)"
69     done
70 fi
71
72 # Checks for libraries.
73 GI_ENABLE_GCOV
74
75 AC_CHECK_LIB([dl], [dlopen])
76
77 AC_MSG_CHECKING(for the suffix of shared libraries)
78 # libtool variables are immediately available since 2.0, prior to that we need
79 # to call libtool --config explicitly
80 if test "x$shrext_cmds" = x; then
81     shrext_cmds=`SED=$SED ./libtool --config | grep '^shrext_cmds='`
82     eval $shrext_cmds
83 fi
84 eval std_shrext=$shrext_cmds
85 # chop the initial dot
86 SHLIB_SUFFIX=${std_shrext#.}
87 AC_MSG_RESULT(.$SHLIB_SUFFIX)
88 # any reason it may fail?
89 if test "x$SHLIB_SUFFIX" = x; then
90         AC_MSG_ERROR(Cannot determine shared library suffix from libtool)
91 fi
92 AC_DEFINE_UNQUOTED([SHLIB_SUFFIX], "$SHLIB_SUFFIX", [Define to the platform's shared library suffix])
93
94 # Copied from dbus configure.in
95 #### find the actual value for $prefix that we'll end up with
96 ##   (I know this is broken and should be done in the Makefile, but
97 ##    that's a major pain and almost nobody actually seems to care)
98 AS_AC_EXPAND(EXPANDED_LOCALSTATEDIR, "$localstatedir")
99 AS_AC_EXPAND(EXPANDED_SYSCONFDIR, "$sysconfdir")
100 AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir")
101 AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir")
102 AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir")
103 AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir")
104
105 #### Directory to install the libexec binaries
106 GOBJECT_INTROSPECTION_LIBDIR="$EXPANDED_LIBDIR"
107 AC_SUBST(GOBJECT_INTROSPECTION_LIBDIR)
108 AC_DEFINE_UNQUOTED(GOBJECT_INTROSPECTION_LIBDIR,"$GOBJECT_INTROSPECTION_LIBDIR", [Directory prefix for typelib installation])
109
110 PKG_CHECK_MODULES(GOBJECT, [gobject-2.0 gio-2.0])
111 PKG_CHECK_MODULES(GTHREAD, [gthread-2.0])
112 PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0], have_gio_unix=true, have_gio_unix=false)
113 AM_CONDITIONAL(HAVE_GIO_UNIX, test x$have_gio_unix = xtrue)
114
115 PKG_CHECK_MODULES(SCANNER, [gobject-2.0 gthread-2.0 gio-2.0])
116
117 dnl libffi
118 PKG_CHECK_MODULES(FFI, libffi, have_ffi_pkgconfig=yes, have_ffi_pkgconfig=no)
119
120 if test x"$have_ffi_pkgconfig" = xno ; then
121   AC_MSG_CHECKING(for ffi.h)
122
123   AC_TRY_CPP([#include <ffi.h>], have_ffi_h=yes, have_ffi_h=no)
124   if test x"$have_ffi_h" = x"yes"; then
125
126     save_LIBS=$LIBS
127     if test x"$with_ffi" = x"yes" || test x"$with_ffi" = x"auto"; then
128       other_LIBS=
129     else
130       other_LIBS=$with_ffi
131     fi
132
133     AC_SEARCH_LIBS(ffi_call,ffi,,AC_MSG_ERROR([libffi not found]),$other_LIBS)
134     if test x"$ac_cv_search_ffi_call" = x"none required" ; then
135       FFI_LIBS=$other_LIBS
136     else
137       FFI_LIBS="$ac_cv_search_ffi_call $other_LIBS"
138     fi
139
140     LIBS=$save_LIBS
141   fi
142   if test x"$have_ffi_h" != x"yes" ; then
143     AC_MSG_ERROR([ffi.h not found])
144   fi
145
146   FFI_CFLAGS=
147
148   AC_MSG_RESULT([$have_ffi_h])
149   AC_SUBST(FFI_LIBS)
150   AC_SUBST(FFI_CFLAGS)
151 fi
152
153 AC_CHECK_SIZEOF(time_t, [], [#include <time.h>])
154
155 PKG_CHECK_MODULES(GIREPO, [glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0])
156
157 # if we ever remove manual check for ffi and require .pc file, then 
158 # just put libffi in the PKG_CHECK_MODULES(GIREPO) deps
159 GIREPO_LIBS="$GIREPO_LIBS $GCOV_LIBS $FFI_LIBS"
160 GIREPO_CFLAGS="$GIREPO_CFLAGS $FFI_CFLAGS"
161
162 GIREPO_CFLAGS="$GIREPO_CFLAGS $GCOV_CFLAGS"
163
164 # Checks for header files.
165 AC_HEADER_STDC
166 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h])
167
168 # Checks for typedefs, structures, and compiler characteristics.
169 AC_C_CONST
170
171 # Checks for library functions.
172 AC_FUNC_STRTOD
173 AC_CHECK_FUNCS([memchr strchr strspn strstr strtol strtoull])
174 AC_CHECK_FUNCS([backtrace backtrace_symbols])
175
176 # Python
177
178 AC_MSG_CHECKING([whether Python support is requested])
179
180 AM_PATH_PYTHON([2.5])
181 case "$host" in
182 *-*-mingw*)
183         # Change backslashes to forward slashes in pyexecdir to avoid
184         # quoting issues
185         pyexecdir=`echo $pyexecdir | tr '\\\\' '/'`
186         ;;
187 esac
188 AM_CHECK_PYTHON_HEADERS
189
190 AC_CONFIG_FILES([
191 Makefile
192 gir/Makefile
193 girepository/Makefile
194 giscanner/Makefile
195 giscanner/config.py
196 m4/Makefile
197 tools/Makefile
198 tests/Makefile
199 tests/invoke/Makefile
200 tests/offsets/Makefile
201 tests/scanner/Makefile
202 tests/repository/Makefile
203 tests/everything/Makefile
204 gobject-introspection-1.0.pc])
205 AC_OUTPUT