Imported Upstream version 2.55.1
[platform/upstream/glib.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_PREREQ([2.62])
3
4 dnl ***********************************
5 dnl *** include special GLib macros ***
6 dnl ***********************************
7
8 m4_define(glib_configure_ac)
9
10 #
11 # The following version number definitions apply to GLib, GModule, GObject,
12 # GThread and GIO as a whole, so if changes occurred in any of them, they are
13 # all treated with the same interface and binary age.
14 #
15 # Making releases:
16 #   glib_micro_version += 1;
17 #   glib_interface_age += 1;
18 #   glib_binary_age += 1;
19 # if any functions have been added, set glib_interface_age to 0.
20 # if backwards compatibility has been broken,
21 # set glib_binary_age _and_ glib_interface_age to 0.
22 #
23 # remember to add a GLIB_VERSION_2_xx macro every time the minor version is
24 # bumped, as well as the GLIB_DEPRECATED_IN and GLIB_AVAILABLE_IN macros
25 # for that version - see gversion.h for further information.
26 #
27 # in easier to understand terms:
28 #
29 # <mclasen> on the stable branch, interface age == micro
30 # <mclasen> on the unstable (ie master), interface age = 0
31
32 m4_define([glib_major_version], [2])
33 m4_define([glib_minor_version], [55])
34 m4_define([glib_micro_version], [1])
35 m4_define([glib_interface_age], [0])
36 m4_define([glib_binary_age],
37           [m4_eval(100 * glib_minor_version + glib_micro_version)])
38 m4_define([glib_version],
39           [glib_major_version.glib_minor_version.glib_micro_version])
40
41 # libtool version related macros
42 m4_define([glib_lt_release], [glib_major_version.glib_minor_version])
43 m4_define([glib_lt_current],
44           [m4_eval(100 * glib_minor_version + glib_micro_version - glib_interface_age)])
45 m4_define([glib_lt_revision], [glib_interface_age])
46 m4_define([glib_lt_age], [m4_eval(glib_binary_age - glib_interface_age)])
47 m4_define([glib_lt_current_minus_age],
48           [m4_eval(glib_lt_current - glib_lt_age)])
49
50 # if the minor version number is odd, then we want debugging.  Otherwise
51 # we only want minimal debugging support.
52 m4_define([glib_debug_default],
53           [m4_if(m4_eval(glib_minor_version % 2), [1], [yes], [minimum])])dnl
54
55
56 AC_INIT(glib, [glib_version],
57         [http://bugzilla.gnome.org/enter_bug.cgi?product=glib])
58
59 AC_CONFIG_HEADERS([config.h])
60 AC_CONFIG_SRCDIR([glib/glib.h])
61 AC_CONFIG_MACRO_DIR([m4macros])
62
63 # Save this value here, since automake will set cflags later
64 cflags_set=${CFLAGS:+set}
65
66 AM_INIT_AUTOMAKE([1.13.3 -Wno-portability no-define no-dist-gzip dist-xz tar-ustar subdir-objects])
67 AM_MAINTAINER_MODE([enable])
68
69 # Support silent build rules. Disable
70 # by either passing --disable-silent-rules to configure or passing V=1
71 # to make
72 AM_SILENT_RULES([yes])
73
74 GLIB_MAJOR_VERSION=glib_major_version
75 GLIB_MINOR_VERSION=glib_minor_version
76 GLIB_MICRO_VERSION=glib_micro_version
77 GLIB_INTERFACE_AGE=glib_interface_age
78 GLIB_BINARY_AGE=glib_binary_age
79 GLIB_VERSION=glib_version
80
81 AC_SUBST(GLIB_MAJOR_VERSION)
82 AC_SUBST(GLIB_MINOR_VERSION)
83 AC_SUBST(GLIB_MICRO_VERSION)
84 AC_SUBST(GLIB_VERSION)
85 AC_SUBST(GLIB_INTERFACE_AGE)
86 AC_SUBST(GLIB_BINARY_AGE)
87
88 AC_DEFINE(GLIB_MAJOR_VERSION, [glib_major_version],
89           [Define to the GLIB major version])
90 AC_DEFINE(GLIB_MINOR_VERSION, [glib_minor_version],
91           [Define to the GLIB minor version])
92 AC_DEFINE(GLIB_MICRO_VERSION, [glib_micro_version],
93           [Define to the GLIB micro version])
94 AC_DEFINE(GLIB_INTERFACE_AGE, [glib_interface_age],
95           [Define to the GLIB interface age])
96 AC_DEFINE(GLIB_BINARY_AGE, [glib_binary_age],
97           [Define to the GLIB binary age])
98
99 # libtool versioning
100 LT_RELEASE=glib_lt_release
101 LT_CURRENT=glib_lt_current
102 LT_REVISION=glib_lt_revision
103 LT_AGE=glib_lt_age
104 LT_CURRENT_MINUS_AGE=glib_lt_current_minus_age
105 AC_SUBST(LT_RELEASE)
106 AC_SUBST(LT_CURRENT)
107 AC_SUBST(LT_REVISION)
108 AC_SUBST(LT_AGE)
109 AC_SUBST(LT_CURRENT_MINUS_AGE)
110
111 dnl Checks for programs.
112 AC_PROG_CC
113 AC_PROG_CPP
114 AC_USE_SYSTEM_EXTENSIONS
115
116 AM_CONDITIONAL(HAVE_GCC, [test "$GCC" = "yes"])
117
118 AC_CANONICAL_HOST
119
120 dnl
121
122 AC_MSG_CHECKING([for Win32])
123 LIB_EXE_MACHINE_FLAG=X86
124 case "$host" in
125   *-*-mingw*)
126     glib_native_win32=yes
127     glib_pid_type='void *'
128     glib_pid_format='p'
129     glib_pollfd_format='%#x'
130     glib_cv_stack_grows=no
131     # Unfortunately the mingw implementations of C99-style snprintf and vsnprintf
132     # don't seem to be quite good enough, at least not in mingw-runtime-3.14.
133     # (Sorry, I don't know exactly what is the problem, but it is related to
134     # floating point formatting and decimal point vs. comma.)
135     # The simple tests in AC_FUNC_VSNPRINTF_C99 and AC_FUNC_SNPRINTF_C99 aren't
136     # rigorous enough to notice, though.
137     # So preset the autoconf cache variables.
138     ac_cv_func_vsnprintf_c99=no
139     ac_cv_func_snprintf_c99=no
140     case "$host" in
141     x86_64-*-*)
142       LIB_EXE_MACHINE_FLAG=X64
143       glib_pollfd_format='%#I64x'
144       ;;
145     esac
146
147     AC_DEFINE([_WIN32_WINNT], [0x0601], [Target the Windows 7 API])
148     ;;
149   *)
150     glib_native_win32=no
151     glib_pid_type=int
152     glib_pid_format='i'
153     glib_pollfd_format='%d'
154     ;;
155 esac
156 case $host in
157   *-*-linux*)
158     glib_os_linux=yes
159     ;;
160 esac
161
162 AC_MSG_RESULT([$glib_native_win32])
163
164 AC_MSG_CHECKING([for the Android])
165 case $host in
166   *android*)
167     glib_native_android="yes"
168     ;;
169   *)
170     glib_native_android="no"
171     ;;
172 esac
173 AC_MSG_RESULT([$glib_native_android])
174
175 AC_SUBST(LIB_EXE_MACHINE_FLAG)
176
177 glib_have_carbon=no
178 AC_MSG_CHECKING([for Mac OS X Carbon support])
179 AC_TRY_CPP([
180 #include <Carbon/Carbon.h>
181 #include <CoreServices/CoreServices.h>
182 ], glib_have_carbon=yes)
183
184 AC_MSG_RESULT([$glib_have_carbon])
185
186 glib_have_cocoa=no
187 AC_MSG_CHECKING([for Mac OS X Cocoa support])
188 AC_TRY_CPP([
189 #include <Cocoa/Cocoa.h>
190 #ifdef GNUSTEP_BASE_VERSION
191 #error "Detected GNUstep, not Cocoa"
192 #endif
193 ], glib_have_cocoa=yes)
194
195 AC_MSG_RESULT([$glib_have_cocoa])
196
197 AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"])
198 AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"])
199 AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"])
200 AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"])
201 AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"])
202 AM_CONDITIONAL(OS_COCOA, [test "$glib_have_cocoa" = "yes"])
203
204 AS_IF([test "$glib_native_win32" = "yes"], [
205   AC_CHECK_TOOL(WINDRES, windres, no)
206   if test "$WINDRES" = no; then
207     AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.])
208   fi
209   AC_CHECK_TOOL(NM, nm, no)
210   if test "$NM" = no; then
211     AC_MSG_ERROR([*** Could not find an implementation of nm in your PATH.])
212   fi
213   AC_CHECK_TOOL(RANLIB, ranlib, :)
214   AC_CHECK_TOOL(DLLTOOL, dlltool, :)
215   AC_CHECK_PROG(ms_librarian, [lib.exe], [yes], [no])
216 ])
217 AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
218
219 AS_IF([test "x$glib_have_carbon" = "xyes"], [
220   AC_DEFINE(HAVE_CARBON, 1, [define to 1 if Carbon is available])
221   CARBON_LIBS="-Wl,-framework,Carbon"
222   LDFLAGS="$LDFLAGS $CARBON_LIBS"
223 ], [CARBON_LIBS=""])
224
225 AC_SUBST([CARBON_LIBS])
226 ac_cv_have_os_x_9_or_later="no"
227 AS_IF([test "x$glib_have_cocoa" = "xyes"], [
228   AC_DEFINE(HAVE_COCOA, 1, [define to 1 if Cocoa is available])
229   COCOA_LIBS="-Wl,-framework,Foundation"
230   LDFLAGS="$LDFLAGS $COCOA_LIBS"
231   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
232 #include <AvailabilityMacros.h>
233 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
234 #error Compiling for minimum OS X version before 10.9
235 #endif
236   ]])],[ac_cv_have_os_x_9_or_later="yes"])
237 ], [COCOA_LIBS=""])
238 AM_CONDITIONAL([MAC_OS_X_9], [test "x$ac_cv_have_os_x_9_or_later" = xyes])
239 AC_SUBST([COCOA_LIBS])
240
241 dnl declare --enable-* args and collect ac_help strings
242 AC_ARG_ENABLE(debug,
243               AS_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@],
244                              [turn on debugging @<:@default=glib_debug_default@:>@]),,
245               enable_debug=glib_debug_default)
246
247 AC_ARG_ENABLE(gc_friendly,
248               [AS_HELP_STRING([--enable-gc-friendly],
249                               [turn on garbage collector friendliness [default=no]])],,
250               [enable_gc_friendly=no])
251 AC_ARG_ENABLE(mem_pools,
252               [AS_HELP_STRING([--disable-mem-pools],
253                               [disable all glib memory pools])],,
254               [disable_mem_pools=no])
255
256 GLIB_TESTS
257
258 AC_MSG_CHECKING([whether to enable garbage collector friendliness])
259 AS_IF([test "x$enable_gc_friendly" = "xyes"], [
260   AC_DEFINE(ENABLE_GC_FRIENDLY_DEFAULT, 1, [Whether to enable GC friendliness by default])
261   AC_MSG_RESULT([yes])
262 ], [ AC_MSG_RESULT([no]) ])
263
264 AC_MSG_CHECKING([whether to disable memory pools])
265 AS_IF([test "x$disable_mem_pools" = "xno"], [
266   AC_MSG_RESULT([no])
267 ], [
268   AC_DEFINE(DISABLE_MEM_POOLS, [1], [Whether to disable memory pools])
269   AC_MSG_RESULT([yes])
270 ])
271
272 dnl location to install runtime libraries, e.g. ../../lib to install
273 dnl to /lib if libdir is /usr/lib
274 AC_ARG_WITH(runtime-libdir,
275            [AS_HELP_STRING([--with-runtime-libdir=RELPATH],
276                            [install runtime libraries relative to libdir])],
277            [],
278            [with_runtime_libdir=""])
279 GLIB_RUNTIME_LIBDIR="$with_runtime_libdir"
280 AC_SUBST(GLIB_RUNTIME_LIBDIR)
281 AM_CONDITIONAL(HAVE_GLIB_RUNTIME_LIBDIR, [test "x$with_runtime_libdir" != "x"])
282
283 dnl Check for a working C++ compiler, but do not bail out, if none is found.
284 AC_CHECK_TOOLS(CXX, [$CCC c++ g++ gcc CC cxx cc++ cl], [gcc])
285 AC_LANG_SAVE
286 AC_LANG_CPLUSPLUS
287 AC_TRY_COMPILE(,[class a { int b; } c;], ,CXX=)
288 AM_CONDITIONAL(HAVE_CXX, [test "$CXX" != ""])
289 AC_LANG_RESTORE
290
291 AM_PROG_CC_C_O
292 AC_PROG_INSTALL
293
294 AC_SYS_LARGEFILE
295
296 PKG_PROG_PKG_CONFIG(0.16)
297
298 if test "x$enable_debug" = "xyes"; then
299   if test "x$cflags_set" != "x" ; then
300       case " $CFLAGS " in
301       *[[\ \    ]]-g[[\ \       ]]*) ;;
302       *) CFLAGS="$CFLAGS -g" ;;
303       esac
304   fi
305   GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
306 else
307   GLIB_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"
308
309   if test "x$enable_debug" = "xno"; then
310     GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
311   fi
312 fi
313
314 # Ensure MSVC-compatible struct packing convention is used when
315 # compiling for Win32 with gcc.
316 # What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
317 # gcc2 uses "-fnative-struct".
318 if test x"$glib_native_win32" = xyes; then
319   if test x"$GCC" = xyes; then
320     msnative_struct=''
321     AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
322     if test -z "$ac_cv_prog_CC"; then
323       our_gcc="$CC"
324     else
325       our_gcc="$ac_cv_prog_CC"
326     fi
327     case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
328       2.)
329         if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
330           msnative_struct='-fnative-struct'
331         fi
332         ;;
333       *)
334         if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
335           msnative_struct='-mms-bitfields'
336         fi
337         ;;
338     esac
339     if test x"$msnative_struct" = x ; then
340       AC_MSG_RESULT([no way])
341       AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
342     else
343       CFLAGS="$CFLAGS $msnative_struct"
344       AC_MSG_RESULT([${msnative_struct}])
345     fi
346   fi
347 fi
348 GLIB_EXTRA_CFLAGS="${msnative_struct}"
349 AC_SUBST(GLIB_EXTRA_CFLAGS)
350
351 AC_EXEEXT
352
353 AC_PROG_AWK
354 AC_CHECK_PROGS(PERL, [perl5 perl])
355
356 # option to specify python interpreter to use; this just sets $PYTHON, so that
357 # we will fallback to reading $PYTHON if --with-python is not given, and
358 # python.m4 will get the expected input
359 AC_ARG_WITH(python,
360             AS_HELP_STRING([--with-python=PATH],
361                            [Path to Python interpreter; searches $PATH if only a program name is given; if not given, searches for a few standard names such as "python3" or "python2"]),
362             [PYTHON="$withval"], [])
363 if test x"$PYTHON" = xyes; then
364   AC_MSG_ERROR([--with-python option requires a path or program argument])
365 fi
366 AM_PATH_PYTHON(2.7,,PYTHON="python2.7")
367
368
369 dnl ***********************
370 dnl *** Tests for iconv ***
371 dnl ***********************
372 dnl
373 dnl We do this before the gettext checks, to avoid distortion
374
375 dnl On Windows we use a native implementation
376
377 AS_IF([ test x"$glib_native_win32" = xyes], [
378   with_libiconv=native
379 ], [
380   AC_ARG_WITH(libiconv,
381               [AS_HELP_STRING([--with-libiconv=@<:@no/gnu/native@:>@],
382                               [use the libiconv library])],,
383               [with_libiconv=maybe])
384
385   found_iconv=no
386   case $with_libiconv in
387     maybe)
388       # Check in the C library first
389       AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
390       # Check if we have GNU libiconv
391       if test $found_iconv = "no"; then
392         AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
393       fi
394       # Check if we have a iconv in -liconv, possibly from vendor
395       if test $found_iconv = "no"; then
396         AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
397       fi
398       ;;
399     no)
400       AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
401       ;;
402     gnu|yes)
403       AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
404       ;;
405     native)
406       AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
407       ;;
408   esac
409
410   if test "x$found_iconv" = "xno" ; then
411      AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
412   fi
413 ])
414
415 dnl
416 dnl zlib support
417 dnl
418 PKG_CHECK_MODULES([ZLIB], [zlib], [found_zlib=yes], [found_zlib=no])
419 AS_IF([test "x$found_zlib" = "xno"], [
420   AC_CHECK_LIB(z, inflate, [AC_CHECK_HEADER(zlib.h, found_zlib=yes)])
421   if test "x$found_zlib" = "xno" ; then
422     AC_MSG_ERROR([*** Working zlib library and headers not found ***])
423   fi
424   ZLIB_LIBS='-lz'
425   AC_SUBST(ZLIB_LIBS)
426 ])
427
428 PKG_CHECK_MODULES(LIBFFI, [libffi >= 3.0.0])
429 AC_SUBST(LIBFFI_CFLAGS)
430 AC_SUBST(LIBFFI_LIBS)
431
432 dnl
433 dnl gettext support
434 dnl
435
436 ALL_LINGUAS="`grep -v '^#' "$srcdir/po/LINGUAS" | tr '\n' ' '`"
437 AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
438 GLIB_GNU_GETTEXT
439
440 if test "$gt_cv_have_gettext" != "yes" ; then
441   AC_MSG_ERROR([
442 *** You must have either have gettext support in your C library, or use the
443 *** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html)
444 ])
445 fi
446
447 LIBS="$INTLLIBS $LIBS"
448
449 GETTEXT_PACKAGE=glib20
450 AC_SUBST(GETTEXT_PACKAGE)
451 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], 
452   [Define the gettext package to be used])
453
454 GLIB_DEFINE_LOCALEDIR(GLIB_LOCALE_DIR)
455
456 dnl
457 dnl Now we are done with gettext checks, figure out ICONV_LIBS
458 dnl
459
460 AS_IF([test x"$glib_native_win32" != xyes], [
461   if test x$with_libiconv != xno ; then
462     case " $INTLLIBS " in
463     *[[\ \      ]]-liconv[[\ \  ]]*) ;;
464     *) ICONV_LIBS="-liconv" ;;
465     esac
466   fi
467 ])
468 AC_SUBST(ICONV_LIBS)
469
470 case $with_libiconv in
471   gnu)
472     AC_DEFINE(USE_LIBICONV_GNU, 1, [Using GNU libiconv])
473     ;;
474   native)
475     AC_DEFINE(USE_LIBICONV_NATIVE, 1, [Using a native implementation of iconv in a separate library])
476     ;;
477 esac
478
479 dnl Initialize libtool
480 LT_PREREQ([2.2])
481 LT_INIT([disable-static win32-dll])
482 dnl when using libtool 2.x create libtool early, because it's used in configure
483 m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
484
485
486 AS_IF([test "$glib_native_win32" = "yes"], [
487   if test x$enable_static = xyes -a x$enable_shared = xyes; then
488     AC_MSG_ERROR([Can not build both shared and static at the same time on Windows.])
489   fi
490   if test x$enable_static = xyes; then
491     glib_win32_static_compilation=yes
492     GLIB_WIN32_STATIC_COMPILATION_DEFINE="#define GLIB_STATIC_COMPILATION 1
493 #define GOBJECT_STATIC_COMPILATION 1"
494     AC_SUBST(GLIB_WIN32_STATIC_COMPILATION_DEFINE)
495   fi
496 ])
497 AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a x$glib_win32_static_compilation != xyes])
498
499 # Checks for library functions.
500 AC_FUNC_ALLOCA
501 AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2 issetugid)
502 AC_CHECK_FUNCS(timegm gmtime_r)
503 AC_FUNC_STRERROR_R()
504
505 AC_CACHE_CHECK([for __libc_enable_secure], glib_cv_have_libc_enable_secure,
506   [AC_TRY_LINK([#include <unistd.h>
507     extern int __libc_enable_secure;],
508     [return __libc_enable_secure;],
509    glib_cv_have_libc_enable_secure=yes,
510    glib_cv_have_libc_enable_secure=no)])
511 AS_IF([test x$glib_cv_have_libc_enable_secure = xyes], [
512    AC_DEFINE(HAVE_LIBC_ENABLE_SECURE, 1,
513      [Define if you have the __libc_enable_secure variable (GNU libc, eglibc)])
514 ])
515
516 AC_CHECK_SIZEOF(char)
517 AC_CHECK_SIZEOF(short)
518 AC_CHECK_SIZEOF(long)
519 AC_CHECK_SIZEOF(int)
520 AC_CHECK_SIZEOF(void *)
521 AC_CHECK_SIZEOF(long long)
522 AC_CHECK_SIZEOF(__int64)
523
524 AC_CACHE_CHECK([for sig_atomic_t], ac_cv_type_sig_atomic_t,
525   [AC_TRY_LINK([#include <signal.h>
526      #include <sys/types.h>
527      sig_atomic_t val = 42;],
528     [return val == 42 ? 0 : 1],
529    ac_cv_type_sig_atomic_t=yes,
530    ac_cv_type_sig_atomic_t=no)])
531 if test x$ac_cv_type_sig_atomic_t = xyes; then
532    AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
533      [Define if you have the 'sig_atomic_t' type.])
534 fi
535
536 if test x$ac_cv_sizeof_long = x8 || test x$ac_cv_sizeof_long_long = x8 || test x$ac_cv_sizeof___int64 = x8 ; then
537   :
538 else
539   AC_MSG_ERROR([
540 *** GLib requires a 64 bit type. You might want to consider
541 *** using the GNU C compiler.
542 ])
543 fi
544
545 AS_IF([test x$glib_native_win32 != xyes && test x$ac_cv_sizeof_long_long = x8], [
546         # long long is a 64 bit integer.
547         AC_MSG_CHECKING(for format to printf and scanf a guint64)
548         AC_CACHE_VAL(glib_cv_long_long_format,[
549                 for format in ll q I64; do
550                   AC_TRY_RUN([#include <stdio.h>  
551                         int main()
552                         {
553                           long long b, a = -0x3AFAFAFAFAFAFAFALL;
554                           char buffer[1000];
555                           sprintf (buffer, "%${format}u", a);
556                           sscanf (buffer, "%${format}u", &b);
557                           exit (b!=a);
558                         }
559                         ],
560                         [glib_cv_long_long_format=${format}
561                         break],
562                         [],[:])
563                 done])
564         AS_IF([ test -n "$glib_cv_long_long_format"], [
565           AC_MSG_RESULT(%${glib_cv_long_long_format}u)
566           AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
567           if test x"$glib_cv_long_long_format" = xI64; then
568             AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format I64])
569           fi
570         ], [AC_MSG_RESULT(none)])
571 ],[ test x$ac_cv_sizeof___int64 = x8], [
572         # __int64 is a 64 bit integer.
573         AC_MSG_CHECKING(for format to printf and scanf a guint64)
574         # We know this is MSVCRT.DLL, and what the formats are
575         glib_cv_long_long_format=I64
576         AC_MSG_RESULT(%${glib_cv_long_long_format}u)
577         AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
578         AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format I64])
579 ])
580
581 AC_C_CONST
582
583 dnl
584 dnl check in which direction the stack grows
585 dnl
586 AC_CACHE_CHECK([for growing stack pointer],glib_cv_stack_grows,[
587         AC_TRY_RUN([
588         volatile int *a = 0, *b = 0;
589         void f (int i) { volatile int x = 5; if (i == 0) b = &x; else f (i - 1); }
590         int main () { volatile int y = 7; a = &y; f (100); return b > a ? 0 : 1; }
591         ],
592         glib_cv_stack_grows=yes
593         ,
594         glib_cv_stack_grows=no
595         ,)
596 ])
597
598 # check for flavours of varargs macros
599 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
600 AC_TRY_COMPILE([],[
601 int a(int p1, int p2, int p3);
602 #define call_a(...) a(1,__VA_ARGS__)
603 call_a(2,3);
604 ],g_have_iso_c_varargs=yes,g_have_iso_c_varargs=no)
605 AC_MSG_RESULT($g_have_iso_c_varargs)
606
607 AC_MSG_CHECKING(for ISO C99 varargs macros in C++)
608 AS_IF([test "$CXX" = ""], [
609 dnl No C++ compiler
610   g_have_iso_cxx_varargs=no
611 else
612   AC_LANG_CPLUSPLUS
613   AC_TRY_COMPILE([],[
614 int a(int p1, int p2, int p3);
615 #define call_a(...) a(1,__VA_ARGS__)
616 call_a(2,3);
617 ],g_have_iso_cxx_varargs=yes,g_have_iso_cxx_varargs=no)
618   AC_LANG_C
619 ])
620 AC_MSG_RESULT($g_have_iso_cxx_varargs)
621
622 AC_MSG_CHECKING(for GNUC varargs macros)
623 AC_TRY_COMPILE([],[
624 int a(int p1, int p2, int p3);
625 #define call_a(params...) a(1,params)
626 call_a(2,3);
627 ],g_have_gnuc_varargs=yes,g_have_gnuc_varargs=no)
628 AC_MSG_RESULT($g_have_gnuc_varargs)
629
630 # check for GNUC visibility support
631 AC_MSG_CHECKING(for GNUC visibility attribute)
632 GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
633 void
634 __attribute__ ((visibility ("hidden")))
635      f_hidden (void)
636 {
637 }
638 void
639 __attribute__ ((visibility ("internal")))
640      f_internal (void)
641 {
642 }
643 void
644 __attribute__ ((visibility ("protected")))
645      f_protected (void)
646 {
647 }
648 void
649 __attribute__ ((visibility ("default")))
650      f_default (void)
651 {
652 }
653 int main (void)
654 {
655         f_hidden();
656         f_internal();
657         f_protected();
658         f_default();
659         return 0;
660 }
661 ]])],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no)
662 AC_MSG_RESULT($g_have_gnuc_visibility)
663 AM_CONDITIONAL(HAVE_GNUC_VISIBILITY, [test x$g_have_gnuc_visibility = xyes])
664
665 AC_MSG_CHECKING([whether using Sun Studio C compiler])
666 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__SUNPRO_C) || (__SUNPRO_C >= 0x550)
667 #else
668 # include "error: this is not Sun Studio."
669 #endif
670 ]], [[]])], [ g_have_sunstudio_visibility=yes ], [ g_have_sunstudio_visibility=no ])
671 AC_MSG_RESULT($g_have_sunstudio_visibility)
672 AM_CONDITIONAL(HAVE_SUNSTUDIO_VISIBILITY, [test x$g_have_sunstudio_visibility = xyes])
673
674 # check for bytesex stuff
675 AC_C_BIGENDIAN
676 if test x$ac_cv_c_bigendian = xuniversal ; then
677   AC_MSG_ERROR([Universal builds not supported: see https://bugzilla.gnome.org/show_bug.cgi?id=742548])
678 fi
679
680
681 # check for header files
682 AC_CHECK_HEADERS([sys/param.h sys/resource.h mach/mach_time.h])
683 AC_CHECK_HEADERS([sys/select.h stdint.h inttypes.h sched.h malloc.h])
684 AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h])
685 AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h])
686 AC_CHECK_HEADERS([linux/magic.h])
687 AC_CHECK_HEADERS([termios.h])
688
689 # Some versions of MSC lack these
690 AC_CHECK_HEADERS([dirent.h sys/time.h])
691
692 # We don't care about this, but we need to keep including it in
693 # glibconfig.h for backward compatibility
694 AC_CHECK_HEADERS([values.h])
695
696 AC_CHECK_HEADERS([sys/mount.h sys/sysctl.h], [], [],
697 [#if HAVE_SYS_PARAM_H
698  #include <sys/param.h>
699  #endif
700 ])
701 AC_CHECK_FUNCS(sysctlbyname)
702
703 AC_HEADER_MAJOR
704 AC_CHECK_HEADERS([xlocale.h])
705
706 # check for structure fields
707 AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec, struct stat.st_birthtime, struct stat.st_birthtimensec, struct stat.st_birthtim, struct stat.st_birthtim.tv_nsec])
708 AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct statfs.f_fstypename, struct statfs.f_bavail],,, [#include <sys/types.h>
709 #include <sys/stat.h>
710 #ifdef G_OS_UNIX
711 #include <unistd.h>
712 #endif
713 #ifdef HAVE_SYS_STATFS_H
714 #include <sys/statfs.h>
715 #endif
716 #ifdef HAVE_SYS_PARAM_H
717 #include <sys/param.h>
718 #endif
719 #ifdef HAVE_SYS_MOUNT_H
720 #include <sys/mount.h>
721 #endif])
722 # struct statvfs.f_basetype is available on Solaris but not for Linux. 
723 AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [#include <sys/statvfs.h>])
724 AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,, [#include <sys/statvfs.h>])
725 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,[#include <time.h>])
726
727 AC_STRUCT_DIRENT_D_TYPE
728
729 # Checks for libcharset
730 AM_LANGINFO_CODESET
731 gl_GLIBC21
732 AC_ARG_WITH(charsetalias-dir,
733             AS_HELP_STRING([--with-charsetalias-dir=DIR], [directory for charset.alias file [LIBDIR]]),
734            [],
735            [with_charsetalias_dir='${libdir}'])
736 GLIB_CHARSETALIAS_DIR=$with_charsetalias_dir
737 AC_SUBST(GLIB_CHARSETALIAS_DIR)
738
739 # check additional type sizes
740 AC_CHECK_SIZEOF(size_t)
741
742 dnl Try to figure out whether gsize should be long or int
743 AC_MSG_CHECKING([for the appropriate definition for size_t])
744
745 case $ac_cv_sizeof_size_t in
746   $ac_cv_sizeof_short) 
747       glib_size_type=short
748       ;;
749   $ac_cv_sizeof_int) 
750       glib_size_type=int
751       ;;
752   $ac_cv_sizeof_long) 
753       glib_size_type=long
754       ;;
755   $ac_cv_sizeof_long_long)
756       glib_size_type='long long'
757       ;;
758   $ac_cv_sizeof__int64)
759       glib_size_type='__int64'
760       ;;
761   *)  AC_MSG_ERROR([No type matching size_t in size])
762       ;;
763 esac
764
765 dnl If int/long are the same size, we see which one produces
766 dnl warnings when used in the location as size_t. (This matters
767 dnl on AIX with xlc)
768 dnl
769 AS_IF([test $ac_cv_sizeof_size_t = $ac_cv_sizeof_int &&
770        test $ac_cv_sizeof_size_t = $ac_cv_sizeof_long], [
771   GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
772 #if defined(_AIX) && !defined(__GNUC__)
773 #pragma options langlvl=stdc89
774 #endif
775 #include <stddef.h> 
776 int main ()
777 {
778   size_t s = 1;
779   unsigned int *size_int = &s;
780   return (int)*size_int;
781 }
782     ]])],glib_size_type=int,
783       [GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
784 #if defined(_AIX) && !defined(__GNUC__)
785 #pragma options langlvl=stdc89
786 #endif
787 #include <stddef.h> 
788 int main ()
789 {
790    size_t s = 1;
791    unsigned long *size_long = &s;
792    return (int)*size_long;
793 }
794         ]])],glib_size_type=long)])
795 ])
796
797 AC_MSG_RESULT(unsigned $glib_size_type)
798
799 AC_CHECK_SIZEOF(ssize_t)
800
801 dnl Try to figure out whether gssize should be long or int
802 AC_MSG_CHECKING([for the appropriate definition for ssize_t])
803
804 case $ac_cv_sizeof_ssize_t in
805   $ac_cv_sizeof_short) 
806       glib_ssize_type=short
807       ;;
808   $ac_cv_sizeof_int) 
809       glib_ssize_type=int
810       ;;
811   $ac_cv_sizeof_long) 
812       glib_ssize_type=long
813       ;;
814   $ac_cv_sizeof_long_long)
815       glib_ssize_type='long long'
816       ;;
817   $ac_cv_sizeof__int64)
818       glib_ssize_type='__int64'
819       ;;
820   *)  AC_MSG_ERROR([No type matching ssize_t in size])
821       ;;
822 esac
823
824 dnl If int/long are the same size, we see which one produces
825 dnl warnings when used in the location as ssize_t. (This matters
826 dnl on Android where ssize_t is long and size_t is unsigned int)
827 dnl
828 AS_IF([test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_int &&
829        test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_long], [
830   GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
831 #if defined(_AIX) && !defined(__GNUC__)
832 #pragma options langlvl=stdc89
833 #endif
834 #include <stddef.h>
835 #ifdef HAVE_INTTYPES_H
836 # include <inttypes.h>
837 #endif
838 #ifdef HAVE_STDINT_H
839 # include <stdint.h>
840 #endif
841 #include <sys/types.h>
842 int main ()
843 {
844   ssize_t s = 1;
845   int *size_int = &s;
846   return (int)*size_int;
847 }
848     ]])],glib_ssize_type=int,
849       [GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
850 #if defined(_AIX) && !defined(__GNUC__)
851 #pragma options langlvl=stdc89
852 #endif
853 #include <stddef.h> 
854 #ifdef HAVE_INTTYPES_H
855 # include <inttypes.h>
856 #endif
857 #ifdef HAVE_STDINT_H
858 # include <stdint.h>
859 #endif
860 #include <sys/types.h>
861 int main ()
862 {
863    ssize_t s = 1;
864    long *size_long = &s;
865    return (int)*size_long;
866 }
867         ]])],glib_ssize_type=long)])
868 ])
869
870 AC_MSG_RESULT($glib_ssize_type)
871
872 # Check for some functions
873 AC_CHECK_FUNCS(lstat strsignal vsnprintf stpcpy strcasecmp strncasecmp poll vasprintf setenv unsetenv getc_unlocked readlink symlink fdwalk mkostemp)
874 AC_CHECK_FUNCS(lchmod lchown fchmod fchown utimes getresuid)
875 AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getfsstat getvfsstat fallocate)
876 case $host_os in aix*) ac_cv_func_splice=no ;; esac # AIX splice() is something else
877 AC_CHECK_FUNCS(splice)
878 AC_CHECK_FUNCS(prlimit)
879
880 # To avoid finding a compatibility unusable statfs, which typically
881 # successfully compiles, but warns to use the newer statvfs interface:
882 AS_IF([test $ac_cv_header_sys_statvfs_h = yes], [AC_CHECK_FUNCS([statvfs])])
883 AS_IF([test $ac_cv_header_sys_statfs_h  = yes -o $ac_cv_header_sys_mount_h = yes], [AC_CHECK_FUNCS([statfs])])
884
885 AC_MSG_CHECKING([whether to use statfs or statvfs])
886 # Some systems have both statfs and statvfs, pick the most "native" for these
887 AS_IF([test x$ac_cv_func_statfs = xyes && test x$ac_cv_func_statvfs = xyes],
888    [
889    # on solaris and irix, statfs doesn't even have the f_bavail field
890    AS_IF([test x$ac_cv_member_struct_statfs_f_bavail = xno],
891       [ac_cv_func_statfs=no],
892    # else, at least on linux, statfs is the actual syscall
893       [ac_cv_func_statvfs=no])
894    ])
895
896 AS_IF([test x$ac_cv_func_statfs = xyes],
897       [
898          AC_DEFINE([USE_STATFS], [1], [Define to use statfs()])
899          AC_MSG_RESULT([statfs])
900       ],
901       [test x$ac_cv_func_statvfs = xyes],
902       [
903          AC_DEFINE([USE_STATVFS], [1], [Define to use statvfs()])
904          AC_MSG_RESULT([statvfs])
905       ],
906       [  AC_MSG_RESULT([neither])])
907
908 AC_CHECK_HEADERS(crt_externs.h)
909 AC_CHECK_FUNCS(_NSGetEnviron)
910
911 AC_CHECK_FUNCS(newlocale uselocale strtod_l strtoll_l strtoull_l)
912
913 # Internet address families
914 if test $glib_native_win32 = yes; then
915   glib_inet_includes=["
916 #include <winsock2.h>
917   "]
918 else
919   glib_inet_includes=["
920 #include <sys/types.h>
921 #include <sys/socket.h>
922   "]
923 fi
924
925 glib_failed=false
926 GLIB_CHECK_VALUE(AF_INET, $glib_inet_includes, glib_failed=true)
927 GLIB_CHECK_VALUE(AF_INET6, $glib_inet_includes, glib_failed=true)
928 # winsock defines this even though it doesn't support it
929 GLIB_CHECK_VALUE(AF_UNIX, $glib_inet_includes, glib_failed=true)
930 if $glib_failed ; then
931   AC_MSG_ERROR([Could not determine values for AF_INET* constants])
932 fi
933
934 glib_failed=false
935 GLIB_CHECK_VALUE(MSG_PEEK, $glib_inet_includes, glib_failed=true)
936 GLIB_CHECK_VALUE(MSG_OOB, $glib_inet_includes, glib_failed=true)
937 GLIB_CHECK_VALUE(MSG_DONTROUTE, $glib_inet_includes, glib_failed=true)
938 if $glib_failed ; then
939   AC_MSG_ERROR([Could not determine values for MSG_* constants])
940 fi
941
942 AC_CHECK_FUNCS(endservent if_nametoindex if_indextoname sendmmsg recvmmsg)
943
944 AC_MSG_CHECKING([for SIOCGIFADDR])
945 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
946     [[
947         #include <sys/ioctl.h>
948         #include <net/if.h>
949     ]],
950     [[
951         struct ifreq ifr;
952         ioctl(0, SIOCGIFADDR, &ifr);
953     ]])], [
954         AC_MSG_RESULT(yes)
955         AC_DEFINE(HAVE_SIOCGIFADDR, 1, [SIOCGIFADDR is available])
956     ], [
957         AC_MSG_RESULT(no)
958 ])
959
960 AS_IF([test $glib_native_win32 = yes], [
961   # <wspiapi.h> in the Windows SDK and in mingw-w64 has wrappers for
962   # inline workarounds for getaddrinfo, getnameinfo and freeaddrinfo if
963   # they aren't present at run-time (on Windows 2000).
964   AC_CHECK_HEADER([wspiapi.h], [WSPIAPI_INCLUDE="#include <wspiapi.h>"])
965   AC_SUBST(WSPIAPI_INCLUDE)
966 ], [
967   # Android does not have C_IN in public headers, we define it wherever necessary
968   AS_IF([test $glib_native_android != yes], [
969     AC_MSG_CHECKING([if arpa/nameser_compat.h is needed])
970     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
971                                         #include <arpa/nameser.h>],
972                                        [int qclass = C_IN;])],
973                       [AC_MSG_RESULT([no])],
974                       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
975                                                            #include <arpa/nameser.h>
976                                                            #include <arpa/nameser_compat.h>],
977                                                           [int qclass = C_IN;])],
978                                          [AC_MSG_RESULT([yes])
979                                           NAMESER_COMPAT_INCLUDE="#include <arpa/nameser_compat.h>"],
980                                          [AC_MSG_ERROR([could not compile test program either way])])])])
981   AC_SUBST(NAMESER_COMPAT_INCLUDE)
982
983   # We can't just use AC_CHECK_FUNC/AC_CHECK_LIB here. Bug 586150
984   NETWORK_LIBS=""
985   AC_MSG_CHECKING([for res_query])
986   AC_TRY_LINK([#include <sys/types.h>
987                #include <netinet/in.h>
988                #include <arpa/nameser.h>
989                #include <resolv.h>
990               ],[
991                res_query("test", 0, 0, (void *)0, 0);
992               ],[AC_MSG_RESULT([yes])],
993               [save_libs="$LIBS"
994                LIBS="-lresolv $LIBS"
995                AC_TRY_LINK([#include <sys/types.h>
996                             #include <netinet/in.h>
997                             #include <arpa/nameser.h>
998                             #include <resolv.h>
999                            ],[
1000                             res_query("test", 0, 0, (void *)0, 0);
1001                            ],[AC_MSG_RESULT([in -lresolv])
1002                               NETWORK_LIBS="-lresolv $NETWORK_LIBS"],
1003                            [LIBS="-lbind $save_libs"
1004                             AC_TRY_LINK([#include <resolv.h>],
1005                                         [res_query("test", 0, 0, (void *)0, 0);],
1006                                         [AC_MSG_RESULT([in -lbind])
1007                                          NETWORK_LIBS="-lbind $NETWORK_LIBS"],
1008                                         [AC_MSG_ERROR(not found)])])
1009                LIBS="$save_libs"])
1010   AC_CHECK_FUNC(socket, :, AC_CHECK_LIB(socket, socket,
1011                                         [NETWORK_LIBS="-lsocket $NETWORK_LIBS"],
1012                                         [AC_MSG_ERROR(Could not find socket())]))
1013   save_libs="$LIBS"
1014   LIBS="$LIBS $NETWORK_LIBS"
1015   AC_MSG_CHECKING([for res_init])
1016   AC_TRY_LINK([#include <sys/types.h>
1017                #include <netinet/in.h>
1018                #include <arpa/nameser.h>
1019                #include <resolv.h>
1020               ],[
1021                res_init();
1022               ],[AC_MSG_RESULT([yes])
1023                  AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if you have the 'res_init' function.])
1024               ],[AC_MSG_RESULT([no])])
1025   LIBS="$save_libs"
1026 ])
1027 AC_SUBST(NETWORK_LIBS)
1028
1029 AC_CHECK_HEADER([linux/netlink.h],
1030                 [AC_DEFINE(HAVE_NETLINK, 1, [We have AF_NETLINK sockets])],,
1031                 [#include <sys/socket.h>])
1032 AM_CONDITIONAL(HAVE_NETLINK, [test "$ac_cv_header_linux_netlink_h" = "yes"])
1033
1034 AC_CHECK_TYPE([struct ip_mreqn], [
1035               AC_DEFINE(HAVE_IP_MREQN,, [Define if we have struct ip_mreqn])],,
1036               [#include <netinet/in.h>])
1037
1038 case $host in
1039   *-*-solaris* )
1040      AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Needed to get declarations for msg_control and msg_controllen on Solaris)
1041      AC_DEFINE(_XOPEN_SOURCE,          2, Needed to get declarations for msg_control and msg_controllen on Solaris)
1042      AC_DEFINE(__EXTENSIONS__,         1, Needed to get declarations for msg_control and msg_controllen on Solaris)
1043      ;;
1044 esac
1045
1046 dnl
1047 dnl if statfs() takes 2 arguments (Posix) or 4 (Solaris)
1048 dnl
1049 AS_IF([test "$ac_cv_func_statfs" = yes], [
1050   AC_MSG_CHECKING([number of arguments to statfs()])
1051   AC_TRY_COMPILE([#include <unistd.h>
1052   #ifdef HAVE_SYS_PARAM_H
1053   #include <sys/param.h>
1054   #endif
1055   #ifdef HAVE_SYS_VFS_H
1056   #include <sys/vfs.h>
1057   #endif
1058   #ifdef HAVE_SYS_MOUNT_H
1059   #include <sys/mount.h>
1060   #endif
1061   #ifdef HAVE_SYS_STATFS_H
1062   #include <sys/statfs.h>
1063   #endif], [struct statfs st;
1064   statfs("/", &st);],[
1065     AC_MSG_RESULT([2])
1066     AC_DEFINE(STATFS_ARGS, 2, [Number of arguments to statfs()])],[
1067     AC_TRY_COMPILE([#include <unistd.h>
1068   #ifdef HAVE_SYS_PARAM_H
1069   #include <sys/param.h>
1070   #endif
1071   #ifdef HAVE_SYS_VFS_H
1072   #include <sys/vfs.h>
1073   #endif
1074   #ifdef HAVE_SYS_MOUNT_H
1075   #include <sys/mount.h>
1076   #endif
1077   #ifdef HAVE_SYS_STATFS_H
1078   #include <sys/statfs.h>
1079   #endif], [struct statfs st;
1080   statfs("/", &st, sizeof (st), 0);],[
1081       AC_MSG_RESULT([4])
1082       AC_DEFINE(STATFS_ARGS, 4, [Number of arguments to statfs()])],[
1083       AC_MSG_RESULT(unknown)
1084       AC_MSG_ERROR([unable to determine number of arguments to statfs()])])])
1085 ])
1086
1087 dnl
1088 dnl open takes O_DIRECTORY as an option
1089 dnl
1090 AC_MSG_CHECKING([open() option O_DIRECTORY])
1091 AC_TRY_COMPILE([#include <fcntl.h>
1092 #include <sys/types.h>
1093 #include <sys/stat.h>],
1094 [open(0, O_DIRECTORY, 0);],[
1095         AC_MSG_RESULT([yes])
1096         AC_DEFINE(HAVE_OPEN_O_DIRECTORY, 1, [open option O_DIRECTORY])],[
1097         AC_MSG_RESULT([no])])
1098
1099 #
1100 # Check whether to use an included printf
1101 #
1102 AC_FUNC_VSNPRINTF_C99
1103 AC_FUNC_PRINTF_UNIX98
1104
1105 AC_ARG_ENABLE(included-printf,
1106               [AS_HELP_STRING([--enable-included-printf],
1107                               [use included printf [default=auto]])],
1108               enable_included_printf="$enableval")
1109
1110 need_included_printf=no
1111 if test "x$enable_included_printf" = "xyes" ; then
1112   need_included_printf=yes
1113 fi
1114 if test "$ac_cv_func_vsnprintf_c99" != "yes" ; then
1115   need_included_printf=yes
1116 fi
1117 if test "$ac_cv_func_printf_unix98" != "yes" ; then
1118   need_included_printf=yes
1119 fi
1120 if test "x$ac_cv_sizeof_long_long" = "x8" &&
1121    test -z "$glib_cv_long_long_format" ; then
1122   need_included_printf=yes
1123 fi
1124
1125 if test "x$enable_included_printf" = "xno" && 
1126    test "x$need_included_printf" = "xyes" ; then
1127   AC_MSG_ERROR([
1128 *** Your C library's printf doesn't appear to have the features that
1129 *** GLib needs, but you specified --enable-included-printf=no.])
1130 fi
1131
1132 enable_included_printf=$need_included_printf
1133
1134 AM_CONDITIONAL(HAVE_GOOD_PRINTF, test "$enable_included_printf" != "yes")
1135 AS_IF([test "$enable_included_printf" != "yes"], [
1136   AC_DEFINE(HAVE_GOOD_PRINTF,1,[define to use system printf])
1137 ], [
1138   if test -z "$glib_cv_long_long_format" ; then
1139     glib_cv_long_long_format="ll"
1140   fi
1141   AC_DEFINE(HAVE_VASPRINTF,1)
1142 ])
1143
1144 # Checks needed for gnulib vasnprintf
1145 bh_C_SIGNED
1146 jm_AC_TYPE_LONG_LONG
1147 gt_TYPE_LONGDOUBLE
1148 gt_TYPE_WCHAR_T
1149 gt_TYPE_WINT_T
1150 AC_TYPE_SIZE_T
1151 AC_CHECK_TYPES(ptrdiff_t)
1152 jm_AC_TYPE_INTMAX_T
1153 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
1154 AC_FUNC_SNPRINTF_C99
1155
1156 # Check if <sys/select.h> needs to be included for fd_set
1157 AC_MSG_CHECKING([for fd_set])
1158 AC_TRY_COMPILE([#include <sys/types.h>],
1159         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
1160 AS_IF([test "$gtk_ok" = "yes"], [
1161     AC_MSG_RESULT([yes, found in sys/types.h])
1162 ], [
1163     AC_EGREP_HEADER(fd_set, sys/select.h, gtk_ok=yes)
1164     if test "$gtk_ok" = "yes"; then
1165         # *** FIXME: give it a different name
1166         AC_DEFINE(HAVE_SYS_SELECT_H,1,[found fd_set in sys/select.h])
1167         AC_MSG_RESULT([yes, found in sys/select.h])
1168     else
1169         AC_DEFINE(NO_FD_SET,1,[didn't find fd_set])
1170         AC_MSG_RESULT(no)
1171     fi
1172 ])
1173
1174 dnl Check for nl_langinfo and CODESET
1175 AC_LANG_SAVE
1176 AC_LANG_C
1177 AC_CACHE_CHECK([for nl_langinfo (CODESET)],glib_cv_langinfo_codeset,[
1178         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <langinfo.h>],
1179                        [char *codeset = nl_langinfo (CODESET);])],
1180                 [glib_cv_langinfo_codeset=yes],
1181                 [glib_cv_langinfo_codeset=no])])
1182 if test x$glib_cv_langinfo_codeset = xyes; then
1183   AC_DEFINE(HAVE_CODESET,1,[Have nl_langinfo (CODESET)])
1184 fi
1185
1186 dnl Check for nl_langinfo and LC_TIME parts that are needed in gdatetime.c
1187 AC_CACHE_CHECK([for nl_langinfo (PM_STR)],glib_cv_langinfo_time,[
1188         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <langinfo.h>],
1189                  [char *str;
1190                  str = nl_langinfo (PM_STR);
1191                  str = nl_langinfo (D_T_FMT);
1192                  str = nl_langinfo (D_FMT);
1193                  str = nl_langinfo (T_FMT);
1194                  str = nl_langinfo (T_FMT_AMPM);
1195                  str = nl_langinfo (MON_1);
1196                  str = nl_langinfo (ABMON_12);
1197                  str = nl_langinfo (DAY_1);
1198                  str = nl_langinfo (ABDAY_7);])],
1199                 [glib_cv_langinfo_time=yes],
1200                 [glib_cv_langinfo_time=no])])
1201 if test x$glib_cv_langinfo_time = xyes; then
1202   AC_DEFINE(HAVE_LANGINFO_TIME,1,[Have nl_langinfo (PM_STR)])
1203 fi
1204
1205 dnl Check for nl_langinfo and _NL_CTYPE_OUTDIGITn_MB
1206 AC_CACHE_CHECK([for nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)], glib_cv_langinfo_outdigit,[
1207         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <langinfo.h>],
1208                 [char *str;
1209                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
1210                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT1_MB);
1211                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT2_MB);
1212                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT3_MB);
1213                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT4_MB);
1214                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT5_MB);
1215                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT6_MB);
1216                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT7_MB);
1217                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT8_MB);
1218                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT9_MB);])],
1219                 [glib_cv_langinfo_outdigit=yes],
1220                 [glib_cv_langinfo_outdigit=no])])
1221 if test x$glib_cv_langinfo_outdigit = xyes; then
1222   AC_DEFINE(HAVE_LANGINFO_OUTDIGIT,1,[Have nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)])
1223 fi
1224 AC_LANG_RESTORE
1225
1226 dnl ****************************************
1227 dnl *** posix_memalign                   ***
1228 dnl ****************************************
1229 AC_MSG_CHECKING(for a compliant posix_memalign() implementation)
1230 AC_CACHE_VAL(glib_cv_compliant_posix_memalign,[
1231     glib_cv_compliant_posix_memalign=0
1232     if test "$ac_cv_func_posix_memalign" = "yes" ; then
1233         AC_TRY_RUN([
1234                 #define _XOPEN_SOURCE 600
1235                 #include <stdlib.h> /* posix_memalign() should be defined here */
1236                 /* some systems break if #include <malloc.h> used */
1237                 static void test_memalign (size_t boundary, size_t size) {
1238                     void *mem = 0;
1239                     if (posix_memalign (&mem, boundary, size) != 0 || !mem)
1240                         exit (1);
1241                     else
1242                       free (mem);
1243                 }
1244                 int main() {
1245                     test_memalign (  128,   128 - 2 * sizeof (void*));
1246                     test_memalign (  256,   256 - 2 * sizeof (void*));
1247                     test_memalign (  512,   512 - 2 * sizeof (void*));
1248                     test_memalign ( 1024,  1024 - 2 * sizeof (void*));
1249                     test_memalign ( 2048,  2048 - 2 * sizeof (void*));
1250                     test_memalign ( 4096,  4096 - 2 * sizeof (void*));
1251                     test_memalign ( 8192,  8192 - 2 * sizeof (void*));
1252                     test_memalign (16384, 16384 - 2 * sizeof (void*));
1253                     test_memalign (32768, 32768 - 2 * sizeof (void*));
1254                     exit (0); /* success */
1255                 }
1256                 ],
1257             [glib_cv_compliant_posix_memalign=1], [], [:])
1258       :
1259     fi
1260     ])
1261 AS_IF([test "$glib_cv_compliant_posix_memalign" = "1"], [
1262     AC_MSG_RESULT(yes)
1263     AC_DEFINE(POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS, 1, [define if posix_memalign() can allocate any size])
1264 ], [
1265     AC_MSG_RESULT(no)
1266 ])
1267
1268
1269 dnl ****************************************
1270 dnl *** strlcpy/strlcat                  ***
1271 dnl ****************************************
1272 # Check for strlcpy
1273 AC_CACHE_CHECK([for OpenBSD strlcpy/strlcat],glib_cv_have_strlcpy,[
1274 AC_TRY_RUN([#include <stdlib.h>
1275 #include <string.h>
1276 int main() {
1277   char p[10];
1278   (void) strlcpy (p, "hi", 10);
1279   if (strlcat (p, "bye", 0) != 3) 
1280     return 1;
1281   return 0;
1282 }], glib_cv_have_strlcpy=yes, 
1283     glib_cv_have_strlcpy=no,
1284     glib_cv_have_strlcpy=no)])
1285 if test "$glib_cv_have_strlcpy" = "yes"; then
1286     AC_DEFINE(HAVE_STRLCPY,1,[Have functions strlcpy and strlcat])
1287 fi
1288   
1289
1290 dnl **********************
1291 dnl *** va_copy checks ***
1292 dnl **********************
1293 dnl we currently check for all three va_copy possibilities, so we get
1294 dnl all results in config.log for bug reports.
1295 AC_CACHE_CHECK([for an implementation of va_copy()],glib_cv_va_copy,[
1296         AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <stdarg.h>
1297 #include <stdlib.h>
1298         void f (int i, ...) {
1299         va_list args1, args2;
1300         va_start (args1, i);
1301         va_copy (args2, args1);
1302         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1303           exit (1);
1304         va_end (args1); va_end (args2);
1305         }
1306         int main() {
1307           f (0, 42);
1308           return 0;
1309         }]])],
1310         [glib_cv_va_copy=yes],
1311         [glib_cv_va_copy=no])
1312 ])
1313 AC_CACHE_CHECK([for an implementation of __va_copy()],glib_cv___va_copy,[
1314         AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <stdarg.h>
1315 #include <stdlib.h>
1316         void f (int i, ...) {
1317         va_list args1, args2;
1318         va_start (args1, i);
1319         __va_copy (args2, args1);
1320         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1321           exit (1);
1322         va_end (args1); va_end (args2);
1323         }
1324         int main() {
1325           f (0, 42);
1326           return 0;
1327         }]])],
1328         [glib_cv___va_copy=yes],
1329         [glib_cv___va_copy=no])
1330 ])
1331
1332 if test "x$glib_cv_va_copy" = "xyes"; then
1333   g_va_copy_func=va_copy
1334 else if test "x$glib_cv___va_copy" = "xyes"; then
1335   g_va_copy_func=__va_copy
1336 fi
1337 fi
1338
1339 if test -n "$g_va_copy_func"; then
1340   AC_DEFINE_UNQUOTED(G_VA_COPY,$g_va_copy_func,[A 'va_copy' style function])
1341 fi
1342
1343 AC_CACHE_CHECK([whether va_lists can be copied by value],glib_cv_va_val_copy,[
1344         AC_TRY_RUN([#include <stdarg.h>
1345 #include <stdlib.h> 
1346         void f (int i, ...) {
1347         va_list args1, args2;
1348         va_start (args1, i);
1349         args2 = args1;
1350         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1351           exit (1);
1352         va_end (args1); va_end (args2);
1353         }
1354         int main() {
1355           f (0, 42);
1356           return 0;
1357         }],
1358         [glib_cv_va_val_copy=yes],
1359         [glib_cv_va_val_copy=no],
1360         [glib_cv_va_val_copy=yes])
1361 ])
1362
1363 AS_IF([ test "x$glib_cv_va_val_copy" = "xno"], [
1364   AC_DEFINE(G_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
1365 ])
1366
1367 dnl ***********************
1368 dnl *** g_module checks ***
1369 dnl ***********************
1370 G_MODULE_LIBS=
1371 G_MODULE_LIBS_EXTRA=
1372 G_MODULE_PLUGIN_LIBS=
1373 if test x"$glib_native_win32" = xyes; then
1374   dnl No use for this on Win32
1375   G_MODULE_LDFLAGS=
1376 else
1377   export SED
1378   eval G_MODULE_LDFLAGS=$export_dynamic_flag_spec
1379 fi
1380 dnl G_MODULE_IMPL= don't reset, so cmd-line can override
1381 G_MODULE_NEED_USCORE=0
1382 G_MODULE_BROKEN_RTLD_GLOBAL=0
1383 G_MODULE_HAVE_DLERROR=0
1384 dnl *** force native WIN32 shared lib loader 
1385 if test -z "$G_MODULE_IMPL"; then
1386   case "$host" in
1387   *-*-mingw*|*-*-cygwin*) G_MODULE_IMPL=G_MODULE_IMPL_WIN32 ;;
1388   esac
1389 fi
1390 dnl *** force native AIX library loader
1391 dnl *** dlopen() filepath must be of the form /path/libname.a(libname.so)
1392 if test -z "$G_MODULE_IMPL"; then
1393   case "$host" in
1394   *-*-aix*) G_MODULE_IMPL=G_MODULE_IMPL_AR ;;
1395   esac
1396 fi
1397 dnl *** dlopen() and dlsym() in system libraries
1398 AS_IF([ test -z "$G_MODULE_IMPL"], [
1399         AC_CHECK_FUNC(dlopen,
1400                       [AC_CHECK_FUNC(dlsym,
1401                                      [G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
1402                       [])
1403 ])
1404 dnl *** NSLinkModule (dyld) in system libraries (Darwin)
1405 AS_IF([ test -z "$G_MODULE_IMPL" ], [
1406         AC_CHECK_FUNC(NSLinkModule,
1407                       [G_MODULE_IMPL=G_MODULE_IMPL_DYLD
1408                        G_MODULE_NEED_USCORE=1],
1409                       [])
1410 ])
1411 dnl *** dlopen() and dlsym() in libdl
1412 AS_IF([ test -z "$G_MODULE_IMPL"], [
1413         AC_CHECK_LIB(dl, dlopen,
1414                      [AC_CHECK_LIB(dl, dlsym,
1415                                    [G_MODULE_LIBS=-ldl
1416                                    G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
1417                      [])
1418 ])
1419 dnl *** additional checks for G_MODULE_IMPL_DL
1420 AS_IF([ test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL" ], [
1421         LIBS_orig="$LIBS"
1422         LDFLAGS_orig="$LDFLAGS"
1423         LIBS="$G_MODULE_LIBS $LIBS"
1424         LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
1425 dnl *** check for OSF1/5.0 RTLD_GLOBAL brokenness
1426         echo "void glib_plugin_test(void) { }" > plugin.c
1427         ${SHELL} ./libtool --mode=compile --tag=CC ${CC} ${CFLAGS} \
1428                 ${CPPFLAGS} -c -o plugin.lo plugin.c >/dev/null 2>&1
1429         ${SHELL} ./libtool --mode=link --tag=CC ${CC} ${CFLAGS} \
1430                 ${LDFLAGS} -module -o plugin.la -export-dynamic \
1431                 -shrext ".o" -avoid-version plugin.lo \
1432                 -rpath /dont/care >/dev/null 2>&1
1433         AC_CACHE_CHECK([for RTLD_GLOBAL brokenness],
1434                 glib_cv_rtldglobal_broken,[
1435                 AC_TRY_RUN([
1436 #include <dlfcn.h>
1437 #ifndef RTLD_GLOBAL
1438 #  define RTLD_GLOBAL 0
1439 #endif
1440 #ifndef RTLD_LAZY
1441 #  define RTLD_LAZY 0
1442 #endif
1443 int glib_plugin_test;
1444 int main () {
1445     void *handle, *global, *local;
1446     global = &glib_plugin_test;
1447     handle = dlopen ("./$objdir/plugin.o", RTLD_GLOBAL | RTLD_LAZY);
1448     if (!handle) return 0;
1449     local = dlsym (handle, "glib_plugin_test");
1450     return global == local;
1451 }                       ],
1452                         [glib_cv_rtldglobal_broken=no],
1453                         [glib_cv_rtldglobal_broken=yes],
1454                         [glib_cv_rtldglobal_broken=no])
1455                 rm -f plugin.c plugin.o plugin.lo plugin.la ${objdir}/plugin.*
1456                 rmdir ${objdir} 2>/dev/null
1457         ])
1458         if test "x$glib_cv_rtldglobal_broken" = "xyes"; then
1459                 G_MODULE_BROKEN_RTLD_GLOBAL=1
1460         else
1461                 G_MODULE_BROKEN_RTLD_GLOBAL=0
1462         fi
1463 dnl *** check whether we need preceeding underscores
1464         AC_CACHE_CHECK([for preceeding underscore in symbols],
1465                 glib_cv_uscore,[
1466                 AC_TRY_RUN([#include <dlfcn.h>
1467                 int glib_underscore_test (void) { return 42; }
1468                 int main() {
1469                   void *f1 = (void*)0, *f2 = (void*)0, *handle;
1470                   handle = dlopen ((void*)0, 0);
1471                   if (handle) {
1472                     f1 = dlsym (handle, "glib_underscore_test");
1473                     f2 = dlsym (handle, "_glib_underscore_test");
1474                   } return (!f2 || f1);
1475                 }],
1476                         [glib_cv_uscore=yes],
1477                         [glib_cv_uscore=no],
1478                         [])
1479                 rm -f plugin.c plugin.$ac_objext plugin.lo
1480         ])
1481         GLIB_ASSERT_SET(glib_cv_uscore)
1482         if test "x$glib_cv_uscore" = "xyes"; then
1483                 G_MODULE_NEED_USCORE=1
1484         else
1485                 G_MODULE_NEED_USCORE=0
1486         fi
1487
1488         AC_CHECK_DECL([RTLD_LAZY],
1489                       [AC_DEFINE(HAVE_RTLD_LAZY, 1, [Define to 1 if RTLD_LAZY is available])],
1490                       [], [[#include <dlfcn.h>]])
1491         AC_CHECK_DECL([RTLD_NOW],
1492                       [AC_DEFINE(HAVE_RTLD_NOW, 1, [Define to 1 if RTLD_NOW is available])],
1493                       [], [[#include <dlfcn.h>]])
1494         AC_CHECK_DECL([RTLD_GLOBAL],
1495                       [AC_DEFINE(HAVE_RTLD_GLOBAL, 1, [Define to 1 if RTLD_GLOBAL is available])],
1496                       [], [[#include <dlfcn.h>]])
1497
1498         LDFLAGS="$LDFLAGS_orig"
1499 dnl *** check for having dlerror()
1500         AC_CHECK_FUNC(dlerror,
1501                 [G_MODULE_HAVE_DLERROR=1],
1502                 [G_MODULE_HAVE_DLERROR=0])
1503         LIBS="$LIBS_orig"
1504 ])
1505 dnl *** done, have we got an implementation?
1506 if test -z "$G_MODULE_IMPL"; then
1507         G_MODULE_IMPL=0
1508         G_MODULE_SUPPORTED=false
1509 else
1510         G_MODULE_SUPPORTED=true
1511 fi
1512
1513 AC_MSG_CHECKING(for the suffix of module shared libraries)
1514 export SED
1515 module=yes eval std_shrext=$shrext_cmds
1516 # chop the initial dot
1517 glib_gmodule_suffix=`echo $std_shrext | sed 's/^\.//'`
1518 AC_MSG_RESULT(.$glib_gmodule_suffix)
1519 # any reason it may fail?
1520 if test "x$glib_gmodule_suffix" = x; then
1521         AC_MSG_ERROR(Cannot determine shared library suffix from libtool)
1522 fi
1523  
1524 AC_SUBST(G_MODULE_SUPPORTED)
1525 AC_SUBST(G_MODULE_IMPL)
1526 AC_SUBST(G_MODULE_LIBS)
1527 AC_SUBST(G_MODULE_LIBS_EXTRA)
1528 AC_SUBST(G_MODULE_PLUGIN_LIBS)
1529 AC_SUBST(G_MODULE_LDFLAGS)
1530 AC_SUBST(G_MODULE_HAVE_DLERROR)
1531 AC_SUBST(G_MODULE_BROKEN_RTLD_GLOBAL)
1532 AC_SUBST(G_MODULE_NEED_USCORE)
1533 AC_SUBST(GLIB_DEBUG_FLAGS)
1534
1535 dnl **********************
1536 dnl *** g_spawn checks ***
1537 dnl **********************
1538
1539 AC_MSG_CHECKING(for gspawn implementation)
1540 case "$host" in
1541   *-*-mingw*)
1542     GSPAWN=gspawn-win32.lo
1543     ;;
1544   *)
1545     GSPAWN=gspawn.lo
1546     ;;    
1547 esac
1548 AC_MSG_RESULT($GSPAWN)
1549 AC_SUBST(GSPAWN)
1550
1551 dnl *************************
1552 dnl *** GIOChannel checks ***
1553 dnl *************************
1554
1555 AC_MSG_CHECKING(for GIOChannel implementation)
1556 case "$host" in
1557   *-*-mingw*)
1558     GIO=giowin32.lo
1559     ;;
1560   *)
1561     GIO=giounix.lo
1562     ;;    
1563 esac
1564 AC_MSG_RESULT($GIO)
1565 AC_SUBST(GIO)
1566
1567 dnl *********************************
1568 dnl *** Directory for GIO modules ***
1569 dnl *********************************
1570
1571 AC_ARG_WITH(gio-module-dir,
1572            [AS_HELP_STRING([--with-gio-module-dir=DIR],
1573                            [load gio modules from this directory [LIBDIR/gio/modules]])],
1574            [],
1575            [with_gio_module_dir='${libdir}/gio/modules'])
1576 GIO_MODULE_DIR=$with_gio_module_dir
1577 AC_SUBST(GIO_MODULE_DIR)
1578
1579 dnl **********************************
1580 dnl *** Check for libselinux (GIO) ***
1581 dnl **********************************
1582 AC_ARG_ENABLE(selinux,
1583               AS_HELP_STRING([--disable-selinux],
1584                              [build without selinux support]))
1585 msg_selinux=no
1586 SELINUX_LIBS=
1587 AS_IF([ test "x$enable_selinux" != "xno"], [
1588
1589  AC_CHECK_LIB(selinux, is_selinux_enabled,
1590    [AC_CHECK_HEADERS(selinux/selinux.h,
1591      [AC_CHECK_LIB(selinux, lgetfilecon_raw, 
1592        [AC_DEFINE(HAVE_SELINUX, 1, [Define to 1 if libselinux is available])
1593         SELINUX_LIBS="-lselinux"
1594         msg_selinux=yes])
1595      ])
1596    ])
1597 ])
1598 AC_SUBST(SELINUX_LIBS)
1599
1600 dnl *****************************
1601 dnl ** Check for inotify (GIO) **
1602 dnl *****************************
1603 inotify_support=no
1604 AC_CHECK_HEADERS([sys/inotify.h],
1605 [
1606   AC_CHECK_FUNCS(inotify_init1, [inotify_support=yes], [inotify_support=no])
1607 ])
1608
1609 AM_CONDITIONAL(HAVE_INOTIFY, [test "$inotify_support" = "yes"])
1610
1611 dnl ****************************
1612 dnl ** Check for kqueue (GIO) **
1613 dnl ****************************
1614 kqueue_support=no
1615 AC_CHECK_HEADERS([sys/event.h],
1616 [
1617         AC_CHECK_FUNCS(kqueue kevent, [kqueue_support=yes])
1618 ])
1619
1620 AM_CONDITIONAL(HAVE_KQUEUE, [test "$kqueue_support" = "yes"])
1621
1622 dnl ****************************
1623 dnl *** Checks for FAM (GIO) ***
1624 dnl ****************************
1625
1626 should_disable_fam=no
1627
1628 AC_ARG_ENABLE(fam,
1629               AS_HELP_STRING([--disable-fam],
1630                              [don't use fam for file system monitoring]),
1631                          [
1632                                 if test "x$enable_fam" = "xno"; then
1633                                         should_disable_fam=yes
1634                                 fi
1635                          ]
1636                          )
1637 fam_support=no
1638 FAM_LIBS=
1639 if test "x$should_disable_fam" = "xno"; then
1640 AC_CHECK_LIB(fam, FAMOpen,
1641   [AC_CHECK_HEADERS(fam.h,
1642     [AC_DEFINE(HAVE_FAM, [], [Define if we have FAM])
1643      AC_CHECK_LIB(fam, FAMNoExists,
1644                   AC_DEFINE(HAVE_FAM_NO_EXISTS, [], [Define if we have FAMNoExists in fam]))
1645      FAM_LIBS="-lfam"]
1646      fam_support=yes,
1647     AC_MSG_WARN(*** FAM support will not be built (header files not found) ***))],
1648   AC_MSG_WARN(*** FAM support will not be built (FAM library not found) ***))
1649 AC_SUBST(FAM_LIBS)
1650 fi
1651 AM_CONDITIONAL(HAVE_FAM, [test "$fam_support" = "yes"])
1652
1653
1654 dnl *****************************
1655 dnl *** Check for xattr (GIO) ***
1656 dnl *****************************
1657 AC_ARG_ENABLE(xattr,
1658               AS_HELP_STRING([--disable-xattr], [build without xattr support]))
1659 msg_xattr=no
1660 XATTR_LIBS=
1661 AS_IF([ test "x$enable_xattr" != "xno"], [
1662
1663 dnl either glibc or libattr can provide xattr support
1664
1665 dnl for both of them, we check for getxattr being in
1666 dnl the library and a valid xattr header.
1667
1668 dnl try glibc
1669  AC_CHECK_LIB(c, getxattr,
1670    [AC_CHECK_HEADERS(sys/xattr.h,
1671      [AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if xattr is available])
1672       msg_xattr=yes])
1673    ])
1674
1675   AS_IF([ test "x$msg_xattr" != "xyes"], [
1676 dnl   failure. try libattr
1677    AC_CHECK_LIB(attr, getxattr,
1678       [AC_CHECK_HEADERS(attr/xattr.h,
1679        [AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if xattr is available])
1680         XATTR_LIBS="-lattr"
1681         msg_xattr=yes])
1682       ])
1683   ])
1684
1685   AS_IF([ test "x$msg_xattr" = "xyes"], [
1686     AC_MSG_CHECKING([for XATTR_NOFOLLOW])
1687     AC_TRY_COMPILE([
1688       #include <stdio.h>
1689       #ifdef HAVE_SYS_TYPES_H
1690       #include <sys/types.h>
1691       #endif
1692       #ifdef HAVE_SYS_XATTR_H
1693       #include <sys/xattr.h>
1694       #elif HAVE_ATTR_XATTR_H
1695       #include <attr/xattr.h>
1696       #endif
1697     ],
1698     [ssize_t len = getxattr("", "", NULL, 0, 0, XATTR_NOFOLLOW);],
1699     [
1700       AC_DEFINE([HAVE_XATTR_NOFOLLOW], [1], [Define to 1 if xattr API uses XATTR_NOFOLLOW])
1701       AC_MSG_RESULT([yes])
1702     ],
1703     [AC_MSG_RESULT([no])]
1704     )
1705   ])
1706 ])
1707 AC_SUBST(XATTR_LIBS)
1708
1709 dnl ************************
1710 dnl *** check for libelf ***
1711 dnl ************************
1712 AC_ARG_ENABLE(libelf,
1713               AS_HELP_STRING([--disable-libelf], [build without libelf support]))
1714 AS_IF([ test "x$enable_libelf" != "xno"],[
1715 PKG_CHECK_MODULES([LIBELF], [libelf >= 0.8.12], [have_libelf=yes], [have_libelf=maybe])
1716 AS_IF([ test $have_libelf = maybe ], [
1717   glib_save_LIBS=$LIBS
1718   AC_CHECK_LIB([elf], [elf_begin], [:], [have_libelf=no])
1719   AC_CHECK_LIB([elf], [elf_getshdrstrndx], [:], [have_libelf=no])
1720   AC_CHECK_LIB([elf], [elf_getshdrnum], [:], [have_libelf=no])
1721   AC_CHECK_HEADER([libelf.h], [:], [have_libelf=no])
1722   LIBS=$glib_save_LIBS
1723
1724   if test $have_libelf != no; then
1725     LIBELF_LIBS=-lelf
1726     have_libelf=yes
1727   fi
1728 ])
1729 ])
1730
1731 if test x$have_libelf = xyes; then
1732   AC_DEFINE(HAVE_LIBELF, 1, [Define if libelf is available])
1733 fi
1734
1735 dnl ************************
1736 dnl *** check for libmount ***
1737 dnl ************************
1738
1739 dnl The fallback code doesn't really implement the same behaviors - e.g.
1740 dnl so on linux we want to require libmount unless specifically disabled
1741 dnl
1742 enable_libmount_default=${glib_os_linux:-no}
1743 AC_ARG_ENABLE(libmount,
1744               [AS_HELP_STRING([--enable-libmount],
1745                               [build with libmount support [default for Linux]])],,
1746               [enable_libmount=$enable_libmount_default])
1747 AS_IF([ test "x$enable_libmount" = "xyes"],[
1748 PKG_CHECK_MODULES([LIBMOUNT], [mount >= 2.28], [have_libmount=yes], [have_libmount=maybe])
1749 AS_IF([ test $have_libmount = maybe ], [
1750   glib_save_LIBS=$LIBS
1751   AC_CHECK_HEADER([libmount/libmount.h], [:], [have_libmount=no])
1752
1753   # We used to check for mnt_unref_table(), but now for compat with
1754   # e.g. RHEL7 just use mnt_free_table().  Let's keep this check
1755   # anyways.
1756   AC_CHECK_LIB([mount], [mnt_free_table], [:], [have_libmount=no])
1757   LIBS=$glib_save_LIBS
1758
1759   if test $have_libmount != no; then
1760     LIBMOUNT_LIBS=-lmount
1761     have_libmount=yes
1762   fi
1763 ])
1764 if test $have_libmount = no ; then
1765    AC_MSG_ERROR([*** Could not find libmount])
1766 fi
1767 ])
1768
1769 if test x$have_libmount = xyes; then
1770   AC_DEFINE(HAVE_LIBMOUNT, 1, [Define if libmount is available])
1771 fi
1772 AM_CONDITIONAL(HAVE_LIBMOUNT, [test x$have_libmount = xyes])
1773
1774 dnl ****************************************
1775 dnl *** platform dependent source checks ***
1776 dnl ****************************************
1777
1778 AC_MSG_CHECKING(for platform-dependent source)
1779 case "$host" in
1780   *-*-cygwin*|*-*-mingw*)
1781     PLATFORMDEP=gwin32.lo
1782     ;;
1783   *)
1784     PLATFORMDEP=
1785     ;;    
1786 esac
1787 AC_MSG_RESULT($PLATFORMDEP)
1788 AC_SUBST(PLATFORMDEP)
1789
1790 AC_MSG_CHECKING([whether to compile timeloop])
1791 case "$host" in
1792   *-*-cygwin*|*-*-mingw*|*-*-minix)
1793     enable_timeloop=no
1794     ;;
1795   *)
1796     enable_timeloop=yes
1797     ;;    
1798 esac
1799 AC_MSG_RESULT($enable_timeloop)
1800 AM_CONDITIONAL(ENABLE_TIMELOOP, test x$enable_timeloop = xyes)
1801
1802 AC_MSG_CHECKING([if building for some Win32 platform])
1803 case "$host" in
1804   *-*-mingw*|*-*-cygwin*)
1805     platform_win32=yes
1806     ;;
1807   *)
1808     platform_win32=no
1809     ;;
1810 esac
1811 AC_MSG_RESULT($platform_win32)
1812 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
1813
1814 dnl ***********************
1815 dnl *** g_thread checks ***
1816 dnl ***********************
1817
1818 AC_ARG_WITH(threads,
1819            [AS_HELP_STRING([--with-threads=@<:@posix/win32@:>@],
1820                            [specify a thread implementation to use])],
1821            [],
1822            [with_threads=yes])
1823
1824 dnl error and warning message
1825 dnl *************************
1826
1827 THREAD_NO_IMPLEMENTATION="No thread implementation found."
1828
1829 FLAG_DOES_NOT_WORK="I can't find the MACRO to enable thread safety on your
1830                 platform (normally it's "_REENTRANT"). I'll not use any flag on
1831                 compilation now, but then your programs might not work.
1832                 Please provide information on how it is done on your system."
1833
1834 LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
1835                  "
1836
1837 LIBS_NOT_FOUND_2=". Please choose another thread implementation or
1838                   provide information on your thread implementation."
1839
1840 FUNC_NO_GETPWUID_R="the 'g_get_(user_name|real_name|home_dir|tmp_dir)'
1841                 functions will not be MT-safe during their first call because
1842                 there is no working 'getpwuid_r' on your system."
1843
1844 FUNC_NO_LOCALTIME_R="the 'g_date_set_time' function will not be MT-safe
1845                 because there is no 'localtime_r' on your system."
1846
1847 AIX_COMPILE_INFO="AIX's C compiler needs to be called by a different name, when
1848                 linking threaded applications. As GLib cannot do that 
1849                 automatically, you will get an linkg error everytime you are 
1850                 not using the right compiler. In that case you have to relink 
1851                 with the right compiler. Ususally just '_r' is appended 
1852                 to the compiler name."
1853
1854 dnl determination of thread implementation
1855 dnl ***************************************
1856
1857 AC_MSG_CHECKING(for thread implementation)
1858
1859 have_threads=no
1860 AS_IF([ test "x$with_threads" = xyes || test "x$with_threads" = xposix], [
1861         AS_IF([ test "x$have_threads" = xno], [
1862                 AC_TRY_COMPILE([#include <pthread.h>],
1863                         [pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;],
1864                         have_threads=posix)
1865         ])
1866         # Tru64Unix requires -pthread to find pthread.h. See #103020
1867         if test "x$have_threads" = xno; then
1868                 glib_save_CPPFLAGS="$CPPFLAGS"
1869                 CPPFLAGS="$CPPFLAGS -pthread"
1870                 AC_TRY_COMPILE([#include <pthread.h>],
1871                        [pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;],
1872                        have_threads=posix)
1873                 CPPFLAGS="$glib_save_CPPFLAGS"
1874         fi
1875 ])
1876 if test "x$with_threads" = xyes || test "x$with_threads" = xwin32; then
1877         case $host in
1878                 *-*-mingw*)
1879                 have_threads=win32
1880                 ;;
1881         esac
1882 fi
1883
1884 if test "x$have_threads" = xno; then
1885         AC_MSG_RESULT(none available)
1886         AC_MSG_ERROR($THREAD_NO_IMPLEMENTATION)
1887 else
1888         AC_MSG_RESULT($have_threads)
1889 fi
1890
1891
1892 dnl determination of G_THREAD_CFLAGS
1893 dnl ********************************
1894
1895 G_THREAD_LIBS=
1896 G_THREAD_LIBS_EXTRA=
1897 G_THREAD_CFLAGS=
1898
1899 dnl
1900 dnl Test program for basic POSIX threads functionality
1901 dnl
1902 m4_define([glib_thread_test],[
1903 #include <pthread.h> 
1904 int check_me = 0;
1905 void* func(void* data) {check_me = 42; return &check_me;}
1906 int main()
1907  { pthread_t t; 
1908    void *ret;
1909    pthread_create (&t, $1, func, 0);
1910    pthread_join (t, &ret);
1911    return (check_me != 42 || ret != &check_me);
1912 }])
1913
1914 AS_IF([ test x"$have_threads" = xposix], [
1915   # First we test for posix, whether -pthread or -pthreads do the trick as 
1916   # both CPPFLAG and LIBS. 
1917   # One of them does for most gcc versions and some other platforms/compilers
1918   # too and could be considered as the canonical way to go. 
1919   case $host in
1920     *-*-cygwin*|*-*-darwin*)
1921        # skip cygwin and darwin -pthread or -pthreads test
1922        ;;
1923     *-solaris*)
1924       # These compiler/linker flags work with both Sun Studio and gcc
1925       # Sun Studio expands -mt to -D_REENTRANT and -lthread
1926       # gcc expands -pthreads to -D_REENTRANT -D_PTHREADS -lpthread
1927       G_THREAD_CFLAGS="-D_REENTRANT -D_PTHREADS"
1928       G_THREAD_LIBS="-lpthread -lthread"
1929       ;;
1930     *)
1931       for flag in pthread pthreads mt; do
1932         glib_save_CFLAGS="$CFLAGS"
1933         CFLAGS="$CFLAGS -$flag"
1934         AC_TRY_RUN(glib_thread_test(0),
1935                    glib_flag_works=yes,
1936                    glib_flag_works=no,
1937                    [AC_LINK_IFELSE([AC_LANG_SOURCE(glib_thread_test(0))],
1938                                    glib_flag_works=yes,
1939                                    glib_flag_works=no)])
1940         CFLAGS="$glib_save_CFLAGS"
1941         if test $glib_flag_works = yes ; then
1942            G_THREAD_CFLAGS=-$flag
1943         G_THREAD_LIBS=-$flag
1944         break;
1945         fi
1946       done
1947        ;;
1948   esac
1949 ])
1950
1951 AS_IF([ test x"$G_THREAD_CFLAGS" = x], [
1952
1953   # The canonical -pthread[s] does not work. Try something different.
1954
1955   case $host in
1956         *-aix*)
1957                 if test x"$GCC" = xyes; then
1958                         # GCC 3.0 and above needs -pthread. 
1959                         # Should be coverd by the case above.
1960                         # GCC 2.x and below needs -mthreads
1961                         G_THREAD_CFLAGS="-mthreads"             
1962                         G_THREAD_LIBS=$G_THREAD_CFLAGS
1963                 else 
1964                         # We are probably using the aix compiler. Normaly a 
1965                         # program would have to be compiled with the _r variant
1966                         # of the corresponding compiler, but we as GLib cannot 
1967                         # do that: but the good news is that for compiling the
1968                         # only difference is the added -D_THREAD_SAFE compile 
1969                         # option. This is according to the "C for AIX User's 
1970                         # Guide".
1971                         G_THREAD_CFLAGS="-D_THREAD_SAFE"
1972                 fi
1973                 ;;
1974         *-sysv5uw7*) # UnixWare 7 
1975                 # We are not using gcc with -pthread. Catched above.
1976                 G_THREAD_CFLAGS="-Kthread"
1977                 G_THREAD_LIBS=$G_THREAD_CFLAGS
1978                 ;;
1979         *-mingw*)
1980                 # No flag needed when using MSVCRT.DLL
1981                 G_THREAD_CFLAGS=""
1982                 ;;
1983         *)
1984                 G_THREAD_CFLAGS="-D_REENTRANT" # good default guess otherwise
1985                 ;;
1986   esac
1987 ])
1988
1989 # if we are not finding the localtime_r function, then we probably are
1990 # not using the proper multithread flag
1991
1992 glib_save_CPPFLAGS="$CPPFLAGS"
1993 CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
1994
1995 # First we test, whether localtime_r is declared in time.h
1996 # directly. Then we test whether a macro localtime_r exists, in
1997 # which case localtime_r in the test program is replaced and thus
1998 # if we still find localtime_r in the output, it is not defined as 
1999 # a macro.
2000
2001 AC_EGREP_CPP([[^a-zA-Z1-9_]localtime_r[^a-zA-Z1-9_]], [#include <time.h>], ,
2002   [AC_EGREP_CPP([[^a-zA-Z1-9_]localtime_r[^a-zA-Z1-9_]], [#include <time.h> 
2003                                                            localtime_r(a,b)],
2004                    AC_MSG_WARN($FLAG_DOES_NOT_WORK))])
2005
2006 CPPFLAGS="$glib_save_CPPFLAGS"
2007
2008 AC_MSG_CHECKING(thread related cflags)
2009 AC_MSG_RESULT($G_THREAD_CFLAGS)
2010 CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
2011
2012 dnl determination of G_THREAD_LIBS
2013 dnl ******************************
2014
2015 AS_IF([test x$have_threads = xposix], [
2016           glib_save_CPPFLAGS="$CPPFLAGS"
2017           CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
2018           AS_IF([ test x"$G_THREAD_LIBS" = x ], [
2019             case $host in
2020               *-aix*)
2021                 # We are not using gcc (would have set G_THREAD_LIBS) and thus 
2022                 # probably using the aix compiler.
2023                 AC_MSG_WARN($AIX_COMPILE_INFO)
2024                 ;;
2025               *)
2026                 G_THREAD_LIBS=error
2027                 glib_save_LIBS="$LIBS"
2028                 for thread_lib in "" pthread pthread32 pthreads thread; do
2029                         if test x"$thread_lib" = x; then
2030                                 add_thread_lib=""
2031                                 IN=""
2032                         else
2033                                 add_thread_lib="-l$thread_lib"
2034                                 IN=" in -l$thread_lib"
2035                         fi
2036                         if test x"$have_threads" = xposix; then
2037                                 defattr=0
2038                         else
2039                                 defattr=pthread_attr_default
2040                         fi
2041                         
2042                         LIBS="$add_thread_lib $glib_save_LIBS"
2043                         
2044                         AC_MSG_CHECKING(for pthread_create/pthread_join$IN)
2045                         AC_TRY_RUN(glib_thread_test($defattr),
2046                                    glib_result=yes,
2047                                    glib_result=no,
2048                                    [AC_LINK_IFELSE([AC_LANG_SOURCE(glib_thread_test($defattr))],
2049                                                    glib_result=yes,
2050                                                    glib_result=no)])
2051                         AC_MSG_RESULT($glib_result)
2052                         
2053                         if test "$glib_result" = "yes" ; then
2054                           G_THREAD_LIBS="$add_thread_lib"
2055                           break
2056                         fi
2057                 done
2058                 if test "x$G_THREAD_LIBS" = xerror; then
2059                   AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
2060                 fi 
2061                 LIBS="$glib_save_LIBS"
2062                 ;;
2063             esac
2064           ])
2065
2066           g_threads_impl="POSIX"
2067           AC_DEFINE([THREADS_POSIX], [1], [Use pthreads])
2068           AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES)
2069           CPPFLAGS="$glib_save_CPPFLAGS"
2070 ], [test x$have_threads = xwin32], [
2071            AC_DEFINE([THREADS_WIN32], [1], [Use w32 threads])
2072            g_threads_impl="WIN32"
2073 ], [
2074            AC_DEFINE([THREADS_NONE], [1], [Use no threads])
2075            g_threads_impl="NONE"
2076            G_THREAD_LIBS=error
2077 ])
2078 AM_CONDITIONAL(THREADS_POSIX, [test "$g_threads_impl" = "POSIX"])
2079 AM_CONDITIONAL(THREADS_WIN32, [test "$g_threads_impl" = "WIN32"])
2080 AM_CONDITIONAL(THREADS_NONE, [test "$g_threads_impl" = "NONE"])
2081
2082 if test "x$G_THREAD_LIBS" = xerror; then
2083         AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
2084 fi
2085
2086 AC_MSG_CHECKING(thread related libraries)
2087 AC_MSG_RESULT($G_THREAD_LIBS)
2088
2089 dnl check for mt safe function variants and some posix functions
2090 dnl ************************************************************
2091
2092 glib_save_LIBS="$LIBS"
2093 # we are not doing the following for now, as this might require glib 
2094 # to always be linked with the thread libs on some platforms. 
2095 # LIBS="$LIBS $G_THREAD_LIBS"
2096 AC_CHECK_FUNCS(localtime_r gmtime_r getpwuid_r getgrgid_r)
2097
2098 LIBS="$G_THREAD_LIBS $LIBS"
2099 AS_IF([ test x"$have_threads" = xposix], [
2100         glib_save_CPPFLAGS="$CPPFLAGS"
2101         CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
2102         # This is not AC_CHECK_FUNC to also work with function
2103         # name mangling in header files.
2104         AC_MSG_CHECKING(for pthread_attr_setstacksize)
2105         AC_LINK_IFELSE(
2106             [AC_LANG_PROGRAM(
2107                 [#include <pthread.h>],
2108                 [pthread_attr_t t; pthread_attr_setstacksize(&t,0)])],
2109             [AC_MSG_RESULT(yes)
2110              AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE,1,
2111                 [Have function pthread_attr_setstacksize])],
2112             [AC_MSG_RESULT(no)])
2113         AC_MSG_CHECKING(for pthread_condattr_setclock)
2114         AC_LINK_IFELSE(
2115             [AC_LANG_PROGRAM(
2116                 [#include <pthread.h>],
2117                 [pthread_condattr_t a; pthread_condattr_setclock(&a,0)])],
2118             [AC_MSG_RESULT(yes)
2119              AC_DEFINE(HAVE_PTHREAD_CONDATTR_SETCLOCK,1,
2120                 [Have function pthread_condattr_setclock])],
2121             [AC_MSG_RESULT(no)])
2122         AC_MSG_CHECKING(for pthread_cond_timedwait_relative_np)
2123         AC_LINK_IFELSE(
2124             [AC_LANG_PROGRAM(
2125                 [#include <pthread.h>],
2126                 [pthread_cond_timedwait_relative_np(NULL, NULL, NULL)])],
2127             [AC_MSG_RESULT(yes)
2128              AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP,1,
2129                 [Have function pthread_cond_timedwait_relative_np])],
2130             [AC_MSG_RESULT(no)])
2131         dnl Sets thread names on OS X 10.6, iOS 3.2 (and higher)
2132         AC_MSG_CHECKING(for pthread_setname_np(const char*))
2133         AC_LINK_IFELSE(
2134             [AC_LANG_PROGRAM(
2135                 [#include <pthread.h>],
2136                 [pthread_setname_np("example")])],
2137             [AC_MSG_RESULT(yes)
2138              AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
2139                 [Have function pthread_setname_np(const char*)])],
2140             [AC_MSG_RESULT(no)])
2141         dnl Sets thread names on Solaris 11.3 & higher
2142         AC_MSG_CHECKING(for pthread_setname_np(pthread_t, const char*))
2143         AC_LINK_IFELSE(
2144             [AC_LANG_PROGRAM(
2145                 [#include <pthread.h>],
2146                 [pthread_setname_np(pthread_self(), "example")])],
2147             [AC_MSG_RESULT(yes)
2148              AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1,
2149                 [Have function pthread_setname_np(pthread_t, const char*)])],
2150             [AC_MSG_RESULT(no)])
2151         CPPFLAGS="$glib_save_CPPFLAGS"
2152 ])
2153
2154 LIBS="$glib_save_LIBS"
2155
2156 # now spit out all the warnings.
2157 if test "$ac_cv_func_getpwuid_r" != "yes"; then
2158         AC_MSG_WARN($FUNC_NO_GETPWUID_R)
2159 fi
2160 if test "$ac_cv_func_localtime_r" != "yes"; then
2161         AC_MSG_WARN($FUNC_NO_LOCALTIME_R)
2162 fi
2163
2164 #
2165 # Hack to deal with:
2166
2167 #  a) GCC < 3.3 for Linux doesn't include -lpthread when
2168 #     building shared libraries with linux.
2169 #  b) FreeBSD doesn't do this either.
2170 #
2171 case $host in
2172   *android*)
2173     G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS"
2174     ;;
2175   *-*-freebsd*|*-*-linux*)
2176     G_THREAD_LIBS_FOR_GTHREAD="`echo $G_THREAD_LIBS | sed s/-pthread/-lpthread/`"
2177     ;;
2178   *)
2179     G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS"
2180     ;;
2181 esac
2182
2183 AC_SUBST(G_THREAD_CFLAGS)
2184 AC_SUBST(G_THREAD_LIBS)
2185 AC_SUBST(G_THREAD_LIBS_FOR_GTHREAD)
2186 AC_SUBST(G_THREAD_LIBS_EXTRA)
2187
2188 AC_CHECK_FUNCS(clock_gettime, [], [
2189   AC_CHECK_LIB(rt, clock_gettime, [
2190     G_THREAD_LIBS="$G_THREAD_LIBS -lrt"
2191     G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS_FOR_GTHREAD -lrt"
2192   ])
2193 ])
2194
2195
2196 dnl ************************
2197 dnl *** g_atomic_* tests ***
2198 dnl ************************
2199
2200 dnl We need to decide at configure time if GLib will use real atomic
2201 dnl operations ("lock free") or emulated ones with a mutex.  This is
2202 dnl because we must put this information in glibconfig.h so we know if
2203 dnl it is safe or not to inline using compiler intrinsics directly from
2204 dnl the header.
2205 dnl
2206 dnl We also publish the information via G_ATOMIC_LOCK_FREE in case the
2207 dnl user is interested in knowing if they can use the atomic ops across
2208 dnl processes.
2209 dnl
2210 dnl We can currently support the atomic ops natively when building GLib
2211 dnl with recent versions of GCC or MSVC.  MSVC doesn't run ./configure,
2212 dnl so we skip that case here and define G_ATOMIC_LOCK_FREE exactly when
2213 dnl we are using GCC (and not mingw*).
2214 dnl
2215 dnl Note that the atomic ops are only available with GCC on x86 when
2216 dnl using -march=i486 or higher.  If we detect that the atomic ops are
2217 dnl not available but would be available given the right flags, we want
2218 dnl to abort and advise the user to fix their CFLAGS.  It's better to do
2219 dnl that then to silently fall back on emulated atomic ops just because
2220 dnl the user had the wrong build environment.
2221
2222 dnl We may add other compilers here in the future...
2223
2224 AC_CACHE_CHECK([for lock-free atomic intrinsics], glib_cv_g_atomic_lock_free, [
2225   case $host in
2226     *-*-mingw*)
2227       glib_cv_g_atomic_lock_free=yes
2228       ;;
2229     *)
2230       AC_TRY_LINK([],
2231                      [volatile int atomic = 2;\
2232                       __sync_bool_compare_and_swap (&atomic, 2, 3);],
2233                      [glib_cv_g_atomic_lock_free=yes],
2234                      [glib_cv_g_atomic_lock_free=no])
2235       if test "$glib_cv_g_atomic_lock_free" = "no"; then
2236         SAVE_CFLAGS="${CFLAGS}"
2237         CFLAGS="-march=i486"
2238         AC_TRY_LINK([],
2239                        [volatile int atomic = 2;\
2240                         __sync_bool_compare_and_swap (&atomic, 2, 3);],
2241                        [AC_MSG_ERROR([GLib must be built with -march=i486 or later.])],
2242                        [])
2243         CFLAGS="${SAVE_CFLAGS}"
2244       fi
2245       ;;
2246   esac])
2247
2248
2249 case $host in
2250   *-*-mingw*)
2251     ;;
2252   *)
2253     # Some compilers support atomic operations but do not define
2254     # __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4, like clang
2255     if test x"$glib_cv_g_atomic_lock_free" = xyes; then
2256       AC_TRY_LINK([],
2257                      [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;],
2258                      [],
2259                      [AC_DEFINE(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4, 1, [ compiler supports atomic operations])])
2260     fi
2261     ;;
2262  esac
2263
2264 dnl We need a more robust approach here...
2265 case $host_cpu in
2266   i?86|x86_64|s390|s390x|arm*|crisv32*|etrax*)
2267     glib_memory_barrier_needed=no
2268     ;;
2269   sparc*|alpha*|powerpc*|ia64)
2270     glib_memory_barrier_needed=yes
2271     ;;
2272   *)
2273     glib_memory_barrier_needed=yes
2274     ;;
2275 esac
2276
2277 dnl ************************
2278 dnl ** Check for futex(2) **
2279 dnl ************************
2280 AC_CACHE_CHECK(for futex(2) system call,
2281     glib_cv_futex,AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
2282 #include <linux/futex.h>
2283 #include <sys/syscall.h>
2284 #include <unistd.h>
2285 ],[
2286   syscall (__NR_futex, NULL, FUTEX_WAKE, FUTEX_WAIT);
2287 ])],glib_cv_futex=yes,glib_cv_futex=no))
2288 if test x"$glib_cv_futex" = xyes; then
2289   AC_DEFINE(HAVE_FUTEX, 1, [we have the futex(2) system call])
2290 fi
2291
2292 AC_CACHE_CHECK(for eventfd(2) system call,
2293     glib_cv_eventfd,AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
2294 #include <sys/eventfd.h>
2295 #include <unistd.h>
2296 ],[
2297   eventfd (0, EFD_CLOEXEC);
2298 ])],glib_cv_eventfd=yes,glib_cv_eventfd=no))
2299 if test x"$glib_cv_eventfd" = x"yes"; then
2300   AC_DEFINE(HAVE_EVENTFD, 1, [we have the eventfd(2) system call])
2301 fi
2302 AM_CONDITIONAL(HAVE_EVENTFD, [test "$glib_cv_eventfd" = "yes"])
2303
2304 dnl ****************************************
2305 dnl *** GLib POLL* compatibility defines ***
2306 dnl ****************************************
2307
2308 glib_poll_includes=["
2309 #include <sys/types.h>
2310 #include <poll.h>
2311 "]
2312
2313 AS_IF([ test $ac_cv_header_sys_types_h = yes &&
2314    test $ac_cv_func_poll = yes ], [
2315   glib_failed=false
2316   GLIB_CHECK_VALUE(POLLIN, $glib_poll_includes, glib_failed=true)
2317   GLIB_CHECK_VALUE(POLLOUT, $glib_poll_includes, glib_failed=true)
2318   GLIB_CHECK_VALUE(POLLPRI, $glib_poll_includes, glib_failed=true)
2319   GLIB_CHECK_VALUE(POLLERR, $glib_poll_includes, glib_failed=true)
2320   GLIB_CHECK_VALUE(POLLHUP, $glib_poll_includes, glib_failed=true)
2321   GLIB_CHECK_VALUE(POLLNVAL, $glib_poll_includes, glib_failed=true)
2322   if $glib_failed ; then
2323     AC_MSG_ERROR([Could not determine values for POLL* constants])
2324   fi
2325 ], [
2326   glib_cv_value_POLLIN=1
2327   glib_cv_value_POLLOUT=4
2328   glib_cv_value_POLLPRI=2
2329   glib_cv_value_POLLERR=8
2330   glib_cv_value_POLLHUP=16
2331   glib_cv_value_POLLNVAL=32
2332 ])
2333
2334 AC_MSG_CHECKING([for broken poll])
2335 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2336         #include <stdlib.h>
2337         #include <fcntl.h>
2338         #include <poll.h>
2339         int main(void) {
2340           struct pollfd fds[1];
2341           int fd;
2342           fd = open("/dev/null", 1);
2343           fds[0].fd = fd;
2344           fds[0].events = POLLIN;
2345           fds[0].revents = 0;
2346           if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
2347                 exit(1);  /* Does not work for devices -- fail */
2348           }
2349           exit(0);
2350         }]])],
2351   [broken_poll=no],
2352   [broken_poll=yes
2353    AC_DEFINE(BROKEN_POLL,1,[poll doesn't work on devices])],
2354   [broken_poll="no (cross compiling)"])
2355 AC_MSG_RESULT($broken_poll)
2356
2357 dnl *********************
2358 dnl *** GRegex checks ***
2359 dnl *********************
2360
2361 PCRE_REQUIRED_VERSION=8.13
2362
2363 # Check if we should use the internal or the system-supplied pcre
2364 AC_ARG_WITH(pcre,
2365             [AS_HELP_STRING([--with-pcre=@<:@internal/system@:>@],
2366                             [whether to use system PCRE [default=system]])],
2367             [],
2368             [with_pcre=system])
2369
2370 AM_CONDITIONAL(USE_SYSTEM_PCRE, [test "x$with_pcre" = xsystem])
2371
2372 AS_IF([ test "x$with_pcre" = xsystem], [
2373   PKG_CHECK_MODULES(PCRE,
2374                     libpcre >= $PCRE_REQUIRED_VERSION)
2375   AC_CACHE_CHECK([for Unicode support in PCRE],glib_cv_pcre_has_unicode,[
2376                   glib_save_CFLAGS="$CFLAGS"
2377                   glib_save_LIBS="$LIBS"
2378                   CFLAGS="$CFLAGS $PCRE_CFLAGS" LIBS="$PCRE_LIBS"
2379                   AC_TRY_RUN([#include <pcre.h>
2380                               int main () {
2381                                 int support;
2382                                 pcre_config (PCRE_CONFIG_UTF8, &support);
2383                                 if (!support)
2384                                   return 1;
2385                                 pcre_config (PCRE_CONFIG_UNICODE_PROPERTIES, &support);
2386                                 if (!support)
2387                                   return 1;
2388                                 return 0;
2389                               }],
2390                   glib_cv_pcre_has_unicode=yes,
2391                   glib_cv_pcre_has_unicode=no,
2392                   glib_cv_pcre_has_unicode=yes)
2393                   CFLAGS="$glib_save_CFLAGS"
2394                   LIBS="$glib_save_LIBS"
2395       ])
2396   if test "$glib_cv_pcre_has_unicode" = "no"; then
2397     AC_MSG_ERROR([*** The system-supplied PCRE does not support Unicode properties or UTF-8.])
2398   fi
2399   AC_SUBST(PCRE_CFLAGS)
2400   AC_SUBST(PCRE_LIBS)
2401   AC_DEFINE(USE_SYSTEM_PCRE, [], [using the system-supplied PCRE library])
2402   PCRE_REQUIRES=libpcre
2403   AC_SUBST(PCRE_REQUIRES)
2404 ], [
2405   # If using gcc 4 pass -Wno-pointer-sign when compiling the internal PCRE
2406   AS_IF([ test x"$GCC" = xyes], [
2407     AC_MSG_CHECKING([whether compiler understands -Wno-pointer-sign])
2408     save_CFLAGS="$CFLAGS"
2409     CFLAGS="$CFLAGS -Wno-pointer-sign"
2410     AC_TRY_COMPILE([],[],[PCRE_WARN_CFLAGS="$PCRE_WARN_CFLAGS -Wno-pointer-sign"
2411                           AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
2412     CFLAGS="$save_CFLAGS"
2413   ])
2414 ])
2415 AC_SUBST(PCRE_WARN_CFLAGS)
2416
2417 dnl **********************
2418 dnl *** Win32 API libs ***
2419 dnl **********************
2420
2421 case $host in
2422   *-*-cygwin*)
2423         G_LIBS_EXTRA="-luser32 -lkernel32"
2424     ;;
2425   *-*-mingw*)
2426         G_LIBS_EXTRA="-lws2_32 -lole32 -lwinmm -lshlwapi"
2427     ;;
2428   *)
2429         G_LIBS_EXTRA=""
2430     ;;
2431 esac
2432 AC_SUBST(G_LIBS_EXTRA)
2433
2434 dnl If the system doesn't define EILSEQ, we should define EILSEQ ourselves
2435 dnl since we need it for g_iconv()
2436
2437 AC_MSG_CHECKING([for EILSEQ])
2438 AC_TRY_COMPILE([
2439 #include <errno.h>
2440 ],
2441 [
2442 int error = EILSEQ;
2443 ], have_eilseq=yes, have_eilseq=no);
2444 AC_MSG_RESULT($have_eilseq)
2445
2446 dnl Add a conditional we can use when cross-compiling, so we avoid running
2447 dnl binaries
2448 AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
2449
2450 dnl **************************
2451 dnl *** Checks for gtk-doc ***
2452 dnl **************************
2453 # gtkdocize greps for ^GTK_DOC_CHECK and parses it, so you need to have
2454 # it on it's own line.
2455 m4_ifdef([GTK_DOC_CHECK], [
2456 GTK_DOC_CHECK([1.20], [--flavour no-tmpl])
2457 ],[
2458 AM_CONDITIONAL([ENABLE_GTK_DOC],[false])
2459 ])
2460
2461 AC_ARG_ENABLE(man,
2462               [AS_HELP_STRING([--enable-man],
2463                               [generate man pages [default=auto]])],,
2464               enable_man=maybe)
2465
2466 AS_IF([test "$enable_man" != no], [
2467   AC_PATH_PROG([XSLTPROC], [xsltproc])
2468   AS_IF([test -z "$XSLTPROC"], [
2469     AS_IF([test "$enable_man" = yes], [
2470       AC_MSG_ERROR([xsltproc is required for --enable-man])
2471     ])
2472     enable_man=no
2473   ])
2474 ])
2475
2476 AS_IF([ test "$enable_man" != no ], [
2477   dnl check for DocBook DTD in the local catalog
2478   JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
2479      [DocBook XML DTD V4.1.2], [have_docbook_dtd=yes], [have_docbook_dtd=no])
2480   AS_IF([test "$have_docbook_dtd" != yes], [
2481     AS_IF([test "$enable_man" = yes ], [
2482       AC_MSG_ERROR([DocBook DTD is required for --enable-man])
2483     ])
2484     enable_man=no
2485   ])
2486 ])
2487
2488 AS_IF([test "$enable_man" != no], [
2489   dnl check for DocBook XSL stylesheets in the local catalog
2490   JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
2491      [DocBook XSL Stylesheets], [have_docbook_style=yes],[have_docbook_style=no])
2492   AS_IF([ test "$have_docbook_style" != yes ], [
2493     AS_IF([ test "$enable_man" = yes ], [
2494       AC_MSG_ERROR([DocBook XSL Stylesheets are required for --enable-man])
2495     ])
2496     enable_man=no
2497   ])
2498 ])
2499
2500 AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
2501
2502 AC_MSG_CHECKING([whether to generate man pages])
2503 AS_IF([ test "$enable_man" != no ], [
2504   AC_MSG_RESULT([yes])
2505 ], [
2506   AC_MSG_RESULT([no])
2507 ])
2508
2509 dnl
2510 dnl Tracing
2511 dnl
2512
2513 AC_ARG_ENABLE([dtrace],
2514              [AS_HELP_STRING([--enable-dtrace],
2515                               [include tracing support for dtrace])])
2516 have_dtrace=no
2517 AC_MSG_CHECKING([whether to include dtrace tracing support])
2518 AS_IF([ test "x$enable_dtrace" != xno], [
2519   if test x$glib_have_carbon = xyes; then
2520     AC_MSG_RESULT([no (not yet compatible with MacOS dtrace)])
2521   else 
2522     AC_MSG_RESULT([yes])
2523     AC_CHECK_PROGS(DTRACE, dtrace)
2524     if test -z "$DTRACE"; then
2525       if test "x$enable_dtrace" = xyes; then
2526         AC_MSG_ERROR([dtrace not found])
2527       fi
2528     else
2529       AC_CHECK_HEADER([sys/sdt.h],have_dtrace=yes,
2530                       [if test "x$enable_dtrace" = xyes; then
2531                         AC_MSG_ERROR([dtrace support needs sys/sdt.h header])
2532                        fi])
2533     fi
2534   fi
2535 ], [
2536   AC_MSG_RESULT([no])
2537 ])
2538 if test "x$have_dtrace" = xyes; then
2539   AC_DEFINE([HAVE_DTRACE], [1], [Define to 1 if using dtrace probes.])
2540 fi
2541 AM_CONDITIONAL([ENABLE_DTRACE], [test x$have_dtrace = xyes ])
2542
2543 AC_MSG_CHECKING([whether to include systemtap tracing support])
2544 AC_ARG_ENABLE([systemtap],
2545              [AS_HELP_STRING([--enable-systemtap],
2546                               [include tracing support for systemtap])])
2547 have_systemtap=no
2548 if test "x$enable_systemtap" != xno -a "x$have_dtrace" = xyes; then
2549   have_systemtap=yes
2550 fi
2551 AC_MSG_RESULT(${have_systemtap})
2552
2553 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$have_systemtap = xyes])
2554
2555 AC_ARG_WITH([tapset-install-dir],
2556             AS_HELP_STRING([--with-tapset-install-dir=DIR],
2557                             [path where systemtap tapsets are installed [DATADIR/systemtap/tapset/HOST_CPU]]),
2558             [if test "x${withval}" = x; then
2559                ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset/${host_cpu}"
2560              else
2561                ABS_TAPSET_DIR="${withval}"
2562               fi],
2563             [ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset/${host_cpu}"])
2564 AC_SUBST(ABS_TAPSET_DIR)
2565
2566 dnl ************************************
2567 dnl *** Enable lcov coverage reports ***
2568 dnl ************************************
2569
2570 AC_ARG_ENABLE(coverage,
2571   AS_HELP_STRING([--enable-coverage],
2572                  [enable coverage testing with gcov]),
2573   [use_gcov=$enableval], [use_gcov=no])
2574
2575 AS_IF([ test "x$use_gcov" = "xyes"], [
2576   dnl we need gcc:
2577   if test "$GCC" != "yes"; then
2578     AC_MSG_ERROR([GCC is required for --enable-coverage])
2579   fi
2580
2581   dnl Check if ccache is being used
2582   AC_CHECK_PROG(SHTOOL, shtool, shtool)
2583   case `$SHTOOL path $CC` in
2584     *ccache*[)] gcc_ccache=yes;;
2585     *[)] gcc_ccache=no;;
2586   esac
2587
2588   if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
2589     AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
2590   fi
2591
2592   ltp_version_list="1.6 1.7 1.8 1.9 1.10 1.12"
2593   AC_CHECK_PROG(LTP, lcov, lcov)
2594   AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
2595
2596   AS_IF([ test "$LTP" ], [
2597     AC_CACHE_CHECK([for ltp version], glib_cv_ltp_version, [
2598       glib_cv_ltp_version=invalid
2599       ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
2600       for ltp_check_version in $ltp_version_list; do
2601         if test "$ltp_version" = "$ltp_check_version"; then
2602           glib_cv_ltp_version="$ltp_check_version (ok)"
2603         fi
2604       done
2605     ])
2606   ], [
2607     ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
2608     AC_MSG_ERROR([$ltp_msg])
2609   ])
2610
2611   case $glib_cv_ltp_version in
2612     ""|invalid[)]
2613       ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
2614       AC_MSG_ERROR([$ltp_msg])
2615       LTP="exit 0;"
2616       ;;
2617   esac
2618
2619   if test -z "$LTP_GENHTML"; then
2620     AC_MSG_ERROR([Could not find genhtml from the LTP package])
2621   fi
2622
2623   dnl Remove all optimization flags from CFLAGS
2624   changequote({,})
2625   CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
2626   changequote([,])
2627
2628   dnl Add the special gcc flags
2629   CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
2630   LDFLAGS="$LDFLAGS -lgcov"
2631 ])
2632
2633 dnl *******************************
2634 dnl *** Disable strict aliasing ***
2635 dnl *******************************
2636 dnl See https://bugzilla.gnome.org/show_bug.cgi?id=791622
2637 AS_IF([test "${GCC}" = "yes"],[
2638   CFLAGS="$CFLAGS -fno-strict-aliasing"
2639 ])
2640
2641 dnl ******************************
2642 dnl *** output the whole stuff ***
2643 dnl ******************************
2644
2645 dnl this section will only be run if config.status is invoked with no
2646 dnl arguments, or with "glib/glibconfig.h" as an argument.
2647 AC_CONFIG_COMMANDS([glib/glibconfig.h],
2648 [
2649         outfile=glib/glibconfig.h-tmp
2650         cat > $outfile <<\_______EOF
2651 /* glibconfig.h
2652  *
2653  * This is a generated file.  Please modify 'configure.ac'
2654  */
2655
2656 #ifndef __GLIBCONFIG_H__
2657 #define __GLIBCONFIG_H__
2658
2659 #include <glib/gmacros.h>
2660
2661 _______EOF
2662
2663         echo '#include <limits.h>' >> $outfile
2664         echo '#include <float.h>' >> $outfile
2665         if test x$glib_values_h = xyes; then
2666           echo '#include <values.h>' >> $outfile
2667         fi
2668         if test "$glib_header_alloca_h" = "yes"; then
2669           echo '#define GLIB_HAVE_ALLOCA_H' >> $outfile
2670         fi
2671         if test x$glib_included_printf != xyes; then
2672           echo "
2673 /* Specifies that GLib's g_print*() functions wrap the
2674  * system printf functions.  This is useful to know, for example,
2675  * when using glibc's register_printf_function().
2676  */" >> $outfile
2677           echo '#define GLIB_USING_SYSTEM_PRINTF' >> $outfile
2678         fi
2679
2680         cat >> $outfile <<_______EOF
2681
2682 G_BEGIN_DECLS
2683
2684 #define G_MINFLOAT      FLT_MIN
2685 #define G_MAXFLOAT      FLT_MAX
2686 #define G_MINDOUBLE     DBL_MIN
2687 #define G_MAXDOUBLE     DBL_MAX
2688 #define G_MINSHORT      SHRT_MIN
2689 #define G_MAXSHORT      SHRT_MAX
2690 #define G_MAXUSHORT     USHRT_MAX
2691 #define G_MININT        INT_MIN
2692 #define G_MAXINT        INT_MAX
2693 #define G_MAXUINT       UINT_MAX
2694 #define G_MINLONG       LONG_MIN
2695 #define G_MAXLONG       LONG_MAX
2696 #define G_MAXULONG      ULONG_MAX
2697
2698 _______EOF
2699
2700
2701         ### this should always be true in a modern C/C++ compiler
2702         ### and is statically asserted by glib-init.c
2703         cat >>$outfile <<_______EOF
2704 typedef signed char gint8;
2705 typedef unsigned char guint8;
2706 _______EOF
2707
2708
2709         if test -n "$gint16"; then
2710           cat >>$outfile <<_______EOF
2711 typedef signed $gint16 gint16;
2712 typedef unsigned $gint16 guint16;
2713 #define G_GINT16_MODIFIER $gint16_modifier
2714 #define G_GINT16_FORMAT $gint16_format
2715 #define G_GUINT16_FORMAT $guint16_format
2716 _______EOF
2717         fi
2718
2719
2720         if test -n "$gint32"; then
2721           cat >>$outfile <<_______EOF
2722 typedef signed $gint32 gint32;
2723 typedef unsigned $gint32 guint32;
2724 #define G_GINT32_MODIFIER $gint32_modifier
2725 #define G_GINT32_FORMAT $gint32_format
2726 #define G_GUINT32_FORMAT $guint32_format
2727 _______EOF
2728         fi
2729
2730         cat >>$outfile <<_______EOF
2731 #define G_HAVE_GINT64 1          /* deprecated, always true */
2732
2733 ${glib_extension}typedef signed $gint64 gint64;
2734 ${glib_extension}typedef unsigned $gint64 guint64;
2735
2736 #define G_GINT64_CONSTANT(val)  $gint64_constant
2737 #define G_GUINT64_CONSTANT(val) $guint64_constant
2738 _______EOF
2739
2740         if test x$gint64_format != x ; then
2741           cat >>$outfile <<_______EOF
2742 #define G_GINT64_MODIFIER $gint64_modifier
2743 #define G_GINT64_FORMAT $gint64_format
2744 #define G_GUINT64_FORMAT $guint64_format
2745 _______EOF
2746         else
2747           cat >>$outfile <<_______EOF
2748 #undef G_GINT64_MODIFIER
2749 #undef G_GINT64_FORMAT
2750 #undef G_GUINT64_FORMAT
2751 _______EOF
2752         fi           
2753
2754         cat >>$outfile <<_______EOF
2755
2756 #define GLIB_SIZEOF_VOID_P $glib_void_p
2757 #define GLIB_SIZEOF_LONG   $glib_long
2758 #define GLIB_SIZEOF_SIZE_T $glib_size_t
2759 #define GLIB_SIZEOF_SSIZE_T $glib_ssize_t
2760
2761 _______EOF
2762
2763         cat >>$outfile <<_______EOF
2764 typedef signed $glib_ssize_type_define gssize;
2765 typedef unsigned $glib_size_type_define gsize;
2766 #define G_GSIZE_MODIFIER $gsize_modifier
2767 #define G_GSSIZE_MODIFIER $gssize_modifier
2768 #define G_GSIZE_FORMAT $gsize_format
2769 #define G_GSSIZE_FORMAT $gssize_format
2770
2771 #define G_MAXSIZE       G_MAXU$glib_msize_type
2772 #define G_MINSSIZE      G_MIN$glib_mssize_type
2773 #define G_MAXSSIZE      G_MAX$glib_mssize_type
2774
2775 typedef gint64 goffset;
2776 #define G_MINOFFSET     G_MININT64
2777 #define G_MAXOFFSET     G_MAXINT64
2778
2779 #define G_GOFFSET_MODIFIER      G_GINT64_MODIFIER
2780 #define G_GOFFSET_FORMAT        G_GINT64_FORMAT
2781 #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
2782
2783 #define G_POLLFD_FORMAT $g_pollfd_format
2784
2785 _______EOF
2786
2787         if test -z "$glib_unknown_void_p"; then
2788           cat >>$outfile <<_______EOF
2789
2790 #define GPOINTER_TO_INT(p)      ((gint)  ${glib_gpi_cast} (p))
2791 #define GPOINTER_TO_UINT(p)     ((guint) ${glib_gpui_cast} (p))
2792
2793 #define GINT_TO_POINTER(i)      ((gpointer) ${glib_gpi_cast} (i))
2794 #define GUINT_TO_POINTER(u)     ((gpointer) ${glib_gpui_cast} (u))
2795
2796 typedef signed $glib_intptr_type_define gintptr;
2797 typedef unsigned $glib_intptr_type_define guintptr;
2798
2799 #define G_GINTPTR_MODIFIER      $gintptr_modifier
2800 #define G_GINTPTR_FORMAT        $gintptr_format
2801 #define G_GUINTPTR_FORMAT       $guintptr_format
2802 _______EOF
2803         else
2804           echo '#error SIZEOF_VOID_P unknown - This should never happen' >>$outfile
2805         fi
2806
2807
2808
2809         cat >>$outfile <<_______EOF
2810 #ifndef G_DISABLE_DEPRECATED
2811 #define g_ATEXIT(proc)  (atexit (proc))
2812 #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
2813 #endif
2814 $glib_defines
2815 $glib_os
2816 $glib_static_compilation
2817
2818 $glib_vacopy
2819
2820 _______EOF
2821
2822         if test x$g_have_iso_c_varargs = xyes ; then
2823                 cat >>$outfile <<_______EOF
2824 #ifndef __cplusplus
2825 # define G_HAVE_ISO_VARARGS 1
2826 #endif
2827 _______EOF
2828         fi
2829         if test x$g_have_iso_cxx_varargs = xyes ; then
2830                 cat >>$outfile <<_______EOF
2831 #ifdef __cplusplus
2832 # define G_HAVE_ISO_VARARGS 1
2833 #endif
2834 _______EOF
2835         fi
2836         if test x$g_have_gnuc_varargs = xyes ; then
2837                 cat >>$outfile <<_______EOF
2838
2839 /* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
2840  * is passed ISO vararg support is turned off, and there is no work
2841  * around to turn it on, so we unconditionally turn it off.
2842  */
2843 #if __GNUC__ == 2 && __GNUC_MINOR__ == 95
2844 #  undef G_HAVE_ISO_VARARGS
2845 #endif
2846
2847 #define G_HAVE_GNUC_VARARGS 1
2848 _______EOF
2849         fi
2850
2851         case x$g_stack_grows in
2852         xyes) echo "#define G_HAVE_GROWING_STACK 1" >>$outfile ;;
2853         *)    echo "#define G_HAVE_GROWING_STACK 0" >>$outfile ;;
2854         esac
2855
2856
2857         echo >>$outfile
2858         if test x$g_have_eilseq = xno; then
2859                 cat >>$outfile <<_______EOF
2860 #ifndef EILSEQ
2861 /* On some pre-C99 systems, EILSEQ is not defined.
2862  * The correspondence between this and the corresponding definition
2863  * in libiconv is essential.
2864  */
2865 #  define EILSEQ ENOENT
2866 #endif
2867 _______EOF
2868
2869         fi
2870
2871         if test x$g_have_gnuc_visibility = xyes; then
2872                 cat >>$outfile <<_______EOF
2873 #define G_HAVE_GNUC_VISIBILITY 1
2874 _______EOF
2875         fi
2876                 cat >>$outfile <<_______EOF
2877 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
2878 #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
2879 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
2880 #define G_GNUC_INTERNAL __hidden
2881 #elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
2882 #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
2883 #else
2884 #define G_GNUC_INTERNAL
2885 #endif 
2886 _______EOF
2887
2888         echo >>$outfile
2889         cat >>$outfile <<_______EOF
2890 #define G_THREADS_ENABLED
2891 #define G_THREADS_IMPL_$g_threads_impl_def
2892 _______EOF
2893
2894         if test x"$g_memory_barrier_needed" != xno; then
2895           echo >>$outfile
2896           echo "#define G_ATOMIC_OP_MEMORY_BARRIER_NEEDED 1" >>$outfile
2897         fi
2898         if test x"$g_atomic_lock_free" = xyes; then
2899           echo >>$outfile
2900           echo "#define G_ATOMIC_LOCK_FREE" >>$outfile
2901         fi
2902         echo >>$outfile
2903         g_bit_sizes="16 32 64"
2904         for bits in $g_bit_sizes; do
2905           cat >>$outfile <<_______EOF
2906 #define GINT${bits}_TO_${g_bs_native}(val)      ((gint${bits}) (val))
2907 #define GUINT${bits}_TO_${g_bs_native}(val)     ((guint${bits}) (val))
2908 #define GINT${bits}_TO_${g_bs_alien}(val)       ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
2909 #define GUINT${bits}_TO_${g_bs_alien}(val)      (GUINT${bits}_SWAP_LE_BE (val))
2910 _______EOF
2911         done
2912
2913         cat >>$outfile <<_______EOF
2914 #define GLONG_TO_LE(val)        ((glong) GINT${glongbits}_TO_LE (val))
2915 #define GULONG_TO_LE(val)       ((gulong) GUINT${glongbits}_TO_LE (val))
2916 #define GLONG_TO_BE(val)        ((glong) GINT${glongbits}_TO_BE (val))
2917 #define GULONG_TO_BE(val)       ((gulong) GUINT${glongbits}_TO_BE (val))
2918 #define GINT_TO_LE(val)         ((gint) GINT${gintbits}_TO_LE (val))
2919 #define GUINT_TO_LE(val)        ((guint) GUINT${gintbits}_TO_LE (val))
2920 #define GINT_TO_BE(val)         ((gint) GINT${gintbits}_TO_BE (val))
2921 #define GUINT_TO_BE(val)        ((guint) GUINT${gintbits}_TO_BE (val))
2922 #define GSIZE_TO_LE(val)        ((gsize) GUINT${gsizebits}_TO_LE (val))
2923 #define GSSIZE_TO_LE(val)       ((gssize) GINT${gssizebits}_TO_LE (val))
2924 #define GSIZE_TO_BE(val)        ((gsize) GUINT${gsizebits}_TO_BE (val))
2925 #define GSSIZE_TO_BE(val)       ((gssize) GINT${gssizebits}_TO_BE (val))
2926 #define G_BYTE_ORDER $g_byte_order
2927
2928 #define GLIB_SYSDEF_POLLIN =$g_pollin
2929 #define GLIB_SYSDEF_POLLOUT =$g_pollout
2930 #define GLIB_SYSDEF_POLLPRI =$g_pollpri
2931 #define GLIB_SYSDEF_POLLHUP =$g_pollhup
2932 #define GLIB_SYSDEF_POLLERR =$g_pollerr
2933 #define GLIB_SYSDEF_POLLNVAL =$g_pollnval
2934
2935 #define G_MODULE_SUFFIX "$g_module_suffix"
2936
2937 typedef $g_pid_type GPid;
2938 #define G_PID_FORMAT $g_pid_format
2939
2940 #define GLIB_SYSDEF_AF_UNIX $g_af_unix
2941 #define GLIB_SYSDEF_AF_INET $g_af_inet
2942 #define GLIB_SYSDEF_AF_INET6 $g_af_inet6
2943
2944 #define GLIB_SYSDEF_MSG_OOB $g_msg_oob
2945 #define GLIB_SYSDEF_MSG_PEEK $g_msg_peek
2946 #define GLIB_SYSDEF_MSG_DONTROUTE $g_msg_dontroute
2947
2948 G_END_DECLS
2949
2950 #endif /* __GLIBCONFIG_H__ */
2951 _______EOF
2952
2953
2954         if cmp -s $outfile glib/glibconfig.h; then
2955           AC_MSG_NOTICE([glib/glibconfig.h is unchanged])
2956           rm -f $outfile
2957         else
2958           mv $outfile glib/glibconfig.h
2959         fi
2960 ],[
2961
2962 # Note that if two cases are the same, case goes with the first one.
2963 # Note also that this is inside an AC_OUTPUT_COMMAND.  We do not depend
2964 # on variable expansion in case labels.  Look at the generated config.status
2965 # for a hint.
2966
2967 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
2968   glib_header_alloca_h="$ac_cv_working_alloca_h"
2969 else
2970   glib_header_alloca_h="$ac_cv_header_alloca_h"
2971 fi
2972
2973 if test x$enable_included_printf = xyes ; then
2974   glib_included_printf=yes
2975 fi
2976
2977 case 2 in
2978 $ac_cv_sizeof_short)            
2979   gint16=short
2980   gint16_modifier='"h"'
2981   gint16_format='"hi"'
2982   guint16_format='"hu"'
2983   ;;
2984 $ac_cv_sizeof_int)              
2985   gint16=int
2986   gint16_modifier='""'
2987   gint16_format='"i"'
2988   guint16_format='"u"'
2989   ;;
2990 esac
2991 case 4 in
2992 $ac_cv_sizeof_short)            
2993   gint32=short
2994   gint32_modifier='"h"'
2995   gint32_format='"hi"'
2996   guint32_format='"hu"'
2997   ;;
2998 $ac_cv_sizeof_int)              
2999   gint32=int
3000   gint32_modifier='""'
3001   gint32_format='"i"'
3002   guint32_format='"u"'
3003   ;;
3004 $ac_cv_sizeof_long)             
3005   gint32=long
3006   gint32_modifier='"l"'
3007   gint32_format='"li"'
3008   guint32_format='"lu"'
3009   ;;
3010 esac
3011 case 8 in
3012 $ac_cv_sizeof_int)
3013   gint64=int
3014   gint64_modifier='""'
3015   gint64_format='"i"'
3016   guint64_format='"u"'
3017   glib_extension=
3018   gint64_constant='(val)'
3019   guint64_constant='(val)'
3020   ;;
3021 $ac_cv_sizeof_long)
3022   gint64=long
3023   gint64_modifier='"l"'
3024   gint64_format='"li"'
3025   guint64_format='"lu"'
3026   glib_extension=
3027   gint64_constant='(val##L)'
3028   guint64_constant='(val##UL)'
3029   ;;
3030 $ac_cv_sizeof_long_long)
3031   gint64='long long'
3032   if test -n "$glib_cv_long_long_format"; then
3033     gint64_modifier='"'$glib_cv_long_long_format'"'
3034     gint64_format='"'$glib_cv_long_long_format'i"'
3035     guint64_format='"'$glib_cv_long_long_format'u"'
3036   fi
3037   glib_extension='G_GNUC_EXTENSION '
3038   gint64_constant='(G_GNUC_EXTENSION (val##LL))'
3039   guint64_constant='(G_GNUC_EXTENSION (val##ULL))'
3040   ;;
3041 $ac_cv_sizeof___int64)
3042   gint64='__int64'
3043   if test -n "$glib_cv_long_long_format"; then
3044     gint64_modifier='"'$glib_cv_long_long_format'"'
3045     gint64_format='"'$glib_cv_long_long_format'i"'
3046     guint64_format='"'$glib_cv_long_long_format'u"'
3047   fi
3048   glib_extension=
3049   gint64_constant='(val##i64)'
3050   guint64_constant='(val##ui64)'
3051   ;;
3052 esac
3053 glib_size_t=$ac_cv_sizeof_size_t
3054 glib_ssize_t=$ac_cv_sizeof_ssize_t
3055 glib_size_type_define="$glib_size_type"
3056 glib_ssize_type_define="$glib_ssize_type"
3057 glib_void_p=$ac_cv_sizeof_void_p
3058 glib_long=$ac_cv_sizeof_long
3059
3060 case "$glib_size_type" in
3061 short)
3062   gsize_modifier='"h"'
3063   gsize_format='"hu"'
3064   glib_msize_type='SHRT'
3065   ;;
3066 int)
3067   gsize_modifier='""'
3068   gsize_format='"u"'
3069   glib_msize_type='INT'
3070   ;;
3071 long)
3072   gsize_modifier='"l"'
3073   gsize_format='"lu"'
3074   glib_msize_type='LONG'
3075   ;;
3076 "long long"|__int64)
3077   gsize_modifier='"I64"'
3078   gsize_format='"I64u"'
3079   glib_msize_type='INT64'
3080   ;;
3081 esac
3082
3083 case "$glib_ssize_type" in
3084 short)
3085   gssize_modifier='"h"'
3086   gssize_format='"hi"'
3087   glib_mssize_type='SHRT'
3088   ;;
3089 int)
3090   gssize_modifier='""'
3091   gssize_format='"i"'
3092   glib_mssize_type='INT'
3093   ;;
3094 long)
3095   gssize_modifier='"l"'
3096   gssize_format='"li"'
3097   glib_mssize_type='LONG'
3098   ;;
3099 "long long"|__int64)
3100   gssize_modifier='"I64"'
3101   gssize_format='"I64i"'
3102   glib_mssize_type='INT64'
3103   ;;
3104 esac
3105
3106 gintbits=`expr $ac_cv_sizeof_int \* 8`
3107 glongbits=`expr $ac_cv_sizeof_long \* 8`
3108 gsizebits=`expr $ac_cv_sizeof_size_t \* 8`
3109 gssizebits=`expr $ac_cv_sizeof_ssize_t \* 8`
3110
3111 case $ac_cv_sizeof_void_p in
3112 $ac_cv_sizeof_int)
3113   glib_intptr_type_define=int
3114   gintptr_modifier='""'
3115   gintptr_format='"i"'
3116   guintptr_format='"u"'
3117   glib_gpi_cast='(gint)'
3118   glib_gpui_cast='(guint)'
3119   ;;
3120 $ac_cv_sizeof_long)
3121   glib_intptr_type_define=long
3122   gintptr_modifier='"l"'
3123   gintptr_format='"li"'
3124   guintptr_format='"lu"'
3125   glib_gpi_cast='(glong)'
3126   glib_gpui_cast='(gulong)'
3127   ;;
3128 $ac_cv_sizeof_long_long)
3129   glib_intptr_type_define='long long'
3130   gintptr_modifier='"I64"'
3131   gintptr_format='"I64i"'
3132   guintptr_format='"I64u"'
3133   glib_gpi_cast='(gint64)'
3134   glib_gpui_cast='(guint64)'
3135   ;;
3136 $ac_cv_sizeof___int64)
3137   glib_intptr_type_define=__int64
3138   gintptr_modifier='"I64"'
3139   gintptr_format='"I64i"'
3140   guintptr_format='"I64u"'
3141   glib_gpi_cast='(gint64)'
3142   glib_gpui_cast='(guint64)'
3143   ;;
3144 *)
3145   glib_unknown_void_p=yes
3146   ;;
3147 esac
3148
3149
3150 glib_defines="
3151 #define GLIB_MAJOR_VERSION $GLIB_MAJOR_VERSION
3152 #define GLIB_MINOR_VERSION $GLIB_MINOR_VERSION
3153 #define GLIB_MICRO_VERSION $GLIB_MICRO_VERSION
3154 "
3155
3156 case xyes in
3157 x$glib_cv_va_copy)      glib_vacopy='#define G_VA_COPY  va_copy' ;;
3158 x$glib_cv___va_copy)    glib_vacopy='#define G_VA_COPY  __va_copy' ;;
3159 *)                      glib_vacopy=''
3160 esac
3161
3162 if test x$glib_cv_va_val_copy = xno; then
3163   glib_vacopy="\$glib_vacopy
3164 #define G_VA_COPY_AS_ARRAY 1"
3165 fi
3166
3167 g_have_gnuc_varargs=$g_have_gnuc_varargs
3168 g_have_iso_c_varargs=$g_have_iso_c_varargs
3169 g_have_iso_cxx_varargs=$g_have_iso_cxx_varargs
3170
3171 g_have_gnuc_visibility=$g_have_gnuc_visibility
3172 g_have_sunstudio_visibility=$g_have_sunstudio_visibility
3173
3174 if test x$ac_cv_c_bigendian = xyes; then
3175   g_byte_order=G_BIG_ENDIAN
3176   g_bs_native=BE
3177   g_bs_alien=LE
3178 else
3179   g_byte_order=G_LITTLE_ENDIAN
3180   g_bs_native=LE
3181   g_bs_alien=BE
3182 fi
3183
3184 g_pollin=$glib_cv_value_POLLIN
3185 g_pollout=$glib_cv_value_POLLOUT
3186 g_pollpri=$glib_cv_value_POLLPRI
3187 g_pollhup=$glib_cv_value_POLLHUP
3188 g_pollerr=$glib_cv_value_POLLERR
3189 g_pollnval=$glib_cv_value_POLLNVAL
3190
3191 # If a family is not found on the system, define that family to
3192 # a negative value, picking a different one for each undefined
3193 # family (-1 for AF_UNIX, -2 for the next one, -3 ...)
3194 # This is needed because glib-mkenums doesn't handle optional
3195 # values in enums, and thus we have to have all existing values
3196 # defined in the enum.
3197 if test "x$glib_cv_value_AF_UNIX" != "x"; then
3198   g_af_unix=$glib_cv_value_AF_UNIX
3199 else
3200   g_af_unix=-1
3201 fi
3202 g_af_inet=$glib_cv_value_AF_INET
3203 g_af_inet6=$glib_cv_value_AF_INET6
3204
3205 g_msg_peek=$glib_cv_value_MSG_PEEK
3206 g_msg_oob=$glib_cv_value_MSG_OOB
3207 g_msg_dontroute=$glib_cv_value_MSG_DONTROUTE
3208
3209 g_stack_grows=$glib_cv_stack_grows
3210
3211 g_have_eilseq=$have_eilseq
3212
3213 g_threads_impl_def=$g_threads_impl
3214
3215 g_atomic_lock_free="$glib_cv_g_atomic_lock_free"
3216 g_memory_barrier_needed="$glib_memory_barrier_needed"
3217 g_gcc_atomic_ops="$glib_cv_gcc_has_builtin_atomic_operations"
3218
3219 g_module_suffix="$glib_gmodule_suffix"
3220 g_pid_type="$glib_pid_type"
3221 g_pid_format="\"$glib_pid_format\""
3222 g_pollfd_format="\"$glib_pollfd_format\""
3223
3224 case $host in
3225   *-*-cygwin*)
3226     glib_os="#define G_OS_UNIX
3227 #define G_PLATFORM_WIN32
3228 #define G_WITH_CYGWIN"
3229     ;;
3230   *-*-mingw*)
3231     glib_os="#define G_OS_WIN32
3232 #define G_PLATFORM_WIN32"
3233     ;;
3234   *)
3235     glib_os="#define G_OS_UNIX"
3236     ;;
3237 esac
3238 glib_static_compilation=""
3239 if test x$glib_win32_static_compilation = xyes; then
3240   glib_static_compilation="#define GLIB_STATIC_COMPILATION 1
3241 #define GOBJECT_STATIC_COMPILATION 1"
3242 fi
3243 ])
3244
3245 # Redo enough to get guint32 and guint64 for the alignment checks below
3246 case 4 in
3247 $ac_cv_sizeof_short)
3248   gint32=short
3249   ;;
3250 $ac_cv_sizeof_int)
3251   gint32=int
3252   ;;
3253 $ac_cv_sizeof_long)
3254   gint32=long
3255   ;;
3256 esac
3257 case 8 in
3258 $ac_cv_sizeof_int)
3259   gint64=int
3260   ;;
3261 $ac_cv_sizeof_long)
3262   gint64=long
3263   ;;
3264 $ac_cv_sizeof_long_long)
3265   gint64='long long'
3266   ;;
3267 $ac_cv_sizeof___int64)
3268   gint64='__int64'
3269   ;;
3270 esac
3271
3272 AC_CHECK_TYPE([guint32],,,[typedef unsigned $gint32 guint32;])
3273 AC_CHECK_ALIGNOF([guint32], [AC_INCLUDES_DEFAULT
3274 typedef unsigned $gint32 guint32;])
3275 AC_CHECK_TYPE([guint64],,,[typedef unsigned $gint64 guint64;])
3276 AC_CHECK_ALIGNOF([guint64], [AC_INCLUDES_DEFAULT
3277 typedef unsigned $gint64 guint64;])
3278 AC_CHECK_TYPE([unsigned long])
3279 AC_CHECK_ALIGNOF([unsigned long])
3280
3281 # Check for libdbus1 - Optional - is only used in the GDBus test cases
3282 #
3283 # 1.2.14 required for dbus_message_set_serial
3284 PKG_CHECK_MODULES(DBUS1,
3285      dbus-1 >= 1.2.14,
3286      [AC_DEFINE(HAVE_DBUS1, 1, [Define if dbus-1 is available]) have_dbus1=yes],
3287      have_dbus1=no)
3288 AC_SUBST(DBUS1_CFLAGS)
3289 AC_SUBST(DBUS1_LIBS)
3290 AM_CONDITIONAL(HAVE_DBUS1, [test "x$have_dbus1" = "xyes"])
3291
3292 AC_CHECK_PROGS([DBUS_DAEMON], [dbus-daemon])
3293 AM_CONDITIONAL([HAVE_DBUS_DAEMON], [test x$DBUS_DAEMON = xdbus-daemon ])
3294
3295 # Check whether MSVC toolset is explicitly set
3296 AM_CONDITIONAL(MSVC_BASE_NO_TOOLSET_SET, [test x$MSVC_BASE_TOOLSET = x])
3297 AM_CONDITIONAL(MSVC_NO_TOOLSET_SET, [test x$MSVC_TOOLSET = x])
3298
3299 dnl
3300 dnl Check for -Bsymbolic-functions linker flag used to avoid
3301 dnl intra-library PLT jumps, if available.
3302 dnl
3303
3304 AC_ARG_ENABLE(Bsymbolic,
3305               [AS_HELP_STRING([--disable-Bsymbolic],
3306                               [avoid linking with -Bsymbolic])],,
3307               [SAVED_LDFLAGS="${LDFLAGS}" SAVED_LIBS="${LIBS}"
3308                AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
3309                LDFLAGS=-Wl,-Bsymbolic-functions
3310                LIBS=
3311                AC_TRY_LINK([], [return 0],
3312                            AC_MSG_RESULT(yes)
3313                            enable_Bsymbolic=yes,
3314                            AC_MSG_RESULT(no)
3315                            enable_Bsymbolic=no)
3316                LDFLAGS="${SAVED_LDFLAGS}" LIBS="${SAVED_LIBS}"])
3317
3318 if test "x${enable_Bsymbolic}" = "xyes"; then
3319   GLIB_LINK_FLAGS=-Wl,-Bsymbolic-functions
3320 fi
3321
3322 dnl
3323 dnl Check for -z,nodelete linker flag: the type system assumes that
3324 dnl libgobject stays loaded for the lifetime of the process.
3325 dnl Since ld.bfd does not treat wrong -z options as fatal by default,
3326 dnl we also try to check for the --fatal-warnings linker flag if
3327 dnl auto-detecting.
3328 dnl
3329
3330 AC_ARG_ENABLE([znodelete],
3331               [AS_HELP_STRING([--disable-znodelete],
3332                               [avoid linking with -z,nodelete])],,
3333               [SAVED_CFLAGS="${CFLAGS}" SAVED_LDFLAGS="${LDFLAGS}" SAVED_LIBS="${LIBS}"
3334                AC_MSG_CHECKING([for --fatal-warnings linker flag])
3335                CFLAGS="${SAVED_CFLAGS} ${shared_flag:- -shared}"
3336                LDFLAGS=-Wl,--fatal-warnings
3337                LIBS=
3338                AC_TRY_LINK([], [return 0],
3339                            AC_MSG_RESULT(yes)
3340                            [ldflags_fatal=-Wl,--fatal-warnings],
3341                            AC_MSG_RESULT(no)
3342                            ldflags_fatal=)
3343                AC_MSG_CHECKING([for -z,nodelete linker flag])
3344                LDFLAGS="$ldflags_fatal -Wl,-z,nodelete"
3345                AC_TRY_LINK([], [return 0],
3346                            AC_MSG_RESULT(yes)
3347                            enable_znodelete=yes,
3348                            AC_MSG_RESULT(no)
3349                            enable_znodelete=no)
3350                CFLAGS="${SAVED_CFLAGS}" LDFLAGS="${SAVED_LDFLAGS}" LIBS="${SAVED_LIBS}"])
3351
3352 if test "x${enable_znodelete}" = "xyes"; then
3353   GLIB_LINK_FLAGS="$GLIB_LINK_FLAGS -Wl,-z,nodelete"
3354 fi
3355
3356 AC_SUBST(GLIB_LINK_FLAGS)
3357
3358 dnl
3359 dnl Check for -fvisibility=hidden to determine if we can do GNU-style
3360 dnl visibility attributes for symbol export control
3361 dnl
3362 GLIB_HIDDEN_VISIBILITY_CFLAGS=""
3363 case "$host" in
3364   *-*-mingw*)
3365     dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
3366     AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
3367               [defines how to decorate public symbols while building])
3368     CFLAGS="${CFLAGS} -fvisibility=hidden"
3369     ;;
3370   *)
3371     dnl on other compilers, check if we can do -fvisibility=hidden
3372     SAVED_CFLAGS="${CFLAGS}"
3373     CFLAGS="-fvisibility=hidden"
3374     AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
3375     AC_TRY_COMPILE([], [return 0],
3376                    AC_MSG_RESULT(yes)
3377                    enable_fvisibility_hidden=yes,
3378                    AC_MSG_RESULT(no)
3379                    enable_fvisibility_hidden=no)
3380     CFLAGS="${SAVED_CFLAGS}"
3381
3382     AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
3383       AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
3384                 [defines how to decorate public symbols while building])
3385       GLIB_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
3386     ])
3387     ;;
3388 esac
3389 AC_SUBST(GLIB_HIDDEN_VISIBILITY_CFLAGS)
3390
3391 dnl Compiler flags; macro originates from systemd
3392 dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
3393 AC_ARG_ENABLE(compile-warnings,
3394               [AS_HELP_STRING([--disable-compile-warnings],
3395                               [Don't use builtin compiler warnings])],,
3396                               enable_compile_warnings=yes)
3397 AS_IF([test "x$enable_compile_warnings" != xno], [
3398   CC_CHECK_FLAGS_APPEND([GLIB_WARN_CFLAGS], [CFLAGS], [\
3399    -Wall -Wstrict-prototypes -Werror=declaration-after-statement \
3400    -Werror=missing-prototypes -Werror=implicit-function-declaration \
3401    -Werror=pointer-arith -Werror=init-self -Werror=format-security \
3402    -Werror=format=2 -Werror=missing-include-dirs])
3403 ])
3404 AC_SUBST(GLIB_WARN_CFLAGS)
3405
3406 #
3407 # Define variables corresponding to the correct include paths to use for
3408 # in-tree building.
3409 #
3410
3411 # for config.h:
3412 config_h_INCLUDES='-I$(top_builddir)'
3413 AC_SUBST(config_h_INCLUDES)
3414
3415 # glib:
3416 #   config.h
3417 #   $(top_builddir)/glib: for glibconfig.h
3418 #   $(top_srcdir)/glib:   for glib.h
3419 #   $(top_srcdir):        for everything
3420 glib_INCLUDES='$(config_h_INCLUDES) -I$(top_builddir)/glib -I$(top_srcdir)/glib -I$(top_srcdir)'
3421 AC_SUBST(glib_INCLUDES)
3422
3423 # gobject:
3424 #   same as glib
3425 gobject_INCLUDES='$(glib_INCLUDES)'
3426 AC_SUBST(gobject_INCLUDES)
3427
3428 # gmodule:
3429 #   glib includes
3430 #   $(top_srcdir)/gmodule: for gmodule.h
3431 gmodule_INCLUDES='$(glib_INCLUDES) -I$(top_srcdir)/gmodule'
3432 AC_SUBST(gmodule_INCLUDES)
3433
3434 # gio:
3435 #   same as gmodule
3436 gio_INCLUDES='$(gmodule_INCLUDES)'
3437 AC_SUBST(gio_INCLUDES)
3438
3439
3440 AC_CONFIG_FILES([
3441 glib-2.0.pc
3442 gmodule-2.0.pc
3443 gmodule-export-2.0.pc
3444 gmodule-no-export-2.0.pc
3445 gthread-2.0.pc
3446 gobject-2.0.pc
3447 gio-2.0.pc
3448 gio-unix-2.0.pc
3449 gio-windows-2.0.pc
3450 glib-zip
3451 glib-gettextize
3452 Makefile
3453 build/Makefile
3454 build/win32/Makefile
3455 build/win32/dirent/Makefile
3456 win32/Makefile
3457 win32/vs9/Makefile
3458 win32/vs9/glib-version-paths.vsprops
3459 win32/vs10/Makefile
3460 win32/vs10/glib-version-paths.props
3461 win32/vs11/Makefile
3462 win32/vs12/Makefile
3463 win32/vs14/Makefile
3464 win32/vs15/Makefile
3465 glib/Makefile
3466 glib/libcharset/Makefile
3467 glib/gnulib/Makefile
3468 glib/pcre/Makefile
3469 glib/update-pcre/Makefile
3470 glib/tests/Makefile
3471 gmodule/Makefile
3472 gmodule/gmoduleconf.h
3473 gobject/Makefile
3474 gobject/glib-genmarshal
3475 gobject/glib-mkenums
3476 gobject/tests/Makefile
3477 gthread/Makefile
3478 gio/Makefile
3479 gio/gdbus-2.0/codegen/Makefile
3480 gio/gdbus-2.0/codegen/config.py
3481 gio/gnetworking.h
3482 gio/xdgmime/Makefile
3483 gio/inotify/Makefile
3484 gio/kqueue/Makefile
3485 gio/fam/Makefile
3486 gio/win32/Makefile
3487 gio/tests/Makefile
3488 gio/tests/gdbus-object-manager-example/Makefile
3489 gio/tests/services/Makefile
3490 gio/tests/services/org.gtk.GDBus.Examples.ObjectManager.service
3491 gio/tests/modules/Makefile
3492 po/Makefile.in
3493 docs/Makefile
3494 docs/reference/Makefile
3495 docs/reference/glib/Makefile
3496 docs/reference/glib/version.xml
3497 docs/reference/gobject/Makefile
3498 docs/reference/gobject/version.xml
3499 docs/reference/gio/Makefile
3500 docs/reference/gio/version.xml
3501 tests/Makefile
3502 tests/gobject/Makefile
3503 tests/refcount/Makefile
3504 m4macros/Makefile
3505 ])
3506
3507 AC_CONFIG_COMMANDS([chmod-scripts],
3508 [chmod 0755 glib-zip
3509 chmod 0755 glib-gettextize
3510 chmod 0755 gobject/glib-genmarshal
3511 chmod 0755 gobject/glib-mkenums])
3512
3513 # we want to invoke this macro solely so that the config.status script
3514 # and automake generated makefiles know about these generated files.
3515 # They are only needed to distcheck the package
3516 if false; then
3517   AC_CONFIG_FILES([
3518     INSTALL
3519     README
3520     config.h.win32
3521     glib/glibconfig.h.win32
3522     glib/glib.rc
3523     gmodule/gmodule.rc
3524     gobject/gobject.rc
3525     gthread/gthread.rc
3526     gio/gio.rc
3527   ])
3528 fi
3529
3530 AC_OUTPUT