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