Do not generate marshaller aliases in source files
[glib.git] / configure.ac
blob8eb5795fce27f105b3193f64c6c51979cfe68891
1 # Process this file with autoconf to produce a configure script.
2 AC_PREREQ([2.62])
4 dnl ***********************************
5 dnl *** include special GLib macros ***
6 dnl ***********************************
8 m4_define(glib_configure_ac)
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.
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.
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.
27 # in easier to understand terms:
29 # <mclasen> on the stable branch, interface age == micro
30 # <mclasen> on the unstable (ie master), interface age = 0
32 m4_define([glib_major_version], [2])
33 m4_define([glib_minor_version], [55])
34 m4_define([glib_micro_version], [0])
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])
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)])
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
56 AC_INIT(glib, [glib_version],
57         [http://bugzilla.gnome.org/enter_bug.cgi?product=glib])
59 AC_CONFIG_HEADERS([config.h])
60 AC_CONFIG_SRCDIR([glib/glib.h])
61 AC_CONFIG_MACRO_DIR([m4macros])
63 # Save this value here, since automake will set cflags later
64 cflags_set=${CFLAGS:+set}
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])
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])
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
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)
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])
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)
111 dnl Checks for programs.
112 AC_PROG_CC
113 AC_PROG_CPP
114 AC_USE_SYSTEM_EXTENSIONS
116 AM_CONDITIONAL(HAVE_GCC, [test "$GCC" = "yes"])
118 AC_CANONICAL_HOST
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
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
162 AC_MSG_RESULT([$glib_native_win32])
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])
175 AC_SUBST(LIB_EXE_MACHINE_FLAG)
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)
184 AC_MSG_RESULT([$glib_have_carbon])
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)
195 AC_MSG_RESULT([$glib_have_cocoa])
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"])
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])
217 AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
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=""])
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])
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)
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])
256 GLIB_TESTS
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]) ])
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])
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"])
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
291 AM_PROG_CC_C_O
292 AC_PROG_INSTALL
294 AC_SYS_LARGEFILE
296 PKG_PROG_PKG_CONFIG(0.16)
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"
309   if test "x$enable_debug" = "xno"; then
310     GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
311   fi
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
348 GLIB_EXTRA_CFLAGS="${msnative_struct}"
349 AC_SUBST(GLIB_EXTRA_CFLAGS)
351 AC_EXEEXT
353 AC_PROG_AWK
354 AC_CHECK_PROGS(PERL, [perl5 perl])
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])
366 AM_PATH_PYTHON(2.7,,PYTHON="python2.7")
369 dnl ***********************
370 dnl *** Tests for iconv ***
371 dnl ***********************
373 dnl We do this before the gettext checks, to avoid distortion
375 dnl On Windows we use a native implementation
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])
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
410   if test "x$found_iconv" = "xno" ; then
411      AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
412   fi
416 dnl zlib support
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)
428 PKG_CHECK_MODULES(LIBFFI, [libffi >= 3.0.0])
429 AC_SUBST(LIBFFI_CFLAGS)
430 AC_SUBST(LIBFFI_LIBS)
433 dnl gettext support
436 ALL_LINGUAS="`grep -v '^#' "$srcdir/po/LINGUAS" | tr '\n' ' '`"
437 AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
438 GLIB_GNU_GETTEXT
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)
447 LIBS="$INTLLIBS $LIBS"
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])
454 GLIB_DEFINE_LOCALEDIR(GLIB_LOCALE_DIR)
457 dnl Now we are done with gettext checks, figure out ICONV_LIBS
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
468 AC_SUBST(ICONV_LIBS)
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
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])
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
497 AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a x$glib_win32_static_compilation != xyes])
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()
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)])
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)
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.])
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.
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])
581 AC_C_CONST
584 dnl check in which direction the stack grows
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         ,)
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)
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
620 AC_MSG_RESULT($g_have_iso_cxx_varargs)
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)
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)
638 void
639 __attribute__ ((visibility ("internal")))
640      f_internal (void)
643 void
644 __attribute__ ((visibility ("protected")))
645      f_protected (void)
648 void
649 __attribute__ ((visibility ("default")))
650      f_default (void)
653 int main (void)
655         f_hidden();
656         f_internal();
657         f_protected();
658         f_default();
659         return 0;
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])
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])
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])
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])
689 # Some versions of MSC lack these
690 AC_CHECK_HEADERS([dirent.h sys/time.h])
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])
696 AC_CHECK_HEADERS([sys/mount.h sys/sysctl.h], [], [],
697 [#if HAVE_SYS_PARAM_H
698  #include <sys/param.h>
699  #endif
701 AC_CHECK_FUNCS(sysctlbyname)
703 AC_HEADER_MAJOR
704 AC_CHECK_HEADERS([xlocale.h])
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>])
727 AC_STRUCT_DIRENT_D_TYPE
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)
739 # check additional type sizes
740 AC_CHECK_SIZEOF(size_t)
742 dnl Try to figure out whether gsize should be long or int
743 AC_MSG_CHECKING([for the appropriate definition for size_t])
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
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)
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 ()
778   size_t s = 1;
779   unsigned int *size_int = &s;
780   return (int)*size_int;
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 ()
790    size_t s = 1;
791    unsigned long *size_long = &s;
792    return (int)*size_long;
794         ]])],glib_size_type=long)])
797 AC_MSG_RESULT(unsigned $glib_size_type)
799 AC_CHECK_SIZEOF(ssize_t)
801 dnl Try to figure out whether gssize should be long or int
802 AC_MSG_CHECKING([for the appropriate definition for ssize_t])
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
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)
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 ()
844   ssize_t s = 1;
845   int *size_int = &s;
846   return (int)*size_int;
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 ()
863    ssize_t s = 1;
864    long *size_long = &s;
865    return (int)*size_long;
867         ]])],glib_ssize_type=long)])
870 AC_MSG_RESULT($glib_ssize_type)
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)
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])])
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    ])
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])])
908 AC_CHECK_HEADERS(crt_externs.h)
909 AC_CHECK_FUNCS(_NSGetEnviron)
911 AC_CHECK_FUNCS(newlocale uselocale strtod_l strtoll_l strtoull_l)
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   "]
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])
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])
942 AC_CHECK_FUNCS(endservent if_nametoindex if_indextoname sendmmsg recvmmsg)
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)
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)
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"
1027 AC_SUBST(NETWORK_LIBS)
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"])
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>])
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
1047 dnl if statfs() takes 2 arguments (Posix) or 4 (Solaris)
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()])])])
1088 dnl open takes O_DIRECTORY as an option
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])])
1100 # Check whether to use an included printf
1102 AC_FUNC_VSNPRINTF_C99
1103 AC_FUNC_PRINTF_UNIX98
1105 AC_ARG_ENABLE(included-printf,
1106               [AS_HELP_STRING([--enable-included-printf],
1107                               [use included printf [default=auto]])],
1108               enable_included_printf="$enableval")
1110 need_included_printf=no
1111 if test "x$enable_included_printf" = "xyes" ; then
1112   need_included_printf=yes
1114 if test "$ac_cv_func_vsnprintf_c99" != "yes" ; then
1115   need_included_printf=yes
1117 if test "$ac_cv_func_printf_unix98" != "yes" ; then
1118   need_included_printf=yes
1120 if test "x$ac_cv_sizeof_long_long" = "x8" &&
1121    test -z "$glib_cv_long_long_format" ; then
1122   need_included_printf=yes
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.])
1132 enable_included_printf=$need_included_printf
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)
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
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
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)])
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)])
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)])
1224 AC_LANG_RESTORE
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)
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])
1288   
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])
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])
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
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])
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])
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])
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
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
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
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                       [])
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                       [])
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                      [])
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
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>]])
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"
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
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)
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)
1535 dnl **********************
1536 dnl *** g_spawn checks ***
1537 dnl **********************
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)
1551 dnl *************************
1552 dnl *** GIOChannel checks ***
1553 dnl *************************
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)
1567 dnl *********************************
1568 dnl *** Directory for GIO modules ***
1569 dnl *********************************
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)
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"], [
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    ])
1598 AC_SUBST(SELINUX_LIBS)
1600 dnl *****************************
1601 dnl ** Check for inotify (GIO) **
1602 dnl *****************************
1603 inotify_support=no
1604 AC_CHECK_HEADERS([sys/inotify.h],
1606   AC_CHECK_FUNCS(inotify_init1, [inotify_support=yes], [inotify_support=no])
1609 AM_CONDITIONAL(HAVE_INOTIFY, [test "$inotify_support" = "yes"])
1611 dnl ****************************
1612 dnl ** Check for kqueue (GIO) **
1613 dnl ****************************
1614 kqueue_support=no
1615 AC_CHECK_HEADERS([sys/event.h],
1617         AC_CHECK_FUNCS(kqueue kevent, [kqueue_support=yes])
1620 AM_CONDITIONAL(HAVE_KQUEUE, [test "$kqueue_support" = "yes"])
1622 dnl ****************************
1623 dnl *** Checks for FAM (GIO) ***
1624 dnl ****************************
1626 should_disable_fam=no
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)
1651 AM_CONDITIONAL(HAVE_FAM, [test "$fam_support" = "yes"])
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"], [
1663 dnl either glibc or libattr can provide xattr support
1665 dnl for both of them, we check for getxattr being in
1666 dnl the library and a valid xattr header.
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    ])
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   ])
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   ])
1707 AC_SUBST(XATTR_LIBS)
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
1724   if test $have_libelf != no; then
1725     LIBELF_LIBS=-lelf
1726     have_libelf=yes
1727   fi
1731 if test x$have_libelf = xyes; then
1732   AC_DEFINE(HAVE_LIBELF, 1, [Define if libelf is available])
1735 dnl ************************
1736 dnl *** check for libmount ***
1737 dnl ************************
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
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])
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
1759   if test $have_libmount != no; then
1760     LIBMOUNT_LIBS=-lmount
1761     have_libmount=yes
1762   fi
1764 if test $have_libmount = no ; then
1765    AC_MSG_ERROR([*** Could not find libmount])
1769 if test x$have_libmount = xyes; then
1770   AC_DEFINE(HAVE_LIBMOUNT, 1, [Define if libmount is available])
1772 AM_CONDITIONAL(HAVE_LIBMOUNT, [test x$have_libmount = xyes])
1774 dnl ****************************************
1775 dnl *** platform dependent source checks ***
1776 dnl ****************************************
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)
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)
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)
1814 dnl ***********************
1815 dnl *** g_thread checks ***
1816 dnl ***********************
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])
1824 dnl error and warning message
1825 dnl *************************
1827 THREAD_NO_IMPLEMENTATION="No thread implementation found."
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."
1834 LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
1835                  "
1837 LIBS_NOT_FOUND_2=". Please choose another thread implementation or
1838                   provide information on your thread implementation."
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."
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."
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."
1854 dnl determination of thread implementation
1855 dnl ***************************************
1857 AC_MSG_CHECKING(for thread implementation)
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
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
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)
1892 dnl determination of G_THREAD_CFLAGS
1893 dnl ********************************
1895 G_THREAD_LIBS=
1896 G_THREAD_LIBS_EXTRA=
1897 G_THREAD_CFLAGS=
1900 dnl Test program for basic POSIX threads functionality
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);
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
1951 AS_IF([ test x"$G_THREAD_CFLAGS" = x], [
1953   # The canonical -pthread[s] does not work. Try something different.
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
1989 # if we are not finding the localtime_r function, then we probably are
1990 # not using the proper multithread flag
1992 glib_save_CPPFLAGS="$CPPFLAGS"
1993 CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
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.
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))])
2006 CPPFLAGS="$glib_save_CPPFLAGS"
2008 AC_MSG_CHECKING(thread related cflags)
2009 AC_MSG_RESULT($G_THREAD_CFLAGS)
2010 CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
2012 dnl determination of G_THREAD_LIBS
2013 dnl ******************************
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           ])
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
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"])
2082 if test "x$G_THREAD_LIBS" = xerror; then
2083         AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
2086 AC_MSG_CHECKING(thread related libraries)
2087 AC_MSG_RESULT($G_THREAD_LIBS)
2089 dnl check for mt safe function variants and some posix functions
2090 dnl ************************************************************
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)
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"
2154 LIBS="$glib_save_LIBS"
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)
2160 if test "$ac_cv_func_localtime_r" != "yes"; then
2161         AC_MSG_WARN($FUNC_NO_LOCALTIME_R)
2165 # Hack to deal with:
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.
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
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)
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   ])
2196 dnl ************************
2197 dnl *** g_atomic_* tests ***
2198 dnl ************************
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.
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.
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*).
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.
2222 dnl We may add other compilers here in the future...
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])
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
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
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>
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])
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>
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])
2302 AM_CONDITIONAL(HAVE_EVENTFD, [test "$glib_cv_eventfd" = "yes"])
2304 dnl ****************************************
2305 dnl *** GLib POLL* compatibility defines ***
2306 dnl ****************************************
2308 glib_poll_includes=["
2309 #include <sys/types.h>
2310 #include <poll.h>
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
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)
2357 dnl *********************
2358 dnl *** GRegex checks ***
2359 dnl *********************
2361 PCRE_REQUIRED_VERSION=8.13
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])
2370 AM_CONDITIONAL(USE_SYSTEM_PCRE, [test "x$with_pcre" = xsystem])
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   ])
2415 AC_SUBST(PCRE_WARN_CFLAGS)
2417 dnl **********************
2418 dnl *** Win32 API libs ***
2419 dnl **********************
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)
2434 dnl If the system doesn't define EILSEQ, we should define EILSEQ ourselves
2435 dnl since we need it for g_iconv()
2437 AC_MSG_CHECKING([for EILSEQ])
2438 AC_TRY_COMPILE([
2439 #include <errno.h>
2442 int error = EILSEQ;
2443 ], have_eilseq=yes, have_eilseq=no);
2444 AC_MSG_RESULT($have_eilseq)
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)
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])
2458 AM_CONDITIONAL([ENABLE_GTK_DOC],[false])
2461 AC_ARG_ENABLE(man,
2462               [AS_HELP_STRING([--enable-man],
2463                               [generate man pages [default=auto]])],,
2464               enable_man=maybe)
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   ])
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   ])
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   ])
2500 AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
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])
2510 dnl Tracing
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])
2538 if test "x$have_dtrace" = xyes; then
2539   AC_DEFINE([HAVE_DTRACE], [1], [Define to 1 if using dtrace probes.])
2541 AM_CONDITIONAL([ENABLE_DTRACE], [test x$have_dtrace = xyes ])
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
2551 AC_MSG_RESULT(${have_systemtap})
2553 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$have_systemtap = xyes])
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)
2566 dnl ************************************
2567 dnl *** Enable lcov coverage reports ***
2568 dnl ************************************
2570 AC_ARG_ENABLE(coverage,
2571   AS_HELP_STRING([--enable-coverage],
2572                  [enable coverage testing with gcov]),
2573   [use_gcov=$enableval], [use_gcov=no])
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
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
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
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)
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   ])
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
2619   if test -z "$LTP_GENHTML"; then
2620     AC_MSG_ERROR([Could not find genhtml from the LTP package])
2621   fi
2623   dnl Remove all optimization flags from CFLAGS
2624   changequote({,})
2625   CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
2626   changequote([,])
2628   dnl Add the special gcc flags
2629   CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
2630   LDFLAGS="$LDFLAGS -lgcov"
2633 dnl ******************************
2634 dnl *** output the whole stuff ***
2635 dnl ******************************
2637 dnl this section will only be run if config.status is invoked with no
2638 dnl arguments, or with "glib/glibconfig.h" as an argument.
2639 AC_CONFIG_COMMANDS([glib/glibconfig.h],
2641         outfile=glib/glibconfig.h-tmp
2642         cat > $outfile <<\_______EOF
2643 /* glibconfig.h
2645  * This is a generated file.  Please modify 'configure.ac'
2646  */
2648 #ifndef __GLIBCONFIG_H__
2649 #define __GLIBCONFIG_H__
2651 #include <glib/gmacros.h>
2653 _______EOF
2655         echo '#include <limits.h>' >> $outfile
2656         echo '#include <float.h>' >> $outfile
2657         if test x$glib_values_h = xyes; then
2658           echo '#include <values.h>' >> $outfile
2659         fi
2660         if test "$glib_header_alloca_h" = "yes"; then
2661           echo '#define GLIB_HAVE_ALLOCA_H' >> $outfile
2662         fi
2663         if test x$glib_included_printf != xyes; then
2664           echo "
2665 /* Specifies that GLib's g_print*() functions wrap the
2666  * system printf functions.  This is useful to know, for example,
2667  * when using glibc's register_printf_function().
2668  */" >> $outfile
2669           echo '#define GLIB_USING_SYSTEM_PRINTF' >> $outfile
2670         fi
2672         cat >> $outfile <<_______EOF
2674 G_BEGIN_DECLS
2676 #define G_MINFLOAT      FLT_MIN
2677 #define G_MAXFLOAT      FLT_MAX
2678 #define G_MINDOUBLE     DBL_MIN
2679 #define G_MAXDOUBLE     DBL_MAX
2680 #define G_MINSHORT      SHRT_MIN
2681 #define G_MAXSHORT      SHRT_MAX
2682 #define G_MAXUSHORT     USHRT_MAX
2683 #define G_MININT        INT_MIN
2684 #define G_MAXINT        INT_MAX
2685 #define G_MAXUINT       UINT_MAX
2686 #define G_MINLONG       LONG_MIN
2687 #define G_MAXLONG       LONG_MAX
2688 #define G_MAXULONG      ULONG_MAX
2690 _______EOF
2693         ### this should always be true in a modern C/C++ compiler
2694         ### and is statically asserted by glib-init.c
2695         cat >>$outfile <<_______EOF
2696 typedef signed char gint8;
2697 typedef unsigned char guint8;
2698 _______EOF
2701         if test -n "$gint16"; then
2702           cat >>$outfile <<_______EOF
2703 typedef signed $gint16 gint16;
2704 typedef unsigned $gint16 guint16;
2705 #define G_GINT16_MODIFIER $gint16_modifier
2706 #define G_GINT16_FORMAT $gint16_format
2707 #define G_GUINT16_FORMAT $guint16_format
2708 _______EOF
2709         fi
2712         if test -n "$gint32"; then
2713           cat >>$outfile <<_______EOF
2714 typedef signed $gint32 gint32;
2715 typedef unsigned $gint32 guint32;
2716 #define G_GINT32_MODIFIER $gint32_modifier
2717 #define G_GINT32_FORMAT $gint32_format
2718 #define G_GUINT32_FORMAT $guint32_format
2719 _______EOF
2720         fi
2722         cat >>$outfile <<_______EOF
2723 #define G_HAVE_GINT64 1          /* deprecated, always true */
2725 ${glib_extension}typedef signed $gint64 gint64;
2726 ${glib_extension}typedef unsigned $gint64 guint64;
2728 #define G_GINT64_CONSTANT(val)  $gint64_constant
2729 #define G_GUINT64_CONSTANT(val) $guint64_constant
2730 _______EOF
2732         if test x$gint64_format != x ; then
2733           cat >>$outfile <<_______EOF
2734 #define G_GINT64_MODIFIER $gint64_modifier
2735 #define G_GINT64_FORMAT $gint64_format
2736 #define G_GUINT64_FORMAT $guint64_format
2737 _______EOF
2738         else
2739           cat >>$outfile <<_______EOF
2740 #undef G_GINT64_MODIFIER
2741 #undef G_GINT64_FORMAT
2742 #undef G_GUINT64_FORMAT
2743 _______EOF
2744         fi           
2746         cat >>$outfile <<_______EOF
2748 #define GLIB_SIZEOF_VOID_P $glib_void_p
2749 #define GLIB_SIZEOF_LONG   $glib_long
2750 #define GLIB_SIZEOF_SIZE_T $glib_size_t
2751 #define GLIB_SIZEOF_SSIZE_T $glib_ssize_t
2753 _______EOF
2755         cat >>$outfile <<_______EOF
2756 typedef signed $glib_ssize_type_define gssize;
2757 typedef unsigned $glib_size_type_define gsize;
2758 #define G_GSIZE_MODIFIER $gsize_modifier
2759 #define G_GSSIZE_MODIFIER $gssize_modifier
2760 #define G_GSIZE_FORMAT $gsize_format
2761 #define G_GSSIZE_FORMAT $gssize_format
2763 #define G_MAXSIZE       G_MAXU$glib_msize_type
2764 #define G_MINSSIZE      G_MIN$glib_mssize_type
2765 #define G_MAXSSIZE      G_MAX$glib_mssize_type
2767 typedef gint64 goffset;
2768 #define G_MINOFFSET     G_MININT64
2769 #define G_MAXOFFSET     G_MAXINT64
2771 #define G_GOFFSET_MODIFIER      G_GINT64_MODIFIER
2772 #define G_GOFFSET_FORMAT        G_GINT64_FORMAT
2773 #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
2775 #define G_POLLFD_FORMAT $g_pollfd_format
2777 _______EOF
2779         if test -z "$glib_unknown_void_p"; then
2780           cat >>$outfile <<_______EOF
2782 #define GPOINTER_TO_INT(p)      ((gint)  ${glib_gpi_cast} (p))
2783 #define GPOINTER_TO_UINT(p)     ((guint) ${glib_gpui_cast} (p))
2785 #define GINT_TO_POINTER(i)      ((gpointer) ${glib_gpi_cast} (i))
2786 #define GUINT_TO_POINTER(u)     ((gpointer) ${glib_gpui_cast} (u))
2788 typedef signed $glib_intptr_type_define gintptr;
2789 typedef unsigned $glib_intptr_type_define guintptr;
2791 #define G_GINTPTR_MODIFIER      $gintptr_modifier
2792 #define G_GINTPTR_FORMAT        $gintptr_format
2793 #define G_GUINTPTR_FORMAT       $guintptr_format
2794 _______EOF
2795         else
2796           echo '#error SIZEOF_VOID_P unknown - This should never happen' >>$outfile
2797         fi
2801         cat >>$outfile <<_______EOF
2802 #ifndef G_DISABLE_DEPRECATED
2803 #define g_ATEXIT(proc)  (atexit (proc))
2804 #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
2805 #endif
2806 $glib_defines
2807 $glib_os
2808 $glib_static_compilation
2810 $glib_vacopy
2812 _______EOF
2814         if test x$g_have_iso_c_varargs = xyes ; then
2815                 cat >>$outfile <<_______EOF
2816 #ifndef __cplusplus
2817 # define G_HAVE_ISO_VARARGS 1
2818 #endif
2819 _______EOF
2820         fi
2821         if test x$g_have_iso_cxx_varargs = xyes ; then
2822                 cat >>$outfile <<_______EOF
2823 #ifdef __cplusplus
2824 # define G_HAVE_ISO_VARARGS 1
2825 #endif
2826 _______EOF
2827         fi
2828         if test x$g_have_gnuc_varargs = xyes ; then
2829                 cat >>$outfile <<_______EOF
2831 /* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
2832  * is passed ISO vararg support is turned off, and there is no work
2833  * around to turn it on, so we unconditionally turn it off.
2834  */
2835 #if __GNUC__ == 2 && __GNUC_MINOR__ == 95
2836 #  undef G_HAVE_ISO_VARARGS
2837 #endif
2839 #define G_HAVE_GNUC_VARARGS 1
2840 _______EOF
2841         fi
2843         case x$g_stack_grows in
2844         xyes) echo "#define G_HAVE_GROWING_STACK 1" >>$outfile ;;
2845         *)    echo "#define G_HAVE_GROWING_STACK 0" >>$outfile ;;
2846         esac
2849         echo >>$outfile
2850         if test x$g_have_eilseq = xno; then
2851                 cat >>$outfile <<_______EOF
2852 #ifndef EILSEQ
2853 /* On some pre-C99 systems, EILSEQ is not defined.
2854  * The correspondence between this and the corresponding definition
2855  * in libiconv is essential.
2856  */
2857 #  define EILSEQ ENOENT
2858 #endif
2859 _______EOF
2861         fi
2863         if test x$g_have_gnuc_visibility = xyes; then
2864                 cat >>$outfile <<_______EOF
2865 #define G_HAVE_GNUC_VISIBILITY 1
2866 _______EOF
2867         fi
2868                 cat >>$outfile <<_______EOF
2869 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
2870 #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
2871 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
2872 #define G_GNUC_INTERNAL __hidden
2873 #elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
2874 #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
2875 #else
2876 #define G_GNUC_INTERNAL
2877 #endif 
2878 _______EOF
2880         echo >>$outfile
2881         cat >>$outfile <<_______EOF
2882 #define G_THREADS_ENABLED
2883 #define G_THREADS_IMPL_$g_threads_impl_def
2884 _______EOF
2886         if test x"$g_memory_barrier_needed" != xno; then
2887           echo >>$outfile
2888           echo "#define G_ATOMIC_OP_MEMORY_BARRIER_NEEDED 1" >>$outfile
2889         fi
2890         if test x"$g_atomic_lock_free" = xyes; then
2891           echo >>$outfile
2892           echo "#define G_ATOMIC_LOCK_FREE" >>$outfile
2893         fi
2894         echo >>$outfile
2895         g_bit_sizes="16 32 64"
2896         for bits in $g_bit_sizes; do
2897           cat >>$outfile <<_______EOF
2898 #define GINT${bits}_TO_${g_bs_native}(val)      ((gint${bits}) (val))
2899 #define GUINT${bits}_TO_${g_bs_native}(val)     ((guint${bits}) (val))
2900 #define GINT${bits}_TO_${g_bs_alien}(val)       ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
2901 #define GUINT${bits}_TO_${g_bs_alien}(val)      (GUINT${bits}_SWAP_LE_BE (val))
2902 _______EOF
2903         done
2905         cat >>$outfile <<_______EOF
2906 #define GLONG_TO_LE(val)        ((glong) GINT${glongbits}_TO_LE (val))
2907 #define GULONG_TO_LE(val)       ((gulong) GUINT${glongbits}_TO_LE (val))
2908 #define GLONG_TO_BE(val)        ((glong) GINT${glongbits}_TO_BE (val))
2909 #define GULONG_TO_BE(val)       ((gulong) GUINT${glongbits}_TO_BE (val))
2910 #define GINT_TO_LE(val)         ((gint) GINT${gintbits}_TO_LE (val))
2911 #define GUINT_TO_LE(val)        ((guint) GUINT${gintbits}_TO_LE (val))
2912 #define GINT_TO_BE(val)         ((gint) GINT${gintbits}_TO_BE (val))
2913 #define GUINT_TO_BE(val)        ((guint) GUINT${gintbits}_TO_BE (val))
2914 #define GSIZE_TO_LE(val)        ((gsize) GUINT${gsizebits}_TO_LE (val))
2915 #define GSSIZE_TO_LE(val)       ((gssize) GINT${gssizebits}_TO_LE (val))
2916 #define GSIZE_TO_BE(val)        ((gsize) GUINT${gsizebits}_TO_BE (val))
2917 #define GSSIZE_TO_BE(val)       ((gssize) GINT${gssizebits}_TO_BE (val))
2918 #define G_BYTE_ORDER $g_byte_order
2920 #define GLIB_SYSDEF_POLLIN =$g_pollin
2921 #define GLIB_SYSDEF_POLLOUT =$g_pollout
2922 #define GLIB_SYSDEF_POLLPRI =$g_pollpri
2923 #define GLIB_SYSDEF_POLLHUP =$g_pollhup
2924 #define GLIB_SYSDEF_POLLERR =$g_pollerr
2925 #define GLIB_SYSDEF_POLLNVAL =$g_pollnval
2927 #define G_MODULE_SUFFIX "$g_module_suffix"
2929 typedef $g_pid_type GPid;
2930 #define G_PID_FORMAT $g_pid_format
2932 #define GLIB_SYSDEF_AF_UNIX $g_af_unix
2933 #define GLIB_SYSDEF_AF_INET $g_af_inet
2934 #define GLIB_SYSDEF_AF_INET6 $g_af_inet6
2936 #define GLIB_SYSDEF_MSG_OOB $g_msg_oob
2937 #define GLIB_SYSDEF_MSG_PEEK $g_msg_peek
2938 #define GLIB_SYSDEF_MSG_DONTROUTE $g_msg_dontroute
2940 G_END_DECLS
2942 #endif /* __GLIBCONFIG_H__ */
2943 _______EOF
2946         if cmp -s $outfile glib/glibconfig.h; then
2947           AC_MSG_NOTICE([glib/glibconfig.h is unchanged])
2948           rm -f $outfile
2949         else
2950           mv $outfile glib/glibconfig.h
2951         fi
2954 # Note that if two cases are the same, case goes with the first one.
2955 # Note also that this is inside an AC_OUTPUT_COMMAND.  We do not depend
2956 # on variable expansion in case labels.  Look at the generated config.status
2957 # for a hint.
2959 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
2960   glib_header_alloca_h="$ac_cv_working_alloca_h"
2961 else
2962   glib_header_alloca_h="$ac_cv_header_alloca_h"
2965 if test x$enable_included_printf = xyes ; then
2966   glib_included_printf=yes
2969 case 2 in
2970 $ac_cv_sizeof_short)            
2971   gint16=short
2972   gint16_modifier='"h"'
2973   gint16_format='"hi"'
2974   guint16_format='"hu"'
2975   ;;
2976 $ac_cv_sizeof_int)              
2977   gint16=int
2978   gint16_modifier='""'
2979   gint16_format='"i"'
2980   guint16_format='"u"'
2981   ;;
2982 esac
2983 case 4 in
2984 $ac_cv_sizeof_short)            
2985   gint32=short
2986   gint32_modifier='"h"'
2987   gint32_format='"hi"'
2988   guint32_format='"hu"'
2989   ;;
2990 $ac_cv_sizeof_int)              
2991   gint32=int
2992   gint32_modifier='""'
2993   gint32_format='"i"'
2994   guint32_format='"u"'
2995   ;;
2996 $ac_cv_sizeof_long)             
2997   gint32=long
2998   gint32_modifier='"l"'
2999   gint32_format='"li"'
3000   guint32_format='"lu"'
3001   ;;
3002 esac
3003 case 8 in
3004 $ac_cv_sizeof_int)
3005   gint64=int
3006   gint64_modifier='""'
3007   gint64_format='"i"'
3008   guint64_format='"u"'
3009   glib_extension=
3010   gint64_constant='(val)'
3011   guint64_constant='(val)'
3012   ;;
3013 $ac_cv_sizeof_long)
3014   gint64=long
3015   gint64_modifier='"l"'
3016   gint64_format='"li"'
3017   guint64_format='"lu"'
3018   glib_extension=
3019   gint64_constant='(val##L)'
3020   guint64_constant='(val##UL)'
3021   ;;
3022 $ac_cv_sizeof_long_long)
3023   gint64='long long'
3024   if test -n "$glib_cv_long_long_format"; then
3025     gint64_modifier='"'$glib_cv_long_long_format'"'
3026     gint64_format='"'$glib_cv_long_long_format'i"'
3027     guint64_format='"'$glib_cv_long_long_format'u"'
3028   fi
3029   glib_extension='G_GNUC_EXTENSION '
3030   gint64_constant='(G_GNUC_EXTENSION (val##LL))'
3031   guint64_constant='(G_GNUC_EXTENSION (val##ULL))'
3032   ;;
3033 $ac_cv_sizeof___int64)
3034   gint64='__int64'
3035   if test -n "$glib_cv_long_long_format"; then
3036     gint64_modifier='"'$glib_cv_long_long_format'"'
3037     gint64_format='"'$glib_cv_long_long_format'i"'
3038     guint64_format='"'$glib_cv_long_long_format'u"'
3039   fi
3040   glib_extension=
3041   gint64_constant='(val##i64)'
3042   guint64_constant='(val##ui64)'
3043   ;;
3044 esac
3045 glib_size_t=$ac_cv_sizeof_size_t
3046 glib_ssize_t=$ac_cv_sizeof_ssize_t
3047 glib_size_type_define="$glib_size_type"
3048 glib_ssize_type_define="$glib_ssize_type"
3049 glib_void_p=$ac_cv_sizeof_void_p
3050 glib_long=$ac_cv_sizeof_long
3052 case "$glib_size_type" in
3053 short)
3054   gsize_modifier='"h"'
3055   gsize_format='"hu"'
3056   glib_msize_type='SHRT'
3057   ;;
3058 int)
3059   gsize_modifier='""'
3060   gsize_format='"u"'
3061   glib_msize_type='INT'
3062   ;;
3063 long)
3064   gsize_modifier='"l"'
3065   gsize_format='"lu"'
3066   glib_msize_type='LONG'
3067   ;;
3068 "long long"|__int64)
3069   gsize_modifier='"I64"'
3070   gsize_format='"I64u"'
3071   glib_msize_type='INT64'
3072   ;;
3073 esac
3075 case "$glib_ssize_type" in
3076 short)
3077   gssize_modifier='"h"'
3078   gssize_format='"hi"'
3079   glib_mssize_type='SHRT'
3080   ;;
3081 int)
3082   gssize_modifier='""'
3083   gssize_format='"i"'
3084   glib_mssize_type='INT'
3085   ;;
3086 long)
3087   gssize_modifier='"l"'
3088   gssize_format='"li"'
3089   glib_mssize_type='LONG'
3090   ;;
3091 "long long"|__int64)
3092   gssize_modifier='"I64"'
3093   gssize_format='"I64i"'
3094   glib_mssize_type='INT64'
3095   ;;
3096 esac
3098 gintbits=`expr $ac_cv_sizeof_int \* 8`
3099 glongbits=`expr $ac_cv_sizeof_long \* 8`
3100 gsizebits=`expr $ac_cv_sizeof_size_t \* 8`
3101 gssizebits=`expr $ac_cv_sizeof_ssize_t \* 8`
3103 case $ac_cv_sizeof_void_p in
3104 $ac_cv_sizeof_int)
3105   glib_intptr_type_define=int
3106   gintptr_modifier='""'
3107   gintptr_format='"i"'
3108   guintptr_format='"u"'
3109   glib_gpi_cast='(gint)'
3110   glib_gpui_cast='(guint)'
3111   ;;
3112 $ac_cv_sizeof_long)
3113   glib_intptr_type_define=long
3114   gintptr_modifier='"l"'
3115   gintptr_format='"li"'
3116   guintptr_format='"lu"'
3117   glib_gpi_cast='(glong)'
3118   glib_gpui_cast='(gulong)'
3119   ;;
3120 $ac_cv_sizeof_long_long)
3121   glib_intptr_type_define='long long'
3122   gintptr_modifier='"I64"'
3123   gintptr_format='"I64i"'
3124   guintptr_format='"I64u"'
3125   glib_gpi_cast='(gint64)'
3126   glib_gpui_cast='(guint64)'
3127   ;;
3128 $ac_cv_sizeof___int64)
3129   glib_intptr_type_define=__int64
3130   gintptr_modifier='"I64"'
3131   gintptr_format='"I64i"'
3132   guintptr_format='"I64u"'
3133   glib_gpi_cast='(gint64)'
3134   glib_gpui_cast='(guint64)'
3135   ;;
3137   glib_unknown_void_p=yes
3138   ;;
3139 esac
3142 glib_defines="
3143 #define GLIB_MAJOR_VERSION $GLIB_MAJOR_VERSION
3144 #define GLIB_MINOR_VERSION $GLIB_MINOR_VERSION
3145 #define GLIB_MICRO_VERSION $GLIB_MICRO_VERSION
3148 case xyes in
3149 x$glib_cv_va_copy)      glib_vacopy='#define G_VA_COPY  va_copy' ;;
3150 x$glib_cv___va_copy)    glib_vacopy='#define G_VA_COPY  __va_copy' ;;
3151 *)                      glib_vacopy=''
3152 esac
3154 if test x$glib_cv_va_val_copy = xno; then
3155   glib_vacopy="\$glib_vacopy
3156 #define G_VA_COPY_AS_ARRAY 1"
3159 g_have_gnuc_varargs=$g_have_gnuc_varargs
3160 g_have_iso_c_varargs=$g_have_iso_c_varargs
3161 g_have_iso_cxx_varargs=$g_have_iso_cxx_varargs
3163 g_have_gnuc_visibility=$g_have_gnuc_visibility
3164 g_have_sunstudio_visibility=$g_have_sunstudio_visibility
3166 if test x$ac_cv_c_bigendian = xyes; then
3167   g_byte_order=G_BIG_ENDIAN
3168   g_bs_native=BE
3169   g_bs_alien=LE
3170 else
3171   g_byte_order=G_LITTLE_ENDIAN
3172   g_bs_native=LE
3173   g_bs_alien=BE
3176 g_pollin=$glib_cv_value_POLLIN
3177 g_pollout=$glib_cv_value_POLLOUT
3178 g_pollpri=$glib_cv_value_POLLPRI
3179 g_pollhup=$glib_cv_value_POLLHUP
3180 g_pollerr=$glib_cv_value_POLLERR
3181 g_pollnval=$glib_cv_value_POLLNVAL
3183 # If a family is not found on the system, define that family to
3184 # a negative value, picking a different one for each undefined
3185 # family (-1 for AF_UNIX, -2 for the next one, -3 ...)
3186 # This is needed because glib-mkenums doesn't handle optional
3187 # values in enums, and thus we have to have all existing values
3188 # defined in the enum.
3189 if test "x$glib_cv_value_AF_UNIX" != "x"; then
3190   g_af_unix=$glib_cv_value_AF_UNIX
3191 else
3192   g_af_unix=-1
3194 g_af_inet=$glib_cv_value_AF_INET
3195 g_af_inet6=$glib_cv_value_AF_INET6
3197 g_msg_peek=$glib_cv_value_MSG_PEEK
3198 g_msg_oob=$glib_cv_value_MSG_OOB
3199 g_msg_dontroute=$glib_cv_value_MSG_DONTROUTE
3201 g_stack_grows=$glib_cv_stack_grows
3203 g_have_eilseq=$have_eilseq
3205 g_threads_impl_def=$g_threads_impl
3207 g_atomic_lock_free="$glib_cv_g_atomic_lock_free"
3208 g_memory_barrier_needed="$glib_memory_barrier_needed"
3209 g_gcc_atomic_ops="$glib_cv_gcc_has_builtin_atomic_operations"
3211 g_module_suffix="$glib_gmodule_suffix"
3212 g_pid_type="$glib_pid_type"
3213 g_pid_format="\"$glib_pid_format\""
3214 g_pollfd_format="\"$glib_pollfd_format\""
3216 case $host in
3217   *-*-cygwin*)
3218     glib_os="#define G_OS_UNIX
3219 #define G_PLATFORM_WIN32
3220 #define G_WITH_CYGWIN"
3221     ;;
3222   *-*-mingw*)
3223     glib_os="#define G_OS_WIN32
3224 #define G_PLATFORM_WIN32"
3225     ;;
3226   *)
3227     glib_os="#define G_OS_UNIX"
3228     ;;
3229 esac
3230 glib_static_compilation=""
3231 if test x$glib_win32_static_compilation = xyes; then
3232   glib_static_compilation="#define GLIB_STATIC_COMPILATION 1
3233 #define GOBJECT_STATIC_COMPILATION 1"
3237 # Redo enough to get guint32 and guint64 for the alignment checks below
3238 case 4 in
3239 $ac_cv_sizeof_short)
3240   gint32=short
3241   ;;
3242 $ac_cv_sizeof_int)
3243   gint32=int
3244   ;;
3245 $ac_cv_sizeof_long)
3246   gint32=long
3247   ;;
3248 esac
3249 case 8 in
3250 $ac_cv_sizeof_int)
3251   gint64=int
3252   ;;
3253 $ac_cv_sizeof_long)
3254   gint64=long
3255   ;;
3256 $ac_cv_sizeof_long_long)
3257   gint64='long long'
3258   ;;
3259 $ac_cv_sizeof___int64)
3260   gint64='__int64'
3261   ;;
3262 esac
3264 AC_CHECK_TYPE([guint32],,,[typedef unsigned $gint32 guint32;])
3265 AC_CHECK_ALIGNOF([guint32], [AC_INCLUDES_DEFAULT
3266 typedef unsigned $gint32 guint32;])
3267 AC_CHECK_TYPE([guint64],,,[typedef unsigned $gint64 guint64;])
3268 AC_CHECK_ALIGNOF([guint64], [AC_INCLUDES_DEFAULT
3269 typedef unsigned $gint64 guint64;])
3270 AC_CHECK_TYPE([unsigned long])
3271 AC_CHECK_ALIGNOF([unsigned long])
3273 # Check for libdbus1 - Optional - is only used in the GDBus test cases
3275 # 1.2.14 required for dbus_message_set_serial
3276 PKG_CHECK_MODULES(DBUS1,
3277      dbus-1 >= 1.2.14,
3278      [AC_DEFINE(HAVE_DBUS1, 1, [Define if dbus-1 is available]) have_dbus1=yes],
3279      have_dbus1=no)
3280 AC_SUBST(DBUS1_CFLAGS)
3281 AC_SUBST(DBUS1_LIBS)
3282 AM_CONDITIONAL(HAVE_DBUS1, [test "x$have_dbus1" = "xyes"])
3284 AC_CHECK_PROGS([DBUS_DAEMON], [dbus-daemon])
3285 AM_CONDITIONAL([HAVE_DBUS_DAEMON], [test x$DBUS_DAEMON = xdbus-daemon ])
3287 # Check whether MSVC toolset is explicitly set
3288 AM_CONDITIONAL(MSVC_BASE_NO_TOOLSET_SET, [test x$MSVC_BASE_TOOLSET = x])
3289 AM_CONDITIONAL(MSVC_NO_TOOLSET_SET, [test x$MSVC_TOOLSET = x])
3292 dnl Check for -Bsymbolic-functions linker flag used to avoid
3293 dnl intra-library PLT jumps, if available.
3296 AC_ARG_ENABLE(Bsymbolic,
3297               [AS_HELP_STRING([--disable-Bsymbolic],
3298                               [avoid linking with -Bsymbolic])],,
3299               [SAVED_LDFLAGS="${LDFLAGS}" SAVED_LIBS="${LIBS}"
3300                AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
3301                LDFLAGS=-Wl,-Bsymbolic-functions
3302                LIBS=
3303                AC_TRY_LINK([], [return 0],
3304                            AC_MSG_RESULT(yes)
3305                            enable_Bsymbolic=yes,
3306                            AC_MSG_RESULT(no)
3307                            enable_Bsymbolic=no)
3308                LDFLAGS="${SAVED_LDFLAGS}" LIBS="${SAVED_LIBS}"])
3310 if test "x${enable_Bsymbolic}" = "xyes"; then
3311   GLIB_LINK_FLAGS=-Wl,-Bsymbolic-functions
3315 dnl Check for -z,nodelete linker flag: the type system assumes that
3316 dnl libgobject stays loaded for the lifetime of the process.
3317 dnl Since ld.bfd does not treat wrong -z options as fatal by default,
3318 dnl we also try to check for the --fatal-warnings linker flag if
3319 dnl auto-detecting.
3322 AC_ARG_ENABLE([znodelete],
3323               [AS_HELP_STRING([--disable-znodelete],
3324                               [avoid linking with -z,nodelete])],,
3325               [SAVED_CFLAGS="${CFLAGS}" SAVED_LDFLAGS="${LDFLAGS}" SAVED_LIBS="${LIBS}"
3326                AC_MSG_CHECKING([for --fatal-warnings linker flag])
3327                CFLAGS="${SAVED_CFLAGS} ${shared_flag:- -shared}"
3328                LDFLAGS=-Wl,--fatal-warnings
3329                LIBS=
3330                AC_TRY_LINK([], [return 0],
3331                            AC_MSG_RESULT(yes)
3332                            [ldflags_fatal=-Wl,--fatal-warnings],
3333                            AC_MSG_RESULT(no)
3334                            ldflags_fatal=)
3335                AC_MSG_CHECKING([for -z,nodelete linker flag])
3336                LDFLAGS="$ldflags_fatal -Wl,-z,nodelete"
3337                AC_TRY_LINK([], [return 0],
3338                            AC_MSG_RESULT(yes)
3339                            enable_znodelete=yes,
3340                            AC_MSG_RESULT(no)
3341                            enable_znodelete=no)
3342                CFLAGS="${SAVED_CFLAGS}" LDFLAGS="${SAVED_LDFLAGS}" LIBS="${SAVED_LIBS}"])
3344 if test "x${enable_znodelete}" = "xyes"; then
3345   GLIB_LINK_FLAGS="$GLIB_LINK_FLAGS -Wl,-z,nodelete"
3348 AC_SUBST(GLIB_LINK_FLAGS)
3351 dnl Check for -fvisibility=hidden to determine if we can do GNU-style
3352 dnl visibility attributes for symbol export control
3354 GLIB_HIDDEN_VISIBILITY_CFLAGS=""
3355 case "$host" in
3356   *-*-mingw*)
3357     dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
3358     AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
3359               [defines how to decorate public symbols while building])
3360     CFLAGS="${CFLAGS} -fvisibility=hidden"
3361     ;;
3362   *)
3363     dnl on other compilers, check if we can do -fvisibility=hidden
3364     SAVED_CFLAGS="${CFLAGS}"
3365     CFLAGS="-fvisibility=hidden"
3366     AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
3367     AC_TRY_COMPILE([], [return 0],
3368                    AC_MSG_RESULT(yes)
3369                    enable_fvisibility_hidden=yes,
3370                    AC_MSG_RESULT(no)
3371                    enable_fvisibility_hidden=no)
3372     CFLAGS="${SAVED_CFLAGS}"
3374     AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
3375       AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
3376                 [defines how to decorate public symbols while building])
3377       GLIB_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
3378     ])
3379     ;;
3380 esac
3381 AC_SUBST(GLIB_HIDDEN_VISIBILITY_CFLAGS)
3383 dnl Compiler flags; macro originates from systemd
3384 dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
3385 AC_ARG_ENABLE(compile-warnings,
3386               [AS_HELP_STRING([--disable-compile-warnings],
3387                               [Don't use builtin compiler warnings])],,
3388                               enable_compile_warnings=yes)
3389 AS_IF([test "x$enable_compile_warnings" != xno], [
3390   CC_CHECK_FLAGS_APPEND([GLIB_WARN_CFLAGS], [CFLAGS], [\
3391    -Wall -Wstrict-prototypes -Werror=declaration-after-statement \
3392    -Werror=missing-prototypes -Werror=implicit-function-declaration \
3393    -Werror=pointer-arith -Werror=init-self -Werror=format-security \
3394    -Werror=format=2 -Werror=missing-include-dirs])
3396 AC_SUBST(GLIB_WARN_CFLAGS)
3399 # Define variables corresponding to the correct include paths to use for
3400 # in-tree building.
3403 # for config.h:
3404 config_h_INCLUDES='-I$(top_builddir)'
3405 AC_SUBST(config_h_INCLUDES)
3407 # glib:
3408 #   config.h
3409 #   $(top_builddir)/glib: for glibconfig.h
3410 #   $(top_srcdir)/glib:   for glib.h
3411 #   $(top_srcdir):        for everything
3412 glib_INCLUDES='$(config_h_INCLUDES) -I$(top_builddir)/glib -I$(top_srcdir)/glib -I$(top_srcdir)'
3413 AC_SUBST(glib_INCLUDES)
3415 # gobject:
3416 #   same as glib
3417 gobject_INCLUDES='$(glib_INCLUDES)'
3418 AC_SUBST(gobject_INCLUDES)
3420 # gmodule:
3421 #   glib includes
3422 #   $(top_srcdir)/gmodule: for gmodule.h
3423 gmodule_INCLUDES='$(glib_INCLUDES) -I$(top_srcdir)/gmodule'
3424 AC_SUBST(gmodule_INCLUDES)
3426 # gio:
3427 #   same as gmodule
3428 gio_INCLUDES='$(gmodule_INCLUDES)'
3429 AC_SUBST(gio_INCLUDES)
3432 AC_CONFIG_FILES([
3433 glib-2.0.pc
3434 gmodule-2.0.pc
3435 gmodule-export-2.0.pc
3436 gmodule-no-export-2.0.pc
3437 gthread-2.0.pc
3438 gobject-2.0.pc
3439 gio-2.0.pc
3440 gio-unix-2.0.pc
3441 gio-windows-2.0.pc
3442 glib-zip
3443 glib-gettextize
3444 Makefile
3445 build/Makefile
3446 build/win32/Makefile
3447 build/win32/dirent/Makefile
3448 win32/Makefile
3449 win32/vs9/Makefile
3450 win32/vs9/glib-version-paths.vsprops
3451 win32/vs10/Makefile
3452 win32/vs10/glib-version-paths.props
3453 win32/vs11/Makefile
3454 win32/vs12/Makefile
3455 win32/vs14/Makefile
3456 win32/vs15/Makefile
3457 glib/Makefile
3458 glib/libcharset/Makefile
3459 glib/gnulib/Makefile
3460 glib/pcre/Makefile
3461 glib/update-pcre/Makefile
3462 glib/tests/Makefile
3463 gmodule/Makefile
3464 gmodule/gmoduleconf.h
3465 gobject/Makefile
3466 gobject/glib-genmarshal
3467 gobject/glib-mkenums
3468 gobject/tests/Makefile
3469 gthread/Makefile
3470 gio/Makefile
3471 gio/gdbus-2.0/codegen/Makefile
3472 gio/gdbus-2.0/codegen/config.py
3473 gio/gnetworking.h
3474 gio/xdgmime/Makefile
3475 gio/inotify/Makefile
3476 gio/kqueue/Makefile
3477 gio/fam/Makefile
3478 gio/win32/Makefile
3479 gio/tests/Makefile
3480 gio/tests/gdbus-object-manager-example/Makefile
3481 gio/tests/services/Makefile
3482 gio/tests/services/org.gtk.GDBus.Examples.ObjectManager.service
3483 gio/tests/modules/Makefile
3484 po/Makefile.in
3485 docs/Makefile
3486 docs/reference/Makefile
3487 docs/reference/glib/Makefile
3488 docs/reference/glib/version.xml
3489 docs/reference/gobject/Makefile
3490 docs/reference/gobject/version.xml
3491 docs/reference/gio/Makefile
3492 docs/reference/gio/version.xml
3493 tests/Makefile
3494 tests/gobject/Makefile
3495 tests/refcount/Makefile
3496 m4macros/Makefile
3499 AC_CONFIG_COMMANDS([chmod-scripts],
3500 [chmod 0755 glib-zip
3501 chmod 0755 glib-gettextize
3502 chmod 0755 gobject/glib-genmarshal
3503 chmod 0755 gobject/glib-mkenums])
3505 # we want to invoke this macro solely so that the config.status script
3506 # and automake generated makefiles know about these generated files.
3507 # They are only needed to distcheck the package
3508 if false; then
3509   AC_CONFIG_FILES([
3510     INSTALL
3511     README
3512     config.h.win32
3513     glib/glibconfig.h.win32
3514     glib/glib.rc
3515     gmodule/gmodule.rc
3516     gobject/gobject.rc
3517     gthread/gthread.rc
3518     gio/gio.rc
3519   ])
3522 AC_OUTPUT