1 dnl ***********************************
2 dnl *** include special GLib macros ***
3 dnl ***********************************
5 # require autoconf 2.53
8 # init autoconf (and check for presence of glist.c)
11 # Save this value here, since automake will set cflags later
12 cflags_set=${CFLAGS+set}
14 # we rewrite this file
15 if test "x$cross_compiling" != "xyes"; then
16 rm -f glibconfig-sysdefs.h
20 # The following version number definitions apply to GLib, GModule and GThread
21 # as a whole, so if changes occoured in any of them, they are all
22 # treated with the same interface and binary age.
25 # GLIB_MICRO_VERSION += 1;
26 # GLIB_INTERFACE_AGE += 1;
27 # GLIB_BINARY_AGE += 1;
28 # if any functions have been added, set GLIB_INTERFACE_AGE to 0.
29 # if backwards compatibility has been broken,
30 # set GLIB_BINARY_AGE _and_ GLIB_INTERFACE_AGE to 0.
37 GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
40 AC_SUBST(GLIB_MAJOR_VERSION)
41 AC_SUBST(GLIB_MINOR_VERSION)
42 AC_SUBST(GLIB_MICRO_VERSION)
43 AC_SUBST(GLIB_VERSION)
44 AC_SUBST(GLIB_INTERFACE_AGE)
45 AC_SUBST(GLIB_BINARY_AGE)
48 LT_RELEASE=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION
49 LT_CURRENT=`expr $GLIB_MICRO_VERSION - $GLIB_INTERFACE_AGE`
50 LT_REVISION=$GLIB_INTERFACE_AGE
51 LT_AGE=`expr $GLIB_BINARY_AGE - $GLIB_INTERFACE_AGE`
60 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
62 # Specify a configuration file
63 AM_CONFIG_HEADER(config.h)
65 AC_DEFINE_UNQUOTED(GLIB_MAJOR_VERSION, $GLIB_MAJOR_VERSION)
66 AC_DEFINE_UNQUOTED(GLIB_MINOR_VERSION, $GLIB_MINOR_VERSION)
67 AC_DEFINE_UNQUOTED(GLIB_MICRO_VERSION, $GLIB_MICRO_VERSION)
68 AC_DEFINE_UNQUOTED(GLIB_INTERFACE_AGE, $GLIB_INTERFACE_AGE)
69 AC_DEFINE_UNQUOTED(GLIB_BINARY_AGE, $GLIB_BINARY_AGE)
71 dnl Initialize libtool
74 dnl Initialize maintainer mode
77 dnl figure debugging default, prior to $ac_help setup
79 if test `expr $GLIB_MINOR_VERSION \% 2` = 1 ; then
85 dnl declare --enable-* args and collect ac_help strings
86 AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,enable_debug=$debug_default)
87 AC_ARG_ENABLE(mem_check, [ --enable-mem-check turn on malloc/free sanity checking (not recommended) [default=no]],,enable_mem_check=no)
88 AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile turn on malloc profiling atexit (not recommended) [default=no]],,enable_mem_profile=no)
89 AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
91 AC_ARG_ENABLE(threads, [ --enable-threads turn on basic thread support [default=yes]
92 ([=no] will override --with-threads)],,enable_threads=yes)
94 if test "x$enable_threads" != "xyes"; then
100 AC_MSG_CHECKING(whether to enable memory checking)
101 if test "x$enable_mem_check" = "xyes"; then
102 AC_DEFINE(ENABLE_MEM_CHECK, 1)
103 AC_SUBST(ENABLE_MEM_CHECK)
110 AC_MSG_CHECKING(whether to enable memory profiling)
111 if test "x$enable_mem_profile" = "xyes"; then
112 AC_DEFINE(ENABLE_MEM_PROFILE, 1)
113 AC_SUBST(ENABLE_MEM_PROFILE)
124 **********************************************************************
125 You have specified --enable-mem-profile or --enable-mem-check.
126 These options are not recommended; they have not been thoroughly
127 tested, and may cause unwanted side-effects. If --enable-mem-check is
128 specified, NO MEMORY WILL BE FREED, EVER.
130 References to better memory debugging tools can be found at:
132 http://people.redhat.com/otaylor/memprof/memtools.html
134 **********************************************************************])
137 if test "x$enable_debug" = "xyes"; then
138 test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
139 GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
141 if test "x$enable_debug" = "xno"; then
142 GLIB_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
146 AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
148 # Checks for programs.
154 if test "x$GCC" = "xyes"; then
156 *[\ \ ]-Wall[\ \ ]*) ;;
157 *) CFLAGS="$CFLAGS -Wall" ;;
160 if test "x$enable_ansi" = "xyes"; then
162 *[\ \ ]-ansi[\ \ ]*) ;;
163 *) CFLAGS="$CFLAGS -ansi" ;;
167 *[\ \ ]-pedantic[\ \ ]*) ;;
168 *) CFLAGS="$CFLAGS -pedantic" ;;
174 # Checks for header files.
177 # Checks for library functions.
180 AC_CHECK_FUNCS(atexit on_exit)
182 AC_CHECK_SIZEOF(char)
183 AC_CHECK_SIZEOF(short)
184 AC_CHECK_SIZEOF(long)
186 AC_CHECK_SIZEOF(void *)
187 AC_CHECK_SIZEOF(long long)
189 dnl long doubles were not used, and a portability problem
193 dnl AC_C_INLINE is useless to us since it bails out too early, we need to
194 dnl truely know which ones of `inline', `__inline' and `__inline__' are
195 dnl actually supported.
196 AC_MSG_CHECKING(for __inline)
197 AC_CACHE_VAL(glib_cv_has__inline,[
199 __inline int foo () { return 0; }
200 int main () { return foo (); }
202 glib_cv_has__inline=yes
204 glib_cv_has__inline=no
207 AC_MSG_RESULT($glib_cv_has__inline)
208 case x$glib_cv_has__inline in
209 xyes) AC_DEFINE(G_HAVE___INLINE)
211 AC_MSG_CHECKING(for __inline__)
212 AC_CACHE_VAL(glib_cv_has__inline__,[
214 __inline__ int foo () { return 0; }
215 int main () { return foo (); }
217 glib_cv_has__inline__=yes
219 glib_cv_has__inline__=no
222 AC_MSG_RESULT($glib_cv_has__inline__)
223 case x$glib_cv_has__inline__ in
224 xyes) AC_DEFINE(G_HAVE___INLINE__)
226 AC_MSG_CHECKING(for inline)
227 AC_CACHE_VAL(glib_cv_hasinline,[
229 inline int foo () { return 0; }
230 int main () { return foo (); }
232 glib_cv_hasinline=yes
237 AC_MSG_RESULT($glib_cv_hasinline)
238 case x$glib_cv_hasinline in
239 xyes) AC_DEFINE(G_HAVE_INLINE)
242 dnl for bytesex stuff
245 dnl header file checks
246 AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H))
247 AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H))
248 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
249 AC_CHECK_HEADERS(sys/param.h, AC_DEFINE(HAVE_SYS_PARAM_H))
250 AC_CHECK_HEADERS(sys/poll.h, AC_DEFINE(HAVE_SYS_POLL_H))
251 AC_CHECK_HEADERS(sys/select.h, AC_DEFINE(HAVE_SYS_SELECT_H))
252 AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
253 AC_CHECK_HEADERS(sys/times.h, AC_DEFINE(HAVE_SYS_TIMES_H))
254 AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
255 AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
257 # Check for some functions
258 AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll)
260 # Check for sys_errlist
261 AC_MSG_CHECKING(for sys_errlist)
263 extern char *sys_errlist[];
265 sys_errlist[sys_nerr-1][0] = 0;
266 ], glib_ok=yes, glib_ok=no)
267 AC_MSG_RESULT($glib_ok)
268 if test $glib_ok = no; then
269 AC_DEFINE(NO_SYS_ERRLIST)
272 # Check for sys_siglist
273 AC_MSG_CHECKING(for sys_siglist)
275 extern char *sys_siglist[];
276 exit (sys_siglist[0]);
277 ], glib_ok=yes, glib_ok=no)
278 AC_MSG_RESULT($glib_ok)
279 if test $glib_ok = no; then
280 AC_DEFINE(NO_SYS_SIGLIST)
283 # Check for sys_siglist decl (see Tue Jan 19 00:44:24 1999 in changelog)
284 AC_MSG_CHECKING(for sys_siglist declaration)
285 AC_TRY_COMPILE([#include <signal.h>], [
286 strlen (sys_siglist[0]);
287 ], glib_ok=yes, glib_ok=no)
288 AC_MSG_RESULT($glib_ok)
289 if test $glib_ok = no; then
290 AC_DEFINE(NO_SYS_SIGLIST_DECL)
293 # Check if <sys/select.h> needs to be included for fd_set
294 AC_MSG_CHECKING([for fd_set])
295 AC_TRY_COMPILE([#include <sys/types.h>],
296 [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
297 if test $gtk_ok = yes; then
298 AC_MSG_RESULT([yes, found in sys/types.h])
300 AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
301 if test $gtk_ok = yes; then
302 AC_DEFINE(HAVE_SYS_SELECT_H)
303 AC_MSG_RESULT([yes, found in sys/select.h])
310 # These are used only in GDK (gdki18n.h)
311 # This stuff is here only so that we can define these
312 # things in glibconfig.h. If gtk+ started using an installed
313 # gdkconfig.h file, then the definitions would belong there.
317 AC_MSG_CHECKING(for wchar.h)
318 AC_TRY_CPP([#include <wchar.h>], glib_wchar_h=yes, glib_wchar_h=no)
319 if test $glib_wchar_h = yes; then
320 AC_DEFINE(HAVE_WCHAR_H)
322 AC_MSG_RESULT($glib_wchar_h)
324 # Check for wctype.h (for iswalnum)
326 AC_MSG_CHECKING(for wctype.h)
327 AC_TRY_CPP([#include <wctype.h>], glib_wctype_h=yes, glib_wctype_h=no)
328 if test $glib_wctype_h = yes; then
329 AC_DEFINE(HAVE_WCTYPE_H)
331 AC_MSG_RESULT($glib_wctype_h)
334 # in Solaris 2.5, `iswalnum' is in -lw
335 AC_CHECK_FUNC(iswalnum,,[AC_CHECK_LIB(w,iswalnum)])
337 # The following is necessary for Linux libc-5.4.38
338 AC_MSG_CHECKING(if iswalnum() and friends are properly defined)
339 AC_TRY_LINK([#include <stdlib.h>],[
340 #if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))
341 # ifdef HAVE_WCTYPE_H
349 # define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
351 iswalnum((wchar_t) 0);
352 ], glib_working_wctype=yes, glib_working_wctype=no)
355 if test $glib_working_wctype = no; then
356 AC_DEFINE(HAVE_BROKEN_WCTYPE)
358 AC_MSG_RESULT($glib_working_wctype)
360 dnl *** check for sane realloc() ***
361 AC_MSG_CHECKING(whether realloc (NULL,) will work)
362 AC_CACHE_VAL(glib_cv_sane_realloc,[
366 return realloc (0, sizeof (int)) == 0;
368 glib_cv_sane_realloc=yes
370 glib_cv_sane_realloc=no
373 if test "x$glib_cv_sane_realloc" = "xyes"; then
374 AC_DEFINE(REALLOC_0_WORKS)
376 AC_MSG_RESULT($glib_cv_sane_realloc)
379 dnl **********************
380 dnl *** va_copy checks ***
381 dnl **********************
382 dnl we currently check for all three va_copy possibilities, so we get
383 dnl all results in config.log for bug reports.
384 AC_MSG_CHECKING(for an implementation of va_copy())
385 AC_CACHE_VAL(glib_cv_va_copy,[
388 void f (int i, ...) {
389 va_list args1, args2;
391 va_copy (args2, args1);
392 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
394 va_end (args1); va_end (args2);
405 AC_MSG_RESULT($glib_cv_va_copy)
406 AC_MSG_CHECKING(for an implementation of __va_copy())
407 AC_CACHE_VAL(glib_cv___va_copy,[
410 void f (int i, ...) {
411 va_list args1, args2;
413 __va_copy (args2, args1);
414 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
416 va_end (args1); va_end (args2);
422 glib_cv___va_copy=yes
427 AC_MSG_RESULT($glib_cv___va_copy)
428 AC_MSG_CHECKING(whether va_lists can be copied by value)
429 AC_CACHE_VAL(glib_cv_va_val_copy,[
432 void f (int i, ...) {
433 va_list args1, args2;
436 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
438 va_end (args1); va_end (args2);
444 glib_cv_va_val_copy=yes
446 glib_cv_va_val_copy=no
449 if test "x$glib_cv_va_copy" = "xyes"; then
450 AC_DEFINE(G_VA_COPY, va_copy)
452 if test "x$glib_cv___va_copy" = "xyes"; then
453 AC_DEFINE(G_VA_COPY, __va_copy)
456 if test "x$glib_cv_va_val_copy" = "xno"; then
457 AC_DEFINE(G_VA_COPY_AS_ARRAY)
459 AC_MSG_RESULT($glib_cv_va_val_copy)
462 dnl ***********************
463 dnl *** g_module checks ***
464 dnl ***********************
467 dnl G_MODULE_IMPL= don't reset, so cmd-line can override
468 G_MODULE_NEED_USCORE=0
469 G_MODULE_BROKEN_RTLD_GLOBAL=0
470 G_MODULE_HAVE_DLERROR=0
471 dnl *** dlopen() and dlsym() in system libraries
472 AC_CHECK_FUNC([dlopen], [AC_CHECK_FUNC([dlsym], [G_MODULE_IMPL=G_MODULE_IMPL_DL], [])], [])
473 dnl *** dlopen() and dlsym() in libdl
474 if test -z "$G_MODULE_IMPL"; then
475 AC_CHECK_LIB([dl], [dlopen], [AC_CHECK_LIB([dl], [dlsym], [
477 G_MODULE_IMPL=G_MODULE_IMPL_DL
480 dnl *** shl_load() in libdld (HP-UX)
481 if test -z "$G_MODULE_IMPL"; then
482 AC_MSG_CHECKING(how to export all symbols)
483 SAVED_LDFLAGS=$LDFLAGS
484 LDFLAGS="$LDFLAGS -Wl,-E"
485 AC_TRY_LINK(,[ return 0; ],
486 [ G_MODULE_LDFLAGS="-Wl,-E" ],[
487 LDFLAGS="$SAVED_LDFLAGS -bexpall"
488 AC_TRY_LINK(,[ return 0; ],
489 G_MODULE_LDFLAGS="-bexpall",
490 G_MODULE_LDFLAGS="none"
493 LDFLAGS=$SAVED_LDFLAGS
494 AC_MSG_RESULT($G_MODULE_LDFLAGS)
495 if test "x$G_MODULE_LDFLAGS" = "xnone"; then
498 AC_CHECK_LIB(dld, shl_load,
500 G_MODULE_IMPL=G_MODULE_IMPL_DLD
503 dnl *** additional checks for G_MODULE_IMPL_DL
504 if test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL"; then
507 G_MODULE_LDFLAGS='-rdynamic'
511 LDFLAGS_orig="$LDFLAGS"
512 LIBS="$LIBS $G_MODULE_LIBS"
513 LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
514 dnl *** check for OSF1/5.0 RTLD_GLOBAL brokenness
515 AC_CACHE_CHECK([for RTLD_GLOBAL brokenness],
516 glib_cv_rtldglobal_broken,[
520 #define RTLD_GLOBAL 0
527 void *handle, *global, *local;
528 global = &pthread_create;
529 handle = dlopen ("libpthread.so", RTLD_GLOBAL | RTLD_LAZY);
530 if (!handle) return 0;
531 local = dlsym (handle, "pthread_create");
532 return global == local;
534 [glib_cv_rtldglobal_broken=no],
535 [glib_cv_rtldglobal_broken=yes],
537 rm -f plugin.c plugin.o plugin.lo
539 if test "x$glib_cv_rtldglobal_broken" = "xyes"; then
540 G_MODULE_BROKEN_RTLD_GLOBAL=1
542 G_MODULE_BROKEN_RTLD_GLOBAL=0
544 dnl *** check whether we need preceeding underscores
545 AC_MSG_CHECKING(for preceeding underscore in symbols)
546 AC_CACHE_VAL(glib_cv_uscore,[
549 int glib_underscore_test (void) { return 42; }
551 void *f1 = (void*)0, *f2 = (void*)0, *handle;
552 handle = dlopen ((void*)0, 0);
554 f1 = dlsym (handle, "glib_underscore_test");
555 f2 = dlsym (handle, "_glib_underscore_test");
556 } return (!f2 || f1);
561 rm -f plugin.c plugin.o plugin.lo
563 AC_MSG_RESULT($glib_cv_uscore)
564 if test "x$glib_cv_uscore" = "xyes"; then
565 G_MODULE_NEED_USCORE=1
567 G_MODULE_NEED_USCORE=0
570 LDFLAGS="$LDFLAGS_orig"
571 dnl *** check for having dlerror()
572 AC_CHECK_FUNC(dlerror,
573 G_MODULE_HAVE_DLERROR=1,
574 G_MODULE_HAVE_DLERROR=0)
577 dnl *** done, have e got an implementation?
578 if test -z "$G_MODULE_IMPL"; then
581 AC_SUBST(G_MODULE_IMPL)
582 AC_SUBST(G_MODULE_LIBS)
583 AC_SUBST(G_MODULE_LDFLAGS)
584 AC_SUBST(G_MODULE_HAVE_DLERROR)
585 AC_SUBST(G_MODULE_NEED_USCORE)
586 AC_SUBST(G_MODULE_BROKEN_RTLD_GLOBAL)
587 AC_SUBST(GLIB_DEBUG_FLAGS)
590 dnl ***********************
591 dnl *** g_thread checks ***
592 dnl ***********************
594 AC_ARG_WITH(threads, [ --with-threads=[none/posix/solaris/nspr] specify a thread implementation to use],
595 if test "x$with_threads" = x; then
598 want_threads=$with_threads
601 if test "x$enable_threads" = "xno"; then
604 if test "x$want_threads" = "xnone"; then
608 dnl error and warning message
609 dnl *************************
611 THREAD_NO_IMPLEMENTATION="You do not have any known thread system on your
612 computer. glib will not be thread safe on your computer."
614 FLAG_DOES_NOT_WORK="I can't find the MACRO, that enables thread safety on your
615 platform (normally it's "_REENTRANT"). I'll not use any flag on
616 compilation now, but then your programs might not work.
617 Please provide information on how it is done on your system."
619 LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
622 LIBS_NOT_FOUND_2=". Please choose another thread implementation or
623 provide information on your thread implementation.
624 You can also run 'configure --disable-threads'
625 to compile without thread support."
627 FUNC_NO_GETPWUID_R="the 'g_get_(user_name|real_name|home_dir|tmp_dir)'
628 functions will not be MT-safe during their first call because
629 there is no working 'getpwuid_r' on your system."
631 FUNC_NO_LOCALTIME_R="the 'g_date_set_time' function will not be MT-safe
632 because there is no 'localtime_r' on your system."
634 dnl determination of thread implementation
635 dnl ***************************************
638 if test "x$want_threads" = xyes || test "x$want_threads" = xsolaris; then
641 AC_CHECK_LIB(thread, cond_init, have_threads=solaris)
645 if test "x$want_threads" = xyes || test "x$want_threads" = xposix; then
646 if test "x$have_threads" = xnone; then
647 AC_CHECK_HEADER(pthread.h, have_threads=posix)
650 if test "x$want_threads" = xyes || test "x$want_threads" = xnspr; then
651 if test "x$have_threads" = xnone; then
652 AC_CHECK_LIB(nspr21, PRP_NewNakedCondVar, have_threads=nspr)
656 AC_MSG_CHECKING(for thread implementation)
658 if test "x$have_threads" = xnone && test "x$want_threads" != xno; then
659 AC_MSG_RESULT(none available)
660 AC_MSG_WARN($THREAD_NO_IMPLEMENTATION)
662 AC_MSG_RESULT($have_threads)
666 dnl determination of G_THREAD_LIBS
667 dnl ******************************
673 case $have_threads in
676 AC_CHECK_LIB(pthread, pthread_attr_init,
677 G_THREAD_LIBS="-lpthread")
678 if test "x$G_THREAD_LIBS" = xerror; then
679 AC_CHECK_LIB(pthreads, pthread_attr_init,
680 G_THREAD_LIBS="-lpthreads")
682 if test "x$G_THREAD_LIBS" = xerror; then
683 AC_CHECK_LIB(thread, pthread_attr_init,
684 G_THREAD_LIBS="-lthread")
686 if test "x$G_THREAD_LIBS" = xerror; then
687 AC_CHECK_LIB(c_r, pthread_attr_init,
688 G_THREAD_LIBS="-lc_r")
690 if test "x$G_THREAD_LIBS" = xerror; then
691 AC_CHECK_FUNC(pthread_attr_init, G_THREAD_LIBS="")
693 dnl ********** DG/UX ************
694 if test "x$G_THREAD_LIBS" = xerror; then
695 AC_CHECK_LIB(thread, __d10_pthread_attr_init,
696 G_THREAD_LIBS="-lthread"
697 G_THREAD_CFLAGS="-D_POSIX4A_DRAFT10_SOURCE")
699 dnl ********* HPUX 11 ***********
700 if test "x$G_THREAD_LIBS" = xerror; then
701 AC_CHECK_LIB(pthread, __pthread_attr_init_system,
702 G_THREAD_LIBS="-lpthread")
704 mutex_has_default=yes
705 mutex_default_type='pthread_mutex_t'
706 mutex_default_init='PTHREAD_MUTEX_INITIALIZER'
707 mutex_header_file='pthread.h'
708 g_threads_impl="POSIX"
712 AC_CHECK_LIB(thread, cond_init, G_THREAD_LIBS="-lthread")
713 mutex_has_default=yes
714 mutex_default_type='mutex_t'
715 mutex_default_init="DEFAULTMUTEX"
716 mutex_header_file='thread.h'
717 g_threads_impl="SOLARIS"
720 AC_CHECK_LIB(nspr21, PRP_NewNakedCondVar,
721 G_THREAD_LIBS="-lnspr21")
722 g_threads_impl="NSPR"
725 g_threads_impl="NONE"
728 g_threads_impl="NONE"
733 if test "x$G_THREAD_LIBS" = xerror; then
734 AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
737 AC_MSG_CHECKING(necessary linker options)
738 AC_MSG_RESULT($G_THREAD_LIBS)
740 dnl determination of G_THREAD_CFLAGS
741 dnl ********************************
743 if test x"$have_threads" != xnone; then
744 G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_REENTRANT" # good default guess
748 G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
749 if test x"$GCC" = xyes; then
750 G_THREAD_CFLAGS="$G_THREAD_CFLAGS -mthreads"
754 G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
756 # FreeBSD 2.2.x shiped with gcc 2.7.2.x, which doesn't support
761 # if we are not finding the ctime_r function, then we probably are
762 # not using the proper multithread flag
763 # Note: Digital UNIX 4.0d #defines ctime_r to _Pctime_r for gcc.
764 old_CPPFLAGS=$CPPFLAGS
765 CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
766 AC_EGREP_HEADER([[^a-zA-Z_](_P)?ctime_r[^a-zA-Z_]], time.h, ,
768 AC_MSG_WARN($FLAG_DOES_NOT_WORK))
769 CPPFLAGS=$old_CPPFLAGS
771 AC_MSG_CHECKING(necessary compiler options)
773 AC_MSG_RESULT($G_THREAD_CFLAGS)
778 dnl check for mt safe function variants
779 dnl ***********************************
781 if test x"$have_threads" != xnone; then
782 glib_save_LIBS="$LIBS"
783 glib_save_CFLAGS="$CFLAGS"
784 # we are not doing the following for now, as this might require glib
785 # to always be linked with the thread libs on some platforms.
786 # LIBS="$LIBS $G_THREAD_LIBS"
787 CFLAGS="$CFLAGS $G_THREAD_CFLAGS"
788 AC_CHECK_FUNCS(localtime_r rand_r)
789 if test "$ac_cv_header_pwd_h" = "yes"; then
790 AC_MSG_CHECKING([for getpwuid_r])
791 AC_CACHE_VAL(ac_cv_func_getpwuid_r,
792 [AC_TRY_RUN([#include <errno.h>
793 int main () { char buffer[10000], *pointer;
794 char getpwuid_r (long, void*, void*,
798 error = getpwuid_r (0, &buffer, &buffer,
799 sizeof (buffer), &pointer);
800 return errno == ENOSYS || error == ENOSYS;}],
801 [ac_cv_func_getpwuid_r=yes],
802 [ac_cv_func_getpwuid_r=no])])
803 if test "$ac_cv_func_getpwuid_r" = yes; then
805 AC_DEFINE(HAVE_GETPWUID_R)
809 if test "$ac_cv_func_getpwuid_r" = "yes"; then
810 AC_MSG_CHECKING(whether getpwuid_r is posix like)
811 # The signature for the POSIX version is:
812 # int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **)
813 AC_CACHE_CHECK([whether pthread_getspecific is posix like],
814 [ac_cv_func_getpwuid_r_posix],
815 [AC_TRY_COMPILE([#include <pwd.h>
816 #include <sys/types.h>
817 #include <stdlib.h>],
818 [getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
819 [ac_cv_func_getpwuid_r_posix=yes],
820 [ac_cv_func_getpwuid_r_posix=no])]
822 if test "x$ac_cv_func_getpwuid_r_posix" = "xyes"; then
823 AC_DEFINE(HAVE_GETPWUID_R_POSIX)
827 if test x"$have_threads" = xposix; then
828 LIBS="$LIBS $G_THREAD_LIBS"
829 AC_MSG_CHECKING(whether pthread_getspecific is posix like)
830 # PCThreads has pthread_getspecific(pthread_key_t, void **);
831 AC_CACHE_CHECK([whether pthread_getspecific is posix like],
832 [glib_cv_sys_pthread_getspecific_posix],
833 [AC_TRY_COMPILE([#include <pthread.h>],
834 [pthread_getspecific(0,NULL);],
835 [glib_cv_sys_pthread_getspecific_posix=no],
836 [glib_cv_sys_pthread_getspecific_posix=yes])]
838 if test "x$glib_cv_sys_pthread_getspecific_posix" = "xyes"; then
839 AC_DEFINE(HAVE_PTHREAD_GETSPECIFIC_POSIX)
841 AC_MSG_CHECKING(whether pthread_mutex_trylock is posix like)
842 # DCE Threads return 1 as success, posix 0. what a mess.
843 AC_CACHE_CHECK([whether pthread_mutex_trylock is posix like],
844 [glib_cv_sys_pthread_mutex_trylock_posix],
845 [AC_TRY_RUN([#include <pthread.h>
846 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
848 return !pthread_mutex_trylock (&mutex); }],
849 [glib_cv_sys_pthread_mutex_trylock_posix=no],
850 [glib_cv_sys_pthread_mutex_trylock_posix=yes])]
852 if test "x$glib_cv_sys_pthread_mutex_trylock_posix=no" = "xyes"; then
853 AC_DEFINE(HAVE_PTHREAD_MUTEX_TRYLOCK_POSIX)
855 AC_MSG_CHECKING(whether pthread_cond_timedwait is posix like)
856 # DCE Threads return -1 as failure, posix ETIMEDOUT.
857 AC_CACHE_CHECK([whether pthread_cond_timedwait is posix like],
858 [glib_cv_sys_pthread_cond_timedwait_posix],
859 [AC_TRY_RUN([#include <pthread.h>
861 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
862 pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
864 struct timespec tspec;
865 gettimeofday (&tval, NULL);
866 tspec.tv_sec = tval.tv_sec;
868 return pthread_cond_timedwait (&cond,&mutex,&tspec) != -1;}],
869 [glib_cv_sys_pthread_cond_timedwait_posix=no],
870 [glib_cv_sys_pthread_cond_timedwait_posix=yes])]
872 if test "x$glib_cv_sys_pthread_cond_timedwait_posix" = "xyes"; then
873 AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_POSIX)
876 LIBS="$glib_save_LIBS"
877 CFLAGS="$glib_save_CFLAGS"
880 if test "x$enable_threads" = "xyes"; then
881 if test "$ac_cv_func_getpwuid_r" != "yes"; then
882 AC_MSG_WARN($FUNC_NO_GETPWUID_R)
884 if test "$ac_cv_func_localtime_r" != "yes"; then
885 AC_MSG_WARN($FUNC_NO_LOCALTIME_R)
889 AC_DEFINE_UNQUOTED(G_THREAD_SOURCE,"gthread-$have_threads.c")
890 AC_SUBST(G_THREAD_CFLAGS)
891 AC_SUBST(G_THREAD_LIBS)
893 CFLAGS="$CFLAGS $G_THREAD_CFLAGS"
895 dnl **********************************************
896 dnl *** GDefaultMutex setup and initialization ***
897 dnl **********************************************
899 dnl if mutex_has_default = yes, we also got
900 dnl mutex_default_type, mutex_default_init and mutex_header_file
901 GLIB_IF_VAR_EQ(mutex_has_default, yes,
902 GLIB_SIZEOF([#include <$mutex_header_file>],
906 GLIB_BYTE_CONTENTS([#include <$mutex_header_file>],
909 $glib_cv_sizeof_gmutex,
915 dnl ****************************************
916 dnl *** GLib POLL* compatibility defines ***
917 dnl ****************************************
918 if test "x$cross_compiling" != "xyes"; then
920 [#include <sys/types.h>
921 #include <sys/poll.h>],
922 POLLIN:1 POLLOUT:4 POLLPRI:2 POLLERR:8 POLLHUP:16 POLLNVAL:32,
923 glibconfig-sysdefs.h,
928 dnl ******************************
929 dnl *** output the whole stuff ***
930 dnl ******************************
934 ## Generate `glibconfig.h' in two cases
935 ## 1. `config.status' is run either explicitly, or via configure.
936 ## Esp. not when it is run in `Makefile' to generate makefiles and
938 ## 2. CONFIG_OTHER is set explicitly
940 ## Case 1 is difficult. We know that `automake' sets one of
941 ## CONFIG_FILES or CONFIG_HEADERS to empty. This heuristic works
942 ## only when AM_CONFIG_HEADER is set, however.
944 if test -n "${CONFIG_FILES}" && test -n "${CONFIG_HEADERS}"; then
945 # Both CONFIG_FILES and CONFIG_HEADERS are non-empty ==> Case 1
946 CONFIG_OTHER=${CONFIG_OTHER:-glibconfig.h}
948 case "$CONFIG_OTHER" in
950 echo creating glibconfig.h
951 outfile=glibconfig.h-tmp
952 cat > $outfile <<\_______EOF
955 * This is a generated file. Please modify `configure.in'
963 if test x$glib_limits_h = xyes; then
964 echo '#include <limits.h>' >> $outfile
966 if test x$glib_float_h = xyes; then
967 echo '#include <float.h>' >> $outfile
969 if test x$glib_values_h = xyes; then
970 echo '#include <values.h>' >> $outfile
972 if test x$g_mutex_header_file != x; then
973 echo '#include <'"$g_mutex_header_file"'>' >> $outfile
975 if test x$glib_sys_poll_h = xyes; then
976 echo '#define GLIB_HAVE_SYS_POLL_H' >> $outfile
979 cat >> $outfile <<_______EOF
983 #endif /* __cplusplus */
985 #define G_MINFLOAT $glib_mf
986 #define G_MAXFLOAT $glib_Mf
987 #define G_MINDOUBLE $glib_md
988 #define G_MAXDOUBLE $glib_Md
989 #define G_MINSHORT $glib_ms
990 #define G_MAXSHORT $glib_Ms
991 #define G_MININT $glib_mi
992 #define G_MAXINT $glib_Mi
993 #define G_MINLONG $glib_ml
994 #define G_MAXLONG $glib_Ml
999 ### this should always be true in a modern C/C++ compiler
1000 cat >>$outfile <<_______EOF
1001 typedef signed char gint8;
1002 typedef unsigned char guint8;
1006 if test -n "$gint16"; then
1007 cat >>$outfile <<_______EOF
1008 typedef signed $gint16 gint16;
1009 typedef unsigned $gint16 guint16;
1014 if test -n "$gint32"; then
1015 cat >>$outfile <<_______EOF
1016 typedef signed $gint32 gint32;
1017 typedef unsigned $gint32 guint32;
1022 if test -n "$gint64"; then
1023 cat >>$outfile <<_______EOF
1024 ${glib_warning_guard}#define G_HAVE_GINT64 1
1026 ${glib_extension}typedef signed $gint64 gint64;
1027 ${glib_extension}typedef unsigned $gint64 guint64;
1029 #define G_GINT64_CONSTANT(val) $gint64_constant
1034 if test -z "$glib_unknown_void_p"; then
1035 cat >>$outfile <<_______EOF
1037 #define GPOINTER_TO_INT(p) ((gint) ${glib_gpi_cast} (p))
1038 #define GPOINTER_TO_UINT(p) ((guint) ${glib_gpui_cast} (p))
1040 #define GINT_TO_POINTER(i) ((gpointer) ${glib_gpi_cast} (i))
1041 #define GUINT_TO_POINTER(u) ((gpointer) ${glib_gpui_cast} (u))
1044 echo '#error SIZEOF_VOID_P unknown - This should never happen' >>$outfile
1049 cat >>$outfile <<_______EOF
1057 #define G_HAVE_INLINE 1
1058 #else /* !__cplusplus */
1060 #endif /* !__cplusplus */
1064 if test x$g_mutex_has_default = xyes; then
1065 cat >>$outfile <<_______EOF
1066 $g_enable_threads_def G_THREADS_ENABLED
1067 #define G_THREADS_IMPL_$g_threads_impl_def
1068 typedef struct _GStaticMutex GStaticMutex;
1069 struct _GStaticMutex
1071 struct _GMutex *runtime_mutex;
1073 char pad[$g_mutex_sizeof];
1074 double dummy_double;
1075 void *dummy_pointer;
1079 #define G_STATIC_MUTEX_INIT { NULL, { { $g_mutex_contents} } }
1080 #define g_static_mutex_get_mutex(mutex) \
1081 (g_thread_use_default_impl ? ((GMutex*) &((mutex)->aligned_pad_u)) : \
1082 g_static_mutex_get_mutex_impl (&((mutex)->runtime_mutex)))
1085 cat >>$outfile <<_______EOF
1086 $g_enable_threads_def G_THREADS_ENABLED
1087 #define G_THREADS_IMPL_$g_threads_impl_def
1088 typedef struct _GMutex* GStaticMutex;
1089 #define G_STATIC_MUTEX_INIT NULL
1090 #define g_static_mutex_get_mutex(mutex) (g_static_mutex_get_mutex_impl (mutex))
1096 if test -n "$gint64"; then
1097 g_bit_sizes="$g_bit_sizes 64"
1099 for bits in $g_bit_sizes; do
1100 cat >>$outfile <<_______EOF
1101 #define GINT${bits}_TO_${g_bs_native}(val) ((gint${bits}) (val))
1102 #define GUINT${bits}_TO_${g_bs_native}(val) ((guint${bits}) (val))
1103 #define GINT${bits}_TO_${g_bs_alien}(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
1104 #define GUINT${bits}_TO_${g_bs_alien}(val) (GUINT${bits}_SWAP_LE_BE (val))
1108 cat >>$outfile <<_______EOF
1109 #define GLONG_TO_LE(val) ((glong) GINT${glongbits}_TO_LE (val))
1110 #define GULONG_TO_LE(val) ((gulong) GUINT${glongbits}_TO_LE (val))
1111 #define GLONG_TO_BE(val) ((glong) GINT${glongbits}_TO_BE (val))
1112 #define GULONG_TO_BE(val) ((gulong) GUINT${glongbits}_TO_BE (val))
1113 #define GINT_TO_LE(val) ((gint) GINT${gintbits}_TO_LE (val))
1114 #define GUINT_TO_LE(val) ((guint) GUINT${gintbits}_TO_LE (val))
1115 #define GINT_TO_BE(val) ((gint) GINT${gintbits}_TO_BE (val))
1116 #define GUINT_TO_BE(val) ((guint) GUINT${gintbits}_TO_BE (val))
1117 #define G_BYTE_ORDER $g_byte_order
1121 if test -r glibconfig-sysdefs.h; then
1122 cat glibconfig-sysdefs.h >>$outfile
1126 cat >>$outfile <<_______EOF
1133 #endif /* __cplusplus */
1135 #endif /* GLIBCONFIG_H */
1139 if cmp -s $outfile glibconfig.h; then
1140 echo glibconfig.h is unchanged
1143 mv $outfile glibconfig.h
1148 # Note that if two cases are the same, case goes with the first one.
1149 # Note also that this is inside an AC_OUTPUT_COMMAND. We do not depend
1150 # on variable expansion in case labels. Look at the generated config.status
1154 x$ac_cv_header_float_h)
1156 glib_mf=FLT_MIN glib_Mf=FLT_MAX
1157 glib_md=DBL_MIN glib_Md=DBL_MAX
1159 x$ac_cv_header_values_h)
1161 glib_mf=MINFLOAT glib_Mf=MAXFLOAT
1162 glib_md=MINDOUBLE glib_Md=MAXDOUBLE
1167 x$ac_cv_header_limits_h)
1169 glib_ms=SHRT_MIN glib_Ms=SHRT_MAX
1170 glib_mi=INT_MIN glib_Mi=INT_MAX
1171 glib_ml=LONG_MIN glib_Ml=LONG_MAX
1173 x$ac_cv_header_values_h)
1175 glib_ms=MINSHORT glib_Ms=MAXSHORT
1176 glib_mi=MININT glib_Mi=MAXINT
1177 glib_ml=MINLONG glib_Ml=MAXLONG
1181 if test x$ac_cv_header_sys_poll_h = xyes ; then
1186 $ac_cv_sizeof_short) gint16=short;;
1187 $ac_cv_sizeof_int) gint16=int;;
1190 $ac_cv_sizeof_short) gint32=short;;
1191 $ac_cv_sizeof_int) gint32=int;;
1192 $ac_cv_sizeof_long) gint32=long;;
1199 gint64_constant='(val)'
1205 gint64_constant='(val##L)'
1207 $ac_cv_sizeof_long_long)
1209 glib_extension='G_GNUC_EXTENSION '
1210 glib_warning_guard="
1211 #if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
1212 # define G_GNUC_EXTENSION __extension__
1214 # define G_GNUC_EXTENSION
1218 gint64_constant='(G_GNUC_EXTENSION (val##LL))'
1222 gintbits=`expr $ac_cv_sizeof_int \* 8`
1223 glongbits=`expr $ac_cv_sizeof_long \* 8`
1226 case $ac_cv_sizeof_void_p in
1227 $ac_cv_sizeof_int) glib_gpi_cast='' glib_gpui_cast='' ;;
1228 $ac_cv_sizeof_long) glib_gpi_cast='(glong)' glib_gpui_cast='(gulong)' ;;
1229 *) glib_unknown_void_p=yes ;;
1234 x$ac_cv_func_atexit)
1236 #ifdef NeXT /* @#%@! NeXTStep */
1237 # define g_ATEXIT(proc) (!atexit (proc))
1239 # define g_ATEXIT(proc) (atexit (proc))
1242 x$ac_cv_func_on_exit)
1244 #define g_ATEXIT(proc) (on_exit ((void (*)(int, void*))(proc), NULL))"
1249 x$ac_cv_func_memmove)
1251 #define g_memmove(d,s,n) G_STMT_START { memmove ((d), (s), (n)); } G_STMT_END'
1255 /* We make the assumption that if memmove isn't available, then
1256 * bcopy will do the job. This isn't safe everywhere. (bcopy can't
1257 * necessarily handle overlapping copies) */
1258 #define g_memmove(d,s,n) G_STMT_START { bcopy ((s), (d), (n)); } G_STMT_END"
1263 #define GLIB_MAJOR_VERSION $GLIB_MAJOR_VERSION
1264 #define GLIB_MINOR_VERSION $GLIB_MINOR_VERSION
1265 #define GLIB_MICRO_VERSION $GLIB_MICRO_VERSION
1269 x$glib_cv_va_copy) glib_vacopy='#define G_VA_COPY va_copy' ;;
1270 x$glib_cv___va_copy) glib_vacopy='#define G_VA_COPY __va_copy' ;;
1274 if test x$glib_cv_va_val_copy = xno; then
1275 glib_vacopy="\$glib_vacopy
1276 #define G_VA_COPY_AS_ARRAY 1"
1279 if test x$glib_cv_hasinline = xyes; then
1280 glib_inline='#define G_HAVE_INLINE 1'
1282 if test x$glib_cv_has__inline = xyes; then
1283 glib_inline="\$glib_inline
1284 #define G_HAVE___INLINE 1"
1286 if test x$glib_cv_has__inline__ = xyes; then
1287 glib_inline="\$glib_inline
1288 #define G_HAVE___INLINE__ 1"
1292 x$ac_cv_c_bigendian)
1293 g_byte_order=G_BIG_ENDIAN
1298 g_byte_order=G_LITTLE_ENDIAN
1304 if test x$glib_wchar_h = xyes; then
1306 #define G_HAVE_WCHAR_H 1'
1308 if test x$glib_wctype_h = xyes; then
1310 #define G_HAVE_WCTYPE_H 1"
1312 if test x$glib_working_wctype = xno; then
1314 #define G_HAVE_BROKEN_WCTYPE 1"
1317 case x$enable_threads in
1318 xyes) g_enable_threads_def="#define";;
1319 *) g_enable_threads_def="#undef ";;
1322 g_threads_impl_def=$g_threads_impl
1324 g_mutex_has_default="$mutex_has_default"
1325 g_mutex_sizeof="$glib_cv_sizeof_gmutex"
1326 g_mutex_contents="$glib_cv_byte_contents_gmutex"
1333 gmodule/gmoduleconf.h
1342 ],[case "$CONFIG_FILES" in
1343 *glib-config*)chmod +x glib-config;;