NEWS file update for upcoming release of GLib + GModule version 1.1.3,
[platform/upstream/glib.git] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(glist.c)
3
4 # Save this value here, since automake will set cflags later
5 cflags_set=${CFLAGS+set}
6
7 # The following version number definitions apply to GLib and GModule
8 # as a whole, so if changes occoured in either of them, they are both
9 # treated with the same interface and binary age.
10 #
11 # Making releases:
12 #   GLIB_MICRO_VERSION += 1;
13 #   GLIB_INTERFACE_AGE += 1;
14 #   GLIB_BINARY_AGE += 1;
15 # if any functions have been added, set GLIB_INTERFACE_AGE to 0.
16 # if backwards compatibility has been broken,
17 # set GLIB_BINARY_AGE and GLIB_INTERFACE_AGE to 0.
18 #
19 GLIB_MAJOR_VERSION=1
20 GLIB_MINOR_VERSION=1
21 GLIB_MICRO_VERSION=3
22 GLIB_INTERFACE_AGE=0
23 GLIB_BINARY_AGE=0
24 GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
25 AC_SUBST(GLIB_VERSION)
26
27 # libtool versioning
28 LT_RELEASE=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION
29 LT_CURRENT=`expr $GLIB_MICRO_VERSION - $GLIB_INTERFACE_AGE`
30 LT_REVISION=$GLIB_INTERFACE_AGE
31 LT_AGE=`expr $GLIB_BINARY_AGE - $GLIB_INTERFACE_AGE`
32 AC_SUBST(LT_RELEASE)
33 AC_SUBST(LT_CURRENT)
34 AC_SUBST(LT_REVISION)
35 AC_SUBST(LT_AGE)
36
37 VERSION=$GLIB_VERSION
38 PACKAGE=glib
39
40 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
41
42 # Specify a configuration file
43 AM_CONFIG_HEADER(glibconfig.h)
44
45 AC_DEFINE_UNQUOTED(GLIB_MAJOR_VERSION, $GLIB_MAJOR_VERSION)
46 AC_DEFINE_UNQUOTED(GLIB_MINOR_VERSION, $GLIB_MINOR_VERSION)
47 AC_DEFINE_UNQUOTED(GLIB_MICRO_VERSION, $GLIB_MICRO_VERSION)
48 AC_DEFINE_UNQUOTED(GLIB_INTERFACE_AGE, $GLIB_INTERFACE_AGE)
49 AC_DEFINE_UNQUOTED(GLIB_BINARY_AGE, $GLIB_BINARY_AGE)
50
51 dnl Initialize libtool
52 AM_PROG_LIBTOOL
53
54 dnl Initialize maintainer mode
55 AM_MAINTAINER_MODE
56
57 AC_CANONICAL_HOST
58
59 AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum)
60 AC_ARG_ENABLE(mem_check, [  --enable-mem-check=[no/yes] turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
61 AC_ARG_ENABLE(mem_profile, [  --enable-mem-profile=[no/yes] turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
62
63 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
64                     , enable_ansi=no)
65
66 AC_MSG_CHECKING(whether to enable memory checking)
67 if test "x$enable_mem_check" = "xyes"; then
68   AC_DEFINE(ENABLE_MEM_CHECK, 1)
69   AC_SUBST(ENABLE_MEM_CHECK)
70   AC_MSG_RESULT(yes)
71 else
72   AC_MSG_RESULT(no)
73 fi
74
75 AC_MSG_CHECKING(whether to enable memory profiling)
76 if test "x$enable_mem_profile" = "xyes"; then
77   AC_DEFINE(ENABLE_MEM_PROFILE, 1)
78   AC_SUBST(ENABLE_MEM_PROFILE)
79   AC_MSG_RESULT(yes)
80 else
81   AC_MSG_RESULT(no)
82 fi
83
84 if test "x$enable_debug" = "xyes"; then
85   test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
86   CFLAGS="$CFLAGS -DG_ENABLE_DEBUG"
87 else
88   if test "x$enable_debug" = "xno"; then
89     CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
90   fi
91 fi
92
93 AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
94
95 # Checks for programs.
96 AC_PROG_CC
97 AM_PROG_CC_STDC
98 AC_PROG_INSTALL
99
100 if eval "test x$GCC = xyes"; then
101   if eval test -z \"`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`\" ; then
102     CFLAGS="$CFLAGS -Wall"
103   fi
104
105   if eval "test x$enable_ansi = xyes"; then
106     if eval test -z \"`echo "$CFLAGS" | grep "\-ansi" 2> /dev/null`\" ; then
107       CFLAGS="$CFLAGS -ansi"
108     fi
109
110     if eval test -z \"`echo "$CFLAGS" | grep "\-pedantic" 2> /dev/null`\" ; then
111       CFLAGS="$CFLAGS -pedantic"
112     fi
113   fi
114 fi
115
116 dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
117 AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
118 glib_save_LIBS=$LIBS
119 LIBS="$LIBS -lm"
120 AC_TRY_RUN([#include <math.h>
121              int main (void) { return (log(1) != log(1.)); }],
122      AC_MSG_RESULT(none needed),
123      glib_save_CFLAGS=$CFLAGS
124      CFLAGS="$CFLAGS -std1"
125      AC_TRY_RUN([#include <math.h>
126                  int main (void) { return (log(1) != log(1.)); }],
127          AC_MSG_RESULT(-std1),
128          AC_MSG_RESULT()
129          CFLAGS=$glib_save_CFLAGS
130          AC_MSG_WARN(
131                 [No ANSI prototypes found in library. (-std1 didn't work.)])
132      )
133 )
134 LIBS=$glib_save_LIBS
135
136 dnl NeXTStep cc seems to need this
137 AC_MSG_CHECKING([for extra flags for POSIX compliance])
138 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
139   AC_MSG_RESULT(none needed),
140   glib_save_CFLAGS=$CFLAGS
141   CFLAGS="$CFLAGS -posix"
142   AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
143     AC_MSG_RESULT(-posix),
144     AC_MSG_RESULT()
145     CFLAGS=$glib_save_CFLAGS
146     AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
147
148 # Checks for header files.
149 AC_HEADER_STDC
150
151 # Checks for library functions.
152 AC_FUNC_VPRINTF
153
154 AC_CHECK_FUNCS(atexit on_exit)
155
156 AC_CHECK_SIZEOF(char)
157 AC_CHECK_SIZEOF(short)
158 AC_CHECK_SIZEOF(long)
159 AC_CHECK_SIZEOF(int)
160 AC_CHECK_SIZEOF(void *)
161 AC_CHECK_SIZEOF(long long)
162
163 dnl long doubles were not used, and a portability problem 
164 dnl AC_C_LONG_DOUBLE
165 AC_C_CONST
166
167 dnl AC_C_INLINE is useless to us since it bails out too early, we need to
168 dnl truely know which ones of `inline', `__inline' and `__inline__' are
169 dnl actually supported.
170 AC_MSG_CHECKING(for __inline)
171 AC_CACHE_VAL(glib_cv_has__inline,[
172         AC_TRY_RUN([
173         __inline int foo () { return 0; }
174         int main () { return foo (); }
175         ],
176         glib_cv_has__inline=yes
177         ,
178         glib_cv_has__inline=no
179         ,)
180 ])
181 AC_MSG_RESULT($glib_cv_has__inline)
182 case x$glib_cv_has__inline in
183 xyes) AC_DEFINE(G_HAVE___INLINE)
184 esac
185 AC_MSG_CHECKING(for __inline__)
186 AC_CACHE_VAL(glib_cv_has__inline__,[
187         AC_TRY_RUN([
188         __inline__ int foo () { return 0; }
189         int main () { return foo (); }
190         ],
191         glib_cv_has__inline__=yes
192         ,
193         glib_cv_has__inline__=no
194         ,)
195 ])
196 AC_MSG_RESULT($glib_cv_has__inline__)
197 case x$glib_cv_has__inline__ in
198 xyes) AC_DEFINE(G_HAVE___INLINE__)
199 esac
200 AC_MSG_CHECKING(for inline)
201 AC_CACHE_VAL(glib_cv_hasinline,[
202         AC_TRY_RUN([
203         inline int foo () { return 0; }
204         int main () { return foo (); }
205         ],
206         glib_cv_hasinline=yes
207         ,
208         glib_cv_hasinline=no
209         ,)
210 ])
211 AC_MSG_RESULT($glib_cv_hasinline)
212 case x$glib_cv_hasinline in
213 xyes) AC_DEFINE(G_HAVE_INLINE)
214 esac
215
216
217 dnl header file checks
218 AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H))
219 AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H))
220 AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
221
222 # Check for strerror, strsignal, memmove, vsnprintf, and strcasecmp functions
223 AC_CHECK_FUNCS(strerror strsignal memmove vsnprintf strcasecmp)
224
225 # Check for sys_errlist
226 AC_MSG_CHECKING(for sys_errlist)
227 AC_TRY_LINK(, [
228 extern char *sys_errlist[];
229 extern int sys_nerr;
230 sys_errlist[sys_nerr-1][0] = 0;
231 ], glib_ok=yes, glib_ok=no)
232 AC_MSG_RESULT($glib_ok)
233 if test $glib_ok = no; then
234     AC_DEFINE(NO_SYS_ERRLIST)
235 fi
236
237 # Check for sys_siglist
238 AC_MSG_CHECKING(for sys_siglist)
239 AC_TRY_LINK(, [
240 extern char *sys_siglist[];
241 sys_siglist[1][0] = 0;
242 ], glib_ok=yes, glib_ok=no)
243 AC_MSG_RESULT($glib_ok)
244 if test $glib_ok = no; then
245     AC_DEFINE(NO_SYS_SIGLIST)
246 fi
247
248 # Check if <sys/select.h> needs to be included for fd_set
249 AC_MSG_CHECKING([for fd_set])
250 AC_TRY_COMPILE([#include <sys/types.h>],
251         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
252 if test $gtk_ok = yes; then
253     AC_MSG_RESULT([yes, found in sys/types.h])
254 else
255     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
256     if test $gtk_ok = yes; then
257         AC_DEFINE(HAVE_SYS_SELECT_H)
258         AC_MSG_RESULT([yes, found in sys/select.h])
259     else
260         AC_DEFINE(NO_FD_SET)
261         AC_MSG_RESULT(no)
262     fi
263 fi
264
265 # This stuff is here, only so that we can define these
266 # things in glibconfig.h. If ../config.h was installed
267 # (under some other name?) then the definitions would
268 # belong there. (They are only used in GDK)
269
270 # Check for wchar.h
271
272 AC_MSG_CHECKING(for wchar.h)
273 AC_TRY_CPP([#include <wchar.h>], gtk_ok=yes, gtk_ok=no)
274 if test $gtk_ok = yes; then
275    AC_DEFINE(HAVE_WCHAR_H)
276 fi
277 AC_MSG_RESULT($gtk_ok)
278
279 # Check for wctype.h (for iswalnum)
280
281 AC_MSG_CHECKING(for wctype.h)
282 AC_TRY_CPP([#include <wctype.h>], gtk_ok=yes, gtk_ok=no)
283 if test $gtk_ok = yes; then
284    AC_DEFINE(HAVE_WCTYPE_H)
285 fi
286 AC_MSG_RESULT($gtk_ok)
287
288 # The following is necessary for Linux libc-5.4.38
289
290 AC_MSG_CHECKING(if iswalnum() and friends are properly defined)
291 AC_TRY_LINK([#include <stdlib.h>],[
292 #if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))
293 #  ifdef HAVE_WCTYPE_H
294 #    include <wctype.h>
295 #  else
296 #    ifdef HAVE_WCHAR_H
297 #      include <wchar.h>
298 #    endif
299 #  endif
300 #else
301 #  define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
302 #endif
303 iswalnum((wchar_t) 0);
304 ], gtk_ok=yes, gtk_ok=no)
305
306 if test $gtk_ok = no; then
307    AC_DEFINE(HAVE_BROKEN_WCTYPE)
308 fi
309 AC_MSG_RESULT($gtk_ok)
310
311 dnl **********************
312 dnl *** va_copy checks ***
313 dnl **********************
314 dnl we currently check for all three va_copy possibilities, so we get
315 dnl all results in config.log for bug reports.
316 AC_MSG_CHECKING(for an implementation of va_copy())
317 AC_CACHE_VAL(glib_cv_va_copy,[
318         AC_TRY_RUN([
319         #include <stdarg.h>
320         void f (int i, ...) {
321         va_list args1, args2;
322         va_start (args1, i);
323         va_copy (args2, args1);
324         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
325           exit (1);
326         va_end (args1); va_end (args2);
327         }
328         int main() {
329           f (0, 42);
330           return 0;
331         }],
332         glib_cv_va_copy=yes
333         ,
334         glib_cv_va_copy=no
335         ,)
336 ])
337 AC_MSG_RESULT($glib_cv_va_copy)
338 AC_MSG_CHECKING(for an implementation of __va_copy())
339 AC_CACHE_VAL(glib_cv___va_copy,[
340         AC_TRY_RUN([
341         #include <stdarg.h>
342         void f (int i, ...) {
343         va_list args1, args2;
344         va_start (args1, i);
345         __va_copy (args2, args1);
346         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
347           exit (1);
348         va_end (args1); va_end (args2);
349         }
350         int main() {
351           f (0, 42);
352           return 0;
353         }],
354         glib_cv___va_copy=yes
355         ,
356         glib_cv___va_copy=no
357         ,)
358 ])
359 AC_MSG_RESULT($glib_cv___va_copy)
360 AC_MSG_CHECKING(whether va_lists can be copied by value)
361 AC_CACHE_VAL(glib_cv_va_val_copy,[
362         AC_TRY_RUN([
363         #include <stdarg.h>
364         void f (int i, ...) {
365         va_list args1, args2;
366         va_start (args1, i);
367         args2 = args1;
368         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
369           exit (1);
370         va_end (args1); va_end (args2);
371         }
372         int main() {
373           f (0, 42);
374           return 0;
375         }],
376         glib_cv_va_val_copy=yes
377         ,
378         glib_cv_va_val_copy=no
379         ,)
380 ])
381 if test "x$glib_cv_va_copy" = "xyes"; then
382   AC_DEFINE(G_VA_COPY, va_copy)
383 else if test "x$glib_cv___va_copy" = "xyes"; then
384   AC_DEFINE(G_VA_COPY, __va_copy)
385 fi
386 fi
387 if test "x$glib_cv_va_val_copy" = "xno"; then
388   AC_DEFINE(G_VA_COPY_AS_ARRAY)
389 fi
390 AC_MSG_RESULT($glib_cv_va_val_copy)
391
392
393 dnl ***********************
394 dnl *** g_module checks ***
395 dnl ***********************
396 G_MODULE_LIBS=
397 G_MODULE_LDFLAGS=
398 G_MODULE_IMPL=
399 G_MODULE_NEED_USCORE=0
400 G_MODULE_HAVE_DLERROR=0
401 dnl *** dlopen() in system libraries
402 if test -z "$G_MODULE_IMPL"; then
403         AC_CHECK_FUNC(dlopen,
404                 G_MODULE_IMPL=G_MODULE_IMPL_DL
405         ,)
406 fi
407 dnl *** dlopen() in libdl
408 if test -z "$G_MODULE_IMPL"; then
409         AC_CHECK_LIB(dl, dlopen,
410                 G_MODULE_LIBS=-ldl
411                 G_MODULE_IMPL=G_MODULE_IMPL_DL
412         ,)
413 fi
414 dnl *** shl_load() in libdld (HP-UX)
415 if test -z "$G_MODULE_IMPL"; then
416         G_MODULE_LDFLAGS='-Wl,-E'
417         AC_CHECK_LIB(dld, shl_load,
418                 G_MODULE_LIBS=-ldld
419                 G_MODULE_IMPL=G_MODULE_IMPL_DLD
420         ,)
421 fi
422 dnl *** additional checks for G_MODULE_IMPL_DL
423 if test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL"; then
424         if test -d /usr/include/linux; then
425                 G_MODULE_LDFLAGS='-rdynamic'
426         fi
427         LIBS_orig="$LIBS"
428         LDFLAGS_orig="$LDFLAGS"
429         LIBS="$LIBS $G_MODULE_LIBS"
430         LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
431 dnl *** check whether we need preceeding underscores
432         AC_MSG_CHECKING(for preceeding underscore in symbols)
433         AC_CACHE_VAL(glib_cv_uscore,[
434                 AC_TRY_RUN([
435                 #include <dlfcn.h>
436                 int glib_underscore_test (void) { return 42; }
437                 int main() {
438                   void *f1 = (void*)0, *f2 = (void*)0, *handle;
439                   handle = dlopen ((void*)0, 0);
440                   if (handle) {
441                     f1 = dlsym (handle, "glib_underscore_test");
442                     f2 = dlsym (handle, "_glib_underscore_test");
443                   } return !(f2 && !f1);
444                 }],
445                         glib_cv_uscore=yes
446                         G_MODULE_NEED_USCORE=1
447                 ,
448                         glib_cv_uscore=no
449                         G_MODULE_NEED_USCORE=0
450                 ,)
451         ])
452         AC_MSG_RESULT($glib_cv_uscore)
453         LDFLAGS="$LDFLAGS_orig"
454 dnl *** check for having dlerror()
455         AC_CHECK_FUNC(dlerror,
456                 G_MODULE_HAVE_DLERROR=1,
457                 G_MODULE_HAVE_DLERROR=0)
458         LIBS="$LIBS_orig"
459 fi
460 dnl *** done, have e got an implementation?
461 if test -z "$G_MODULE_IMPL"; then
462         G_MODULE_IMPL=0
463 fi
464 AC_SUBST(G_MODULE_IMPL)
465 AC_SUBST(G_MODULE_LIBS)
466 AC_SUBST(G_MODULE_LDFLAGS)
467 AC_SUBST(G_MODULE_HAVE_DLERROR)
468 AC_SUBST(G_MODULE_NEED_USCORE)
469
470
471 AC_OUTPUT([
472 Makefile
473 glib-config
474 gmodule/gmoduleconf.h
475 gmodule/Makefile
476 ],[chmod +x glib-config])