Updated Catalan translation.
[platform/upstream/glib.git] / configure.in
index 78aa75e..eb711d7 100644 (file)
@@ -1,12 +1,15 @@
 dnl ***********************************
 dnl *** include special GLib macros ***
 dnl ***********************************
+
+define(glib_configure_in)
 builtin(include, acglib.m4)dnl
 builtin(include, glib/libcharset/codeset.m4)dnl
 builtin(include, glib/libcharset/glibc21.m4)dnl
+builtin(include, m4macros/glib-gettext.m4)dnl
 
-# require autoconf 2.52
-AC_PREREQ(2.52)
+# require autoconf 2.53
+AC_PREREQ(2.53)
 
 # Process this file with autoconf to produce a configure script.
 AC_INIT(glib/glib.h)
@@ -14,9 +17,6 @@ AC_INIT(glib/glib.h)
 # Save this value here, since automake will set cflags later
 cflags_set=${CFLAGS+set}
 
-# we rewrite this file
-rm -f glibconfig-sysdefs.h
-
 GLIB_AC_DIVERT_BEFORE_HELP([
 #
 # The following version number definitions apply to GLib, GModule, GObject 
@@ -32,10 +32,10 @@ GLIB_AC_DIVERT_BEFORE_HELP([
 # set GLIB_BINARY_AGE _and_ GLIB_INTERFACE_AGE to 0.
 #
 GLIB_MAJOR_VERSION=2
-GLIB_MINOR_VERSION=0
-GLIB_MICRO_VERSION=1
-GLIB_INTERFACE_AGE=1
-GLIB_BINARY_AGE=1
+GLIB_MINOR_VERSION=1
+GLIB_MICRO_VERSION=5
+GLIB_INTERFACE_AGE=2
+GLIB_BINARY_AGE=`expr 100 '*' $GLIB_MINOR_VERSION + $GLIB_MICRO_VERSION`
 GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
 ])dnl
 
@@ -48,7 +48,7 @@ AC_SUBST(GLIB_BINARY_AGE)
 
 # libtool versioning
 LT_RELEASE=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION
-LT_CURRENT=`expr $GLIB_MICRO_VERSION - $GLIB_INTERFACE_AGE`
+LT_CURRENT=`expr 100 '*' $GLIB_MINOR_VERSION + $GLIB_MICRO_VERSION - $GLIB_INTERFACE_AGE`
 LT_REVISION=$GLIB_INTERFACE_AGE
 LT_AGE=`expr $GLIB_BINARY_AGE - $GLIB_INTERFACE_AGE`
 LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
@@ -206,10 +206,10 @@ if test x$PKG_CONFIG = xno ; then
   AC_MSG_ERROR([*** pkg-config not found. See http://www.freedesktop.org/software/pkgconfig/])
 fi
 
-if $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
+if $PKG_CONFIG --atleast-pkgconfig-version 0.14 ; then
   :
 else
-  AC_MSG_ERROR([*** pkg-config too old; version 0.5 or better required.])
+  AC_MSG_ERROR([*** pkg-config too old; version 0.14 or better required.])
 fi
 
 if test "x$enable_debug" = "xyes"; then
@@ -222,18 +222,45 @@ if test "x$enable_debug" = "xyes"; then
        
   GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
 else
+  GLIB_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"
+
   if test "x$enable_debug" = "xno"; then
-    GLIB_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
+    GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
   fi
 fi
 
-# Ensure -fnative-struct is used when compiling for Win32
-if test "x$glib_native_win32" = "xyes"; then
-  if test "x$GCC" = "xyes"; then
-    case " $CFLAGS " in
-    *[[\ \     ]]-fnative-struct[[\ \  ]]*) ;;
-    *) CFLAGS="$CFLAGS -fnative-struct" ;;
+# Ensure MSVC-compatible struct packing convention is used when
+# compiling for Win32 with gcc.
+# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
+# gcc2 uses "-fnative-struct".
+if test x"$glib_native_win32" = xyes; then
+  if test x"$GCC" = xyes; then
+    msnative_struct=''
+    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
+    if test -z "$ac_cv_prog_CC"; then
+      our_gcc="$CC"
+    else
+      our_gcc="$ac_cv_prog_CC"
+    fi
+    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
+      2.)
+       if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
+         msnative_struct='-fnative-struct'
+       fi
+       ;;
+      *)
+       if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
+         msnative_struct='-mms-bitfields'
+       fi
+       ;;
     esac
+    if test x"$msnative_struct" = x ; then
+      AC_MSG_RESULT([no way])
+      AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
+    else
+      CFLAGS="$CFLAGS $msnative_struct"
+      AC_MSG_RESULT([${msnative_struct}])
+    fi
   fi
 fi
 
@@ -264,34 +291,86 @@ else
 fi
 AC_SUBST(PERL_PATH)
 
+dnl ***********************
+dnl *** Tests for iconv ***
+dnl ***********************
+dnl
+dnl We do this before the gettext checks, to avoid distortion
+
+AC_ARG_WITH(libiconv, [  --with-libiconv=[no/gnu/native] use the libiconv library ],,with_libiconv=maybe)
+
+found_iconv=no
+case $with_libiconv in
+  maybe)
+    # Check in the C library first
+    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+    # Check if we have GNU libiconv
+    if test $found_iconv = "no"; then
+      AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
+    fi
+    # Check if we have a iconv in -liconv, possibly from vendor
+    if test $found_iconv = "no"; then
+      AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
+    fi
+    ;;
+  no)
+    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+    ;;
+  gnu|yes)
+    AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
+    ;;
+  native)
+    AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
+    ;;
+esac
+
+if test "x$found_iconv" = "xno" ; then
+   AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
+fi
+
 dnl
 dnl gettext support
 dnl
 
-ALL_LINGUAS="az ca cs de el es eu fr gl ja ko ms nl nn no pl pt ro ru sk sl sv ta tr uk vi zh_CN zh_TW"
-AM_GLIB_GNU_GETTEXT
+ALL_LINGUAS="az be bg ca cs da de el es eu fi fr gl hi ja ko ms nl nn no pl pt pt_BR ro ru sk sl sq sv ta tr uk vi zh_CN zh_TW"
+GLIB_GNU_GETTEXT
 
-if test "$gt_cv_func_dgettext_libc" = "yes" || test "$gt_cv_func_dgettext_libintl" = "yes"; then
-  :
-else
+if test "$gt_cv_have_gettext" != "yes" ; then
   AC_MSG_ERROR([
 *** You must have either have gettext support in your C library, or use the 
 *** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
 ])
 fi
 
-LIBS="$LIBS $INTLLIBS"
+LIBS="$INTLLIBS $LIBS"
 
 GETTEXT_PACKAGE=glib20
 AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", 
+  [Define the gettext package to be used])
 
-# AM_GLIB_GNU_GETTEXT above substs $DATADIRNAME
-# this is the directory where the *.{mo,gmo} files are installed
-GLIB_LOCALE_DIR="${prefix}/${DATADIRNAME}/locale"
-AC_DEFINE_UNQUOTED(GLIB_LOCALE_DIR,"$GLIB_LOCALE_DIR")
+GLIB_DEFINE_LOCALEDIR(GLIB_LOCALE_DIR)
 
-AC_CHECK_FUNCS(bind_textdomain_codeset)
+dnl
+dnl Now we are done with gettext checks, figure out ICONV_LIBS
+dnl
+
+if test x$with_libiconv != xno ; then
+  case " $INTLLIBS " in
+  *[[\ \       ]]-liconv[[\ \  ]]*) ;;
+  *) ICONV_LIBS="-liconv" ;;
+  esac
+fi
+AC_SUBST(ICONV_LIBS)
+
+case $with_libiconv in
+  gnu)
+    AC_DEFINE(USE_LIBICONV_GNU, 1, [Using GNU libiconv])
+    ;;
+  native)
+    AC_DEFINE(USE_LIBICONV_NATIVE, 1, [Using a native implementation of iconv in a separate library])
+    ;;
+esac
 
 dnl Initialize libtool
 AM_DISABLE_STATIC
@@ -317,25 +396,29 @@ if test "x$GCC" = "xyes"; then
   fi
 fi
 
+dnl
 dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
-AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
-glib_save_LIBS=$LIBS
-LIBS="$LIBS -lm"
-AC_TRY_RUN([#include <math.h>
-             int main (void) { return (log(1) != log(1.)); }],
-     AC_MSG_RESULT(none needed),
-     glib_save_CFLAGS=$CFLAGS
-     CFLAGS="$CFLAGS -std1"
-     AC_TRY_RUN([#include <math.h>
-                 int main (void) { return (log(1) != log(1.)); }],
-         AC_MSG_RESULT(-std1),
-         AC_MSG_RESULT()
-         CFLAGS=$glib_save_CFLAGS
-         AC_MSG_WARN(
-                [No ANSI prototypes found in library. (-std1 didn't work.)])
-     )
-)
-LIBS=$glib_save_LIBS
+dnl
+if test $cross_compiling != yes ; then
+    AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
+    glib_save_LIBS=$LIBS
+    LIBS="$LIBS -lm"
+    AC_TRY_RUN([#include <math.h>
+                int main (void) { return (log(1) != log(1.)); }],
+        AC_MSG_RESULT(none needed),
+        glib_save_CFLAGS=$CFLAGS
+        CFLAGS="$CFLAGS -std1"
+        AC_TRY_RUN([#include <math.h>
+                    int main (void) { return (log(1) != log(1.)); }],
+            AC_MSG_RESULT(-std1),
+            AC_MSG_RESULT()
+            CFLAGS=$glib_save_CFLAGS
+            AC_MSG_WARN(
+                   [No ANSI prototypes found in library. (-std1 didn't work.)])
+        )
+    )
+    LIBS=$glib_save_LIBS
+fi
 
 dnl NeXTStep cc seems to need this
 AC_MSG_CHECKING([for extra flags for POSIX compliance])
@@ -391,8 +474,9 @@ if test x$ac_cv_sizeof_long_long = x8; then
                          exit (b!=a);
                        }
                        ],
-                       glib_cv_long_long_format=${format}
-                       break)
+                       [glib_cv_long_long_format=${format}
+                       break],
+                       [],[:])
                done])
        if test -n "$glib_cv_long_long_format"; then
          AC_MSG_RESULT(%${glib_cv_long_long_format}u)
@@ -431,7 +515,8 @@ if test "x$GCC" = "xyes"; then
     my_free_p = 0;
     my_realloc_p = 0;
   ],
-    AC_DEFINE(SANE_MALLOC_PROTOS)
+    AC_DEFINE(SANE_MALLOC_PROTOS, 1, 
+      [Define if you have correct malloc prototypes])
     SANE_MALLOC_PROTOS=yes)
 fi
 AC_MSG_RESULT($SANE_MALLOC_PROTOS)
@@ -457,7 +542,7 @@ dnl AC_C_INLINE is useless to us since it bails out too early, we need to
 dnl truely know which ones of `inline', `__inline' and `__inline__' are
 dnl actually supported.
 AC_CACHE_CHECK([for __inline],glib_cv_has__inline,[
-        AC_TRY_RUN([
+        AC_TRY_COMPILE([
        __inline int foo () { return 0; }
        int main () { return foo (); }
                ],
@@ -470,7 +555,7 @@ case x$glib_cv_has__inline in
 xyes) AC_DEFINE(G_HAVE___INLINE,1,[Have __inline keyword])
 esac
 AC_CACHE_CHECK([for __inline__],glib_cv_has__inline__,[
-        AC_TRY_RUN([
+        AC_TRY_COMPILE([
        __inline__ int foo () { return 0; }
        int main () { return foo (); }
                ],
@@ -483,7 +568,7 @@ case x$glib_cv_has__inline__ in
 xyes) AC_DEFINE(G_HAVE___INLINE__,1,[Have __inline__ keyword])
 esac
 AC_CACHE_CHECK([for inline], glib_cv_hasinline,[
-        AC_TRY_RUN([
+        AC_TRY_COMPILE([
        #undef inline
        inline int foo () { return 0; }
        int main () { return foo (); }
@@ -533,7 +618,7 @@ AC_MSG_RESULT($g_have_gnuc_varargs)
 AC_C_BIGENDIAN
 
 # check for header files
-AC_CHECK_HEADERS([dirent.h float.h limits.h pwd.h sys/param.h sys/poll.h sys/select.h])
+AC_CHECK_HEADERS([dirent.h float.h limits.h pwd.h sys/param.h sys/poll.h sys/select.h sys/types.h])
 AC_CHECK_HEADERS([sys/time.h sys/times.h unistd.h values.h stdint.h sched.h])
 
 # Checks for libcharset
@@ -558,30 +643,100 @@ AC_SUBST(STRIP_BEGIN)
 AC_SUBST(STRIP_END)
 
 # check additional type sizes
-size_includes=["
-#include <stdarg.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-"]
-if test "x$ac_cv_header_stdint_h" = "xyes"; then
-  size_includes=["$size_includes
-#include <stdint.h>
-"]
-fi
-if test "x$ac_cv_header_unistd_h" = "xyes"; then
-  size_includes=["$size_includes
-#include <unistd.h>
-"]
+AC_CHECK_SIZEOF(size_t)
+
+dnl Try to figure out whether gsize, gssize should be long or int
+AC_MSG_CHECKING([for the appropriate definition for size_t])
+
+case $ac_cv_sizeof_size_t in
+  $ac_cv_sizeof_short) 
+      glib_size_type=short
+      ;;
+  $ac_cv_sizeof_int) 
+      glib_size_type=int
+      ;;
+  $ac_cv_sizeof_long) 
+      glib_size_type=long
+      ;;
+  *)  AC_MSG_ERROR([No type matching size_t in size])
+      ;;
+esac
+
+dnl If int/long are the same size, we see which one produces
+dnl warnings when used in the location as size_t. (This matters
+dnl on AIX with xlc)
+dnl
+if test $ac_cv_sizeof_size_t = $ac_cv_sizeof_int &&
+   test $ac_cv_sizeof_size_t = $ac_cv_sizeof_long ; then
+  GLIB_CHECK_COMPILE_WARNINGS([
+#include <stddef.h> 
+int main ()
+{
+  size_t s = 1;
+  unsigned int *size_int = &s;
+  return (int)*size_int;
+}
+    ],glib_size_type=int,
+      [GLIB_CHECK_COMPILE_WARNINGS([
+#include <stddef.h> 
+int main ()
+{
+   size_t s = 1;
+   unsigned long *size_long = &s;
+   return (int)*size_long;
+}
+        ],glib_size_type=long)])
 fi
-GLIB_SIZEOF([$size_includes], size_t, size_t)
-GLIB_SIZEOF([$size_includes], ptrdiff_t, ptrdiff_t)
-GLIB_SIZEOF([$size_includes], intmax_t, intmax_t)
+
+AC_MSG_RESULT(unsigned $glib_size_type)
 
 # Check for some functions
-AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv)
+AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv getc_unlocked)
 
 AC_FUNC_VSNPRINTF_C99
+AC_FUNC_PRINTF_UNIX98
+
+#
+# Check whether to use trio printf
+#
+
+AC_ARG_ENABLE(included-printf, [  --enable-included-printf    use included printf [default=auto]], enable_trio="$enableval")
+
+need_trio=no
+if test "x$enable_trio" = "xyes" ; then
+  need_trio=yes
+fi
+if test "$ac_cv_func_vsnprintf_c99" != "yes" ; then
+  need_trio=yes
+fi
+if test "$ac_cv_func_printf_unix98" != "yes" ; then
+  need_trio=yes
+fi
+if test "x$ac_cv_sizeof_long_long" = "x8" &&
+   test -z "$glib_cv_long_long_format" ; then
+  need_trio=yes
+fi
+
+if test "x$enable_trio" = "xno" && 
+   test "x$need_trio" = "xyes" ; then
+  AC_MSG_ERROR([
+*** Your C library's printf doesn't appear to have the features that
+*** GLib needs, but you specified --enable-included-printf=no.])
+fi
+
+enable_trio=$need_trio
+
+AM_CONDITIONAL(HAVE_GOOD_PRINTF, test "$enable_trio" != "yes")
+if test "$enable_trio" != "yes" ; then 
+  AC_DEFINE(HAVE_GOOD_PRINTF,1,[define to use system printf])
+else
+  glib_cv_long_long_format="ll"
+  AC_DEFINE(HAVE_VASPRINTF,1)
+  AC_DEFINE(HAVE_C99_VSNPRINTF,1)
+  AC_DEFINE(HAVE_UNIX98_PRINTF,1)
+  TRIO_LIBS=-lm
+fi
+AC_SUBST(TRIO_LIBS)
 
 # Check if bcopy can be used for overlapping copies, if memmove isn't found.
 # The check is borrowed from the PERL Configure script.
@@ -603,6 +758,8 @@ if test "$ac_cv_func_memmove" != "yes"; then
         }
         return(0);
       }],glib_cv_working_bcopy=yes,glib_cv_working_bcopy=no)])
+
+  GLIB_ASSERT_SET(glib_cv_working_bcopy)
   if test "$glib_cv_working_bcopy" = "yes"; then
     AC_DEFINE(HAVE_WORKING_BCOPY,1,[Have a working bcopy])
   fi
@@ -661,14 +818,13 @@ fi
 
 dnl *** check for sane realloc() ***
 AC_CACHE_CHECK([whether realloc (NULL,) will work],glib_cv_sane_realloc,[
-        AC_TRY_RUN([
-        #include <stdlib.h>
+        AC_TRY_RUN([#include <stdlib.h>
         int main() {
           return realloc (0, sizeof (int)) == 0;
         }],
         [glib_cv_sane_realloc=yes],
         [glib_cv_sane_realloc=no],
-       [])
+       [glib_cv_sane_realloc=yes])
 ])
 if test x$glib_cv_sane_realloc = xyes; then
   AC_DEFINE(REALLOC_0_WORKS,1,[whether realloc (NULL,) works])
@@ -689,15 +845,19 @@ dnl ****************************************
 dnl *** strlcpy/strlcat                  ***
 dnl ****************************************
 # Check for strlcpy
-AC_MSG_CHECKING(for strlcpy/strlcat)
-AC_TRY_LINK([#include <stdlib.h>
-#include <string.h>], [
-char *p = malloc(10);
-(void) strlcpy(p, "hi", 10);
-(void) strlcat(p, "bye", 10);
-], glib_ok=yes, glib_ok=no)
-AC_MSG_RESULT($glib_ok)
-if test "$glib_ok" = "yes"; then
+AC_CACHE_CHECK([for OpenBSD strlcpy/strlcat],glib_cv_have_strlcpy,[
+AC_TRY_RUN([#include <stdlib.h>
+#include <string.h>
+int main() {
+  char p[10];
+  (void) strlcpy (p, "hi", 10);
+  if (strlcat (p, "bye", 0) != 3) 
+    return 1;
+  return 0;
+}], glib_cv_have_strlcpy=yes, 
+    glib_cv_have_strlcpy=no,
+    glib_cv_have_strlcpy=no)])
+if test "$glib_cv_have_strlcpy" = "yes"; then
     AC_DEFINE(HAVE_STRLCPY,1,[Have functions strlcpy and strlcat])
 fi
   
@@ -708,8 +868,7 @@ dnl **********************
 dnl we currently check for all three va_copy possibilities, so we get
 dnl all results in config.log for bug reports.
 AC_CACHE_CHECK([for an implementation of va_copy()],glib_cv_va_copy,[
-       AC_TRY_RUN([
-       #include <stdarg.h>
+       AC_LINK_IFELSE([#include <stdarg.h>
        void f (int i, ...) {
        va_list args1, args2;
        va_start (args1, i);
@@ -723,12 +882,10 @@ AC_CACHE_CHECK([for an implementation of va_copy()],glib_cv_va_copy,[
          return 0;
        }],
        [glib_cv_va_copy=yes],
-       [glib_cv_va_copy=no],
-       [])
+       [glib_cv_va_copy=no])
 ])
 AC_CACHE_CHECK([for an implementation of __va_copy()],glib_cv___va_copy,[
-       AC_TRY_RUN([
-       #include <stdarg.h>
+       AC_LINK_IFELSE([#include <stdarg.h>
        void f (int i, ...) {
        va_list args1, args2;
        va_start (args1, i);
@@ -742,8 +899,7 @@ AC_CACHE_CHECK([for an implementation of __va_copy()],glib_cv___va_copy,[
          return 0;
        }],
        [glib_cv___va_copy=yes],
-       [glib_cv___va_copy=no],
-       [])
+       [glib_cv___va_copy=no])
 ])
 
 if test "x$glib_cv_va_copy" = "xyes"; then
@@ -758,8 +914,7 @@ if test -n "$g_va_copy_func"; then
 fi
 
 AC_CACHE_CHECK([whether va_lists can be copied by value],glib_cv_va_val_copy,[
-       AC_TRY_RUN([
-       #include <stdarg.h>
+       AC_TRY_RUN([#include <stdarg.h>
        void f (int i, ...) {
        va_list args1, args2;
        va_start (args1, i);
@@ -774,7 +929,7 @@ AC_CACHE_CHECK([whether va_lists can be copied by value],glib_cv_va_val_copy,[
        }],
        [glib_cv_va_val_copy=yes],
        [glib_cv_va_val_copy=no],
-       [])
+       [glib_cv_va_val_copy=yes])
 ])
 
 if test "x$glib_cv_va_val_copy" = "xno"; then
@@ -787,7 +942,12 @@ dnl ***********************
 G_MODULE_LIBS=
 G_MODULE_LIBS_EXTRA=
 G_MODULE_PLUGIN_LIBS=
-G_MODULE_LDFLAGS=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
+if test x"$glib_native_win32" = xyes; then
+  dnl No use for this on Win32
+  G_MODULE_LDFLAGS=
+else
+  G_MODULE_LDFLAGS=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
+fi
 dnl G_MODULE_IMPL= don't reset, so cmd-line can override
 G_MODULE_NEED_USCORE=0
 G_MODULE_BROKEN_RTLD_GLOBAL=0
@@ -814,6 +974,13 @@ if test -z "$G_MODULE_IMPL" && test "x$glib_native_beos" = "xyes"; then
       G_MODULE_IMPL=G_MODULE_IMPL_BEOS],
       [])
 fi   
+dnl *** NSLinkModule (dyld) in system libraries (Darwin)
+if test -z "$G_MODULE_IMPL"; then
+       AC_CHECK_FUNC(NSLinkModule,
+                     [G_MODULE_IMPL=G_MODULE_IMPL_DYLD
+                      G_MODULE_NEED_USCORE=1],
+                     [])
+fi
 dnl *** dlopen() and dlsym() in libdl
 if test -z "$G_MODULE_IMPL"; then
        AC_CHECK_LIB(dl, dlopen,
@@ -822,13 +989,6 @@ if test -z "$G_MODULE_IMPL"; then
                                   G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
                     [])
 fi
-dnl *** NSLinkModule (dyld) in system libraries (Darwin)
-if test -z "$G_MODULE_IMPL"; then
-       AC_CHECK_FUNC(NSLinkModule,
-                     [G_MODULE_IMPL=G_MODULE_IMPL_DYLD
-                      G_MODULE_NEED_USCORE=1],
-                     [])
-fi
 dnl *** shl_load() in libdld (HP-UX)
 if test -z "$G_MODULE_IMPL"; then
        AC_CHECK_LIB(dld, shl_load,
@@ -840,31 +1000,31 @@ dnl *** additional checks for G_MODULE_IMPL_DL
 if test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL"; then
        LIBS_orig="$LIBS"
        LDFLAGS_orig="$LDFLAGS"
-       LIBS="$LIBS $G_MODULE_LIBS"
+       LIBS="$G_MODULE_LIBS $LIBS"
        LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
 dnl *** check for OSF1/5.0 RTLD_GLOBAL brokenness
        AC_CACHE_CHECK([for RTLD_GLOBAL brokenness],
                glib_cv_rtldglobal_broken,[
                AC_TRY_RUN([
-               #include <dlfcn.h>
-                #ifndef RTLD_GLOBAL
-                #define RTLD_GLOBAL 0
-                #endif
-                #ifndef RTLD_LAZY
-                #define RTLD_LAZY 0
-                #endif
-               int pthread_create;
-               int main () {
-               void *handle, *global, *local;
-               global = &pthread_create;
-               handle = dlopen ("libpthread.so", RTLD_GLOBAL | RTLD_LAZY);
-               if (!handle) return 0;
-               local = dlsym (handle, "pthread_create");
-               return global == local;
-               }],
+#include <dlfcn.h>
+#ifndef RTLD_GLOBAL
+#  define RTLD_GLOBAL 0
+#endif
+#ifndef RTLD_LAZY
+#  define RTLD_LAZY 0
+#endif
+int pthread_create;
+int main () {
+    void *handle, *global, *local;
+    global = &pthread_create;
+    handle = dlopen ("libpthread.so", RTLD_GLOBAL | RTLD_LAZY);
+    if (!handle) return 0;
+    local = dlsym (handle, "pthread_create");
+    return global == local;
+}                       ],
                        [glib_cv_rtldglobal_broken=no],
                        [glib_cv_rtldglobal_broken=yes],
-                       [])
+                       [glib_cv_rtldglobal_broken=no])
                rm -f plugin.c plugin.o plugin.lo
        ])
        if test "x$glib_cv_rtldglobal_broken" = "xyes"; then
@@ -875,8 +1035,7 @@ dnl *** check for OSF1/5.0 RTLD_GLOBAL brokenness
 dnl *** check whether we need preceeding underscores
        AC_CACHE_CHECK([for preceeding underscore in symbols],
                glib_cv_uscore,[
-               AC_TRY_RUN([
-               #include <dlfcn.h>
+               AC_TRY_RUN([#include <dlfcn.h>
                 int glib_underscore_test (void) { return 42; }
                int main() {
                  void *f1 = (void*)0, *f2 = (void*)0, *handle;
@@ -891,6 +1050,7 @@ dnl *** check whether we need preceeding underscores
                        [])
                rm -f plugin.c plugin.$ac_objext plugin.lo
        ])
+        GLIB_ASSERT_SET(glib_cv_uscore)
        if test "x$glib_cv_uscore" = "xyes"; then
                G_MODULE_NEED_USCORE=1
        else
@@ -1060,6 +1220,12 @@ POSIX_NO_PRIORITIES="I can not find the minimal and maximal priorities for
                priority. If you happen to know these main/max
                priorities, please inform the GLib developers."
 
+AIX_COMPILE_INFO="AIX's C compiler needs to be called by a different name, when
+               linking threaded applications. As GLib cannot do that 
+               automatically, you will get an linkg error everytime you are 
+               not using the right compiler. In that case you have to relink 
+               with the right compiler. Ususally just '_r' is appended 
+               to the compiler name."
 
 dnl determination of thread implementation
 dnl ***************************************
@@ -1084,12 +1250,13 @@ if test "x$want_threads" = xyes || test "x$want_threads" = xposix \
        CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
         if test "x$have_threads" = xno; then
                 AC_TRY_COMPILE([#include <pthread.h>],
-                       [pthread_attr_t attr; pthread_attr_init(&attr);],
+                       [pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;],
                        have_threads=posix)
         fi
         if test "x$have_threads" = xno; then
                 AC_TRY_COMPILE([#include <pthread.h>],
-                       [pthread_attr_t attr; pthread_attr_create(&attr);],
+                       [pthread_mutex_t m; 
+                         pthread_mutex_init (&m, pthread_mutexattr_default);],
                        have_threads=dce)
         fi
        CPPFLAGS="$glib_save_CPPFLAGS"
@@ -1122,39 +1289,110 @@ G_THREAD_LIBS=
 G_THREAD_LIBS_EXTRA=
 G_THREAD_CFLAGS=
 
+dnl
+dnl Test program for basic POSIX threads functionality
+dnl
+m4_define([glib_thread_test],[
+#include <pthread.h> 
+int check_me = 0;
+void* func(void* data) {return check_me = 42;}
+main()
+ { pthread_t t; 
+   void *ret;
+   pthread_create (&t, 0, func, 0);
+   pthread_join (t, &ret);
+   exit (check_me != 42 || ret != 42);
+}])
+
+dnl
+dnl Test program for sched_get_priority_min()
+dnl
+m4_define([glib_sched_priority_test],[
+#include <sched.h>
+#include <errno.h>
+int main() {
+    errno = 0;
+    return sched_get_priority_min(SCHED_OTHER)==-1
+          && errno != 0;
+}])
+
 if test x"$have_threads" != xno; then
 
-    G_THREAD_CFLAGS="-D_REENTRANT" # good default guess
+  if test x"$have_threads" = xposix; then
+    # First we test for posix, whether -pthread or -pthreads do the trick as 
+    # both CPPFLAG and LIBS. 
+    # One of them does for most gcc versions and some other platforms/compilers
+    # too and could be considered as the canonical way to go. 
+    for flag in pthread pthreads; do
+      glib_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -$flag"
+      AC_TRY_RUN(glib_thread_test,
+                 glib_flag_works=yes,
+                 glib_flag_works=no,
+                 [AC_LINK_IFELSE(glib_thread_test,
+                                 glib_flag_works=yes,
+                                 glib_flag_works=no)])
+      CFLAGS="$glib_save_CFLAGS"
+      if test $glib_flag_works = yes ; then
+         G_THREAD_CFLAGS=-$flag
+        G_THREAD_LIBS=-$flag
+      fi
+    done
+  fi
+
+  if test x"$G_THREAD_CFLAGS" = x; then
+
+    # The canonical -pthread[s] does not work. Try something different.
 
     case $host in
        *-aix*)
-               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
                if test x"$GCC" = xyes; then
-                       # GCC 3.0 and above needs -pthread
+                       # GCC 3.0 and above needs -pthread. 
+                       # Should be coverd by the case above.
                        # GCC 2.x and below needs -mthreads
-                       AC_TRY_COMPILE(,[#if __GNUC__ <= 2
-                                       bail out here
-                                       #endif],
-                               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -pthread", 
-                               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -mthreads")
+                       G_THREAD_CFLAGS="-mthreads"             
+                       G_THREAD_LIBS=$G_THREAD_CFLAGS
+               else 
+                       # We are probably using the aix compiler. Normaly a 
+                       # program would have to be compiled with the _r variant
+                       # of the corresponding compiler, but we as GLib cannot 
+                       # do that: but the good news is that for compiling the
+                       # only difference is the added -D_THREAD_SAFE compile 
+                       # option. This is according to the "C for AIX User's 
+                       # Guide".
+                       G_THREAD_CFLAGS="-D_THREAD_SAFE"
                fi
                ;;
-       *-freebsd2.2*)
-               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
-
-               # FreeBSD 2.2.x shiped with gcc 2.7.2.x, which doesn't support
-               # -mthreads flag.
-               ;;      
-       *-sysv5uw7*)  # UnixWare 7 
-               if test "$GCC" != "yes"; then
-                               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -Kthread"
-               else    
-                       G_THREAD_CFLAGS="$G_THREAD_CFLAGS -pthread"
-               fi      
-               ;;
        *-dg-dgux*)  # DG/UX
-               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
+               G_THREAD_CFLAGS="-D_REENTRANT -D_POSIX4A_DRAFT10_SOURCE"
+               ;;
+       *-osf*)
+               # So we are using dce threads. posix threads are already 
+               # catched above.
+               G_THREAD_CFLAGS="-threads"
+               G_THREAD_LIBS=$G_THREAD_CFLAGS
+               ;;
+       *-solaris*)
+               if test x"$GCC" = xyes; then
+                  # We are using solaris threads. posix threads are 
+                  # already catched above.
+                       G_THREAD_CFLAGS="-threads"
+               else
+                       G_THREAD_CFLAGS="-mt"
+               fi
+               G_THREAD_LIBS=$G_THREAD_CFLAGS
+               ;;
+       *-sysv5uw7*) # UnixWare 7 
+               # We are not using gcc with -pthread. Catched above.
+               G_THREAD_CFLAGS="-Kthread"
+               G_THREAD_LIBS=$G_THREAD_CFLAGS
+               ;;
+       *)
+               G_THREAD_CFLAGS="-D_REENTRANT" # good default guess otherwise
+               ;;
     esac
+  fi
 
     # if we are not finding the localtime_r function, then we probably are
     # not using the proper multithread flag
@@ -1177,7 +1415,7 @@ if test x"$have_threads" != xno; then
 
     AC_MSG_CHECKING(thread related cflags)
     AC_MSG_RESULT($G_THREAD_CFLAGS)
-    CFLAGS="$CFLAGS $G_THREAD_CFLAGS"
+    CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
 fi
 
 dnl determination of G_THREAD_LIBS
@@ -1186,25 +1424,19 @@ dnl ******************************
 mutex_has_default=no
 case $have_threads in
         posix|dce)
-          glib_save_CPPFLAGS="$CPPFLAGS"
-          CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
-           G_THREAD_LIBS=error
-          glib_save_LIBS="$LIBS"
-          case $host in
-            *-sysv5uw7*) # UnixWare 7 
-               if test "$GCC" != "yes"; then
-                               G_THREAD_LIBS="-Kthread"
-               else    
-                       G_THREAD_LIBS="-pthread"
-               fi      
-               ;;
-            *-*-openbsd* | *-*-freebsd*) 
-               # FreeBSD and OpenBSD want us to use the -pthread flag 
-                # instead of linking to -lc_r and libtool enforces that.
-               G_THREAD_LIBS="-pthread"
-               ;;
-             *)
-               for thread_lib in "" pthread pthread32 pthreads thread dce; do
+         glib_save_CPPFLAGS="$CPPFLAGS"
+         CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
+          if test x"$G_THREAD_LIBS" = x; then
+            case $host in
+              *-aix*)
+                # We are not using gcc (would have set G_THREAD_LIBS) and thus 
+                # probably using the aix compiler.
+               AC_MSG_WARN($AIX_COMPILE_INFO)
+                ;;
+              *)
+                G_THREAD_LIBS=error
+               glib_save_LIBS="$LIBS"
+               for thread_lib in "" pthread pthread32 pthreads thread dce; do
                        if test x"$thread_lib" = x; then
                                add_thread_lib=""
                                IN=""
@@ -1218,70 +1450,72 @@ case $have_threads in
                                defattr=pthread_attr_default
                        fi
                        
-                       LIBS="$glib_save_LIBS $add_thread_lib"
+                       LIBS="$add_thread_lib $glib_save_LIBS"
                        
                        AC_MSG_CHECKING(for pthread_create/pthread_join$IN)
-                       AC_TRY_RUN([#include <pthread.h> 
-                               int check_me = 0;
-                               void* func(void* data) {check_me = 42;}
-                                main()
-                               { pthread_t t; 
-                                 void *ret;
-                                 pthread_create (&t, $defattr, func, 0);
-                                 pthread_join (t, &ret);
-                                 exit (check_me != 42);
-                               }],
-                               [AC_MSG_RESULT(yes)
-                               G_THREAD_LIBS="$add_thread_lib"
-                               break],
-                               [AC_MSG_RESULT(no)])
+                       AC_TRY_RUN(glib_thread_test,
+                                   glib_result=yes,
+                                   glib_result=no,
+                                   [AC_LINK_IFELSE(glib_thread_test,
+                                                   glib_result=yes,
+                                                   glib_result=no)])
+                        AC_MSG_RESULT($glib_result)
+                       
+                        if test "$glib_result" = "yes" ; then
+                         G_THREAD_LIBS="$add_thread_lib"
+                          break
+                        fi
                done
+               if test "x$G_THREAD_LIBS" = xerror; then
+                 AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
+               fi 
+               LIBS="$glib_save_LIBS"
                 ;;
-          esac         
-          if test "x$G_THREAD_LIBS" = xerror; then
-             AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
-          fi
-          for thread_lib in "" rt rte; do
-            if test x"$thread_lib" = x; then
-              add_thread_lib=""
-              IN=""
-            else
-              add_thread_lib="-l$thread_lib"
-              IN=" in -l$thread_lib"
-            fi
-            LIBS="$glib_save_LIBS $add_thread_lib"
-                       
-            AC_MSG_CHECKING(for sched_get_priority_min$IN)
-            AC_TRY_RUN([#include <sched.h>
-                        #include <errno.h>
-                        int main() {
-                        errno = 0;
-                         return sched_get_priority_min(SCHED_OTHER)==-1
-                               && errno != 0;}],
-                       [AC_MSG_RESULT(yes)
-                        G_THREAD_LIBS="$G_THREAD_LIBS $add_thread_lib"
-                        posix_priority_min="sched_get_priority_min(SCHED_OTHER)"
-                        posix_priority_max="sched_get_priority_max(SCHED_OTHER)"
-                        break],
-                       [AC_MSG_RESULT(no)])
-          done
-          LIBS="$glib_save_LIBS"
-           mutex_has_default=yes
-           mutex_default_type='pthread_mutex_t'
-           mutex_default_init='PTHREAD_MUTEX_INITIALIZER'
-           mutex_header_file='pthread.h'
-          if test "x$have_threads" = "xposix"; then
-            g_threads_impl="POSIX"
-          else
-            g_threads_impl="DCE"
-            have_threads="posix"
-          fi
-          AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES)
-           CPPFLAGS="$glib_save_CPPFLAGS"
-           ;;
+            esac
+          fi
+
+          glib_save_LIBS="$LIBS"
+         for thread_lib in "" rt rte; do
+           if test x"$thread_lib" = x; then
+             add_thread_lib=""
+             IN=""
+           else
+             add_thread_lib="-l$thread_lib"
+             IN=" in -l$thread_lib"
+           fi
+           LIBS="$add_thread_lib $glib_save_LIBS"
+           
+            AC_MSG_CHECKING(for sched_get_priority_min$IN)
+           AC_TRY_RUN(glib_sched_priority_test,
+                       glib_result=yes,
+                       glib_result=no,
+                       [AC_LINK_IFELSE(glib_sched_priority_test,
+                                       glib_result=yes,
+                                       glib_result=no)])
+           AC_MSG_RESULT($glib_result)
+
+           if test "$glib_result" = "yes" ; then           
+              G_THREAD_LIBS="$G_THREAD_LIBS $add_thread_lib"
+              posix_priority_min="sched_get_priority_min(SCHED_OTHER)"
+              posix_priority_max="sched_get_priority_max(SCHED_OTHER)"
+              break
+            fi
+         done
+         LIBS="$glib_save_LIBS"
+          mutex_has_default=yes
+          mutex_default_type='pthread_mutex_t'
+          mutex_default_init='PTHREAD_MUTEX_INITIALIZER'
+          mutex_header_file='pthread.h'
+         if test "x$have_threads" = "xposix"; then
+           g_threads_impl="POSIX"
+         else
+           g_threads_impl="DCE"
+           have_threads="posix"
+         fi
+         AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES)
+          CPPFLAGS="$glib_save_CPPFLAGS"
+          ;;
         solaris)
-          G_THREAD_LIBS=error
-           AC_CHECK_LIB(thread, cond_init, G_THREAD_LIBS="-lthread")
            mutex_has_default=yes
            mutex_default_type='mutex_t'
           mutex_default_init="DEFAULTMUTEX"
@@ -1290,7 +1524,6 @@ case $have_threads in
            ;;
        win32)
           g_threads_impl="WIN32"
-          G_THREAD_LIBS=""
           ;;
         none|no)
           g_threads_impl="NONE"
@@ -1329,18 +1562,22 @@ if test x"$have_threads" != xno; then
        if test "$ac_cv_header_pwd_h" = "yes"; then
                AC_CACHE_CHECK([for posix getpwuid_r],
                        ac_cv_func_posix_getpwuid_r,
-                       [AC_TRY_RUN([#include <errno.h>
-                                #include <pwd.h>
-                                int main () { char buffer[10000];
-                                struct passwd pwd, *pwptr = &pwd;
-                                int error;
-                                errno = 0;
-                                error = getpwuid_r (0, &pwd, buffer, 
-                                        sizeof (buffer), &pwptr);
-                                return (error < 0 && errno == ENOSYS) 
-                                       || error == ENOSYS; }],
+                       [AC_TRY_RUN([
+#include <errno.h>
+#include <pwd.h>
+int main () { 
+    char buffer[10000];
+    struct passwd pwd, *pwptr = &pwd;
+    int error;
+    errno = 0;
+    error = getpwuid_r (0, &pwd, buffer, 
+                        sizeof (buffer), &pwptr);
+   return (error < 0 && errno == ENOSYS) 
+          || error == ENOSYS; 
+}                               ],
                                [ac_cv_func_posix_getpwuid_r=yes],
                                [ac_cv_func_posix_getpwuid_r=no])])
+               GLIB_ASSERT_SET(ac_cv_func_posix_getpwuid_r)
                if test "$ac_cv_func_posix_getpwuid_r" = yes; then
                        AC_DEFINE(HAVE_POSIX_GETPWUID_R,1,
                                [Have POSIX function getpwuid_r])
@@ -1354,13 +1591,14 @@ if test x"$have_threads" != xno; then
                                                        sizeof (buffer));],
                                        [ac_cv_func_nonposix_getpwuid_r=yes],
                                        [ac_cv_func_nonposix_getpwuid_r=no])])
+                       GLIB_ASSERT_SET(ac_cv_func_nonposix_getpwuid_r)
                        if test "$ac_cv_func_nonposix_getpwuid_r" = yes; then
                                AC_DEFINE(HAVE_NONPOSIX_GETPWUID_R,1,
                                        [Have non-POSIX function getpwuid_r])
                        fi
                fi
        fi
-       LIBS="$LIBS $G_THREAD_LIBS"
+       LIBS="$G_THREAD_LIBS $LIBS"
        if test x"$have_threads" = xposix; then
                glib_save_CPPFLAGS="$CPPFLAGS"
                CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
@@ -1376,13 +1614,20 @@ if test x"$have_threads" != xno; then
                                  [Have function pthread_attr_setstacksize])],
                        [AC_MSG_RESULT(no)])
                AC_MSG_CHECKING(for minimal/maximal thread priority)
-               if test x"$posix_priority_min" = xnone; then
+               if test x"$posix_priority_min" = x; then
                        AC_EGREP_CPP(PX_PRIO_MIN,[#include <pthread.h>
                                PX_PRIO_MIN],,[
                                posix_priority_min=PX_PRIO_MIN
                                posix_priority_max=PX_PRIO_MAX])
                fi
-               if test x"$posix_priority_min" = xnone; then
+               if test x"$posix_priority_min" = x; then
+                       # AIX
+                       AC_EGREP_CPP(PTHREAD_PRIO_MIN,[#include <pthread.h>
+                               PTHREAD_PRIO_MIN],,[
+                               posix_priority_min=PTHREAD_PRIO_MIN
+                               posix_priority_max=PTHREAD_PRIO_MAX])
+               fi
+               if test x"$posix_priority_min" = x; then
                        AC_EGREP_CPP(PRI_OTHER_MIN,[#include <pthread.h>
                                PRI_OTHER_MIN],,[
                                posix_priority_min=PRI_OTHER_MIN        
@@ -1418,25 +1663,32 @@ if test x"$have_threads" != xno; then
                AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func,[The POSIX RT yield function])
                CPPFLAGS="$glib_save_CPPFLAGS"
 
-               AC_MSG_CHECKING(whether to use the PID niceness surrogate for thread priorities)
-               AC_TRY_RUN([#include <pthread.h> 
-                       #include <sys/types.h>
-                       #include <unistd.h>
-                       pid_t other_pid = 0;
-
-                       void* func(void* data) {other_pid = getpid();}
-                       main()
-                       { pthread_t t; 
-                         void *ret;
-                         pthread_create (&t, $defattr, func, NULL);
-                         pthread_join (t, &ret);
-                         exit (getpid()==other_pid || 
-                               $posix_priority_min != $posix_priority_max);
-                       }],
-                       [AC_MSG_RESULT(yes)
-                         AC_DEFINE(G_THREAD_USE_PID_SURROGATE, 1, [whether to use the PID niceness surrogate for thread priorities])
-                        ],
-                       [AC_MSG_RESULT(no)])
+               AC_CACHE_CHECK([whether to use the PID niceness surrogate for thread priorities], 
+                               glib_cv_use_pid_surrogate, 
+                 [AC_TRY_RUN([
+#include <pthread.h> 
+#include <sys/types.h>
+#include <unistd.h>
+pid_t other_pid = 0;
+
+void* func(void* data) {other_pid = getpid();}
+main()
+{ pthread_t t; 
+  void *ret;
+  pthread_create (&t, 0, func, NULL);
+  pthread_join (t, &ret);
+  exit (getpid()==other_pid || 
+       $posix_priority_min != $posix_priority_max);
+}               ],
+               [glib_cv_use_pid_surrogate=yes],
+                [glib_cv_use_pid_surrogate=no],
+                [])])
+         GLIB_ASSERT_SET(glib_cv_use_pid_surrogate)
+          if test "$glib_cv_use_pid_surrogate" = "yes" ; then
+           AC_DEFINE(G_THREAD_USE_PID_SURROGATE, 1, 
+                      [whether to use the PID niceness surrogate for thread priorities])
+          fi
+           
        elif test x"$have_threads" = xwin32; then
                # It's a pointer to a private struct
                GLIB_SIZEOF(,struct _GThreadData *, system_thread)
@@ -1461,10 +1713,27 @@ if test x"$glib_cv_sizeof_system_thread" = x; then
    GLIB_SIZEOF(,void *, system_thread)
 fi
 
+#
+# Hack to deal with:
+# 
+#  a) GCC < 3.3 for Linux doesn't include -lpthread when
+#     building shared libraries with linux.
+#  b) libtool doesn't recognize -pthread as a library dependency.
+#
+case $host in
+  *-*-linux*)
+    G_THREAD_LIBS_FOR_GTHREAD="`echo $G_THREAD_LIBS | sed s/-pthread/-lpthread/`"
+    ;;
+  *)
+    G_THREAD_LIBS_FOR_GTHREAD="`echo $G_THREAD_LIBS | sed s/-pthread/-Wc,-pthread/`"
+    ;;
+esac
+
 AC_DEFINE_UNQUOTED(G_THREAD_SOURCE,"gthread-$have_threads.c",
                   [Source file containing theread implementation])
 AC_SUBST(G_THREAD_CFLAGS)
 AC_SUBST(G_THREAD_LIBS)
+AC_SUBST(G_THREAD_LIBS_FOR_GTHREAD)
 AC_SUBST(G_THREAD_LIBS_EXTRA)
 
 dnl **********************************************
@@ -1473,15 +1742,14 @@ dnl **********************************************
 dnl
 dnl if mutex_has_default = yes, we also got
 dnl mutex_default_type, mutex_default_init and mutex_header_file
-GLIB_IF_VAR_EQ(mutex_has_default, yes,
+if test $mutex_has_default = yes ; then
        glib_save_CPPFLAGS="$CPPFLAGS"
        glib_save_LIBS="$LIBS"
-       LIBS="$LIBS $G_THREAD_LIBS"
+       LIBS="$G_THREAD_LIBS $LIBS"
        CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
        GLIB_SIZEOF([#include <$mutex_header_file>],
                     $mutex_default_type,
-                    gmutex,
-                    )
+                    gmutex)
        GLIB_BYTE_CONTENTS([#include <$mutex_header_file>],
                           $mutex_default_type,
                           gmutex,
@@ -1492,19 +1760,37 @@ GLIB_IF_VAR_EQ(mutex_has_default, yes,
        fi
        CPPFLAGS="$glib_save_CPPFLAGS"
        LIBS="$glib_save_LIBS"
-       ,
-)
-
+fi
 
 dnl ****************************************
 dnl *** GLib POLL* compatibility defines ***
 dnl ****************************************
-GLIB_SYSDEFS(
-[#include <sys/types.h>
-#include <sys/poll.h>],
-       POLLIN:1 POLLOUT:4 POLLPRI:2 POLLERR:8 POLLHUP:16 POLLNVAL:32,
-       glibconfig-sysdefs.h,
-       =)
+
+glib_poll_includes=["
+#include <sys/types.h>
+#include <sys/poll.h>
+"]
+
+if test $ac_cv_header_sys_types_h = yes &&
+   test $ac_cv_header_sys_poll_h = yes ; then
+  glib_failed=false
+  GLIB_CHECK_VALUE(POLLIN, $glib_poll_includes, glib_failed=true)
+  GLIB_CHECK_VALUE(POLLOUT, $glib_poll_includes, glib_failed=true)
+  GLIB_CHECK_VALUE(POLLPRI, $glib_poll_includes, glib_failed=true)
+  GLIB_CHECK_VALUE(POLLERR, $glib_poll_includes, glib_failed=true)
+  GLIB_CHECK_VALUE(POLLHUP, $glib_poll_includes, glib_failed=true)
+  GLIB_CHECK_VALUE(POLLNVAL, $glib_poll_includes, glib_failed=true)
+  if $glib_failed ; then
+    AC_MSG_ERROR([Could not determine values for POLL* constants])
+  fi
+else
+  glib_cv_value_POLLIN=1
+  glib_cv_value_POLLOUT=4
+  glib_cv_value_POLLPRI=2
+  glib_cv_value_POLLERR=8
+  glib_cv_value_POLLHUP=16
+  glib_cv_value_POLLNVAL=32
+fi
 
 dnl **********************
 dnl *** Win32 API libs ***
@@ -1512,7 +1798,7 @@ dnl **********************
 
 case $host in
   *-*-cygwin*)
-       G_LIBS_EXTRA="-luser32 -lwsock32 -lkernel32"
+       G_LIBS_EXTRA="-luser32 -lkernel32"
     ;;
   *-*-mingw*)
        G_LIBS_EXTRA="-lwsock32"
@@ -1523,53 +1809,6 @@ case $host in
 esac
 AC_SUBST(G_LIBS_EXTRA)
 
-dnl ***********************
-dnl *** Tests for iconv ***
-dnl ***********************
-
-AC_ARG_WITH(libiconv, [  --with-libiconv=[no/gnu/native] use the libiconv library ],,with_libiconv=maybe)
-
-found_iconv=no
-case $with_libiconv in
-  maybe)
-    # Check in the C library first
-    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
-    # Check if we have GNU libiconv
-    if test $found_iconv = "no"; then
-      AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
-    fi
-    # Check if we have a iconv in -liconv, possibly from vendor
-    if test $found_iconv = "no"; then
-      AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
-    fi
-    ;;
-  no)
-    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
-    ;;
-  gnu|yes)
-    AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
-    ;;
-  native)
-    AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
-    ;;
-esac
-
-if test "x$found_iconv" = "xno" ; then
-   AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
-fi
-
-case $with_libiconv in
-  gnu)
-    ICONV_LIBS="-liconv"
-    AC_DEFINE(USE_LIBICONV_GNU, [Using GNU libiconv])
-    ;;
-  native)
-    ICONV_LIBS="-liconv"
-    AC_DEFINE(USE_LIBICONV_NATIVE, [Using a native implementation of iconv in a separate library])
-    ;;
-esac
-AC_SUBST(ICONV_LIBS)
-
 dnl If the system doesn't define EILSEQ, we should define EILSEQ ourselves
 dnl since we need it for g_iconv()
 
@@ -1582,6 +1821,19 @@ int error = EILSEQ;
 ], have_eilseq=yes, have_eilseq=no);
 AC_MSG_RESULT($have_eilseq)
 
+dnl ******************************************************************
+dnl *** Look for glib-genmarshal in PATH if we are cross-compiling ***
+dnl ******************************************************************
+
+AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
+
+if test $cross_compiling = yes; then
+  AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal, no)
+  if test x$GLIB_GENMARSHAL = xno; then
+    AC_MSG_ERROR(Could not find a glib-genmarshal in your PATH)
+  fi
+fi
+
 dnl **************************
 dnl *** Checks for gtk-doc ***
 dnl **************************
@@ -1598,19 +1850,29 @@ AC_SUBST(HTML_DIR)
 
 AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
 
-gtk_doc_min_version=0.6
-if $GTKDOC ; then 
+AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
+
+gtk_doc_min_version=0.10
+if $GTKDOC ; then
     gtk_doc_version=`gtkdoc-mkdb --version`
     AC_MSG_CHECKING([gtk-doc version ($gtk_doc_version) >= $gtk_doc_min_version])
-    if perl <<EOF ; then
-      exit (("$gtk_doc_version" =~ /^[[0-9]]+\.[[0-9]]+$/) &&
-            ("$gtk_doc_version" >= "$gtk_doc_min_version") ? 0 : 1);
-EOF
+
+    IFS="${IFS=        }"; gtk_save_IFS="$IFS"; IFS="."
+    set $gtk_doc_version
+    for min in $gtk_doc_min_version ; do
+        cur=$1; shift
+        if test -z $min ; then break; fi
+        if test -z $cur ; then GTKDOC=false; break; fi
+        if test $cur -gt $min ; then break ; fi
+        if test $cur -lt $min ; then GTKDOC=false; break ; fi
+    done
+    IFS="$gtk_save_IFS"
+
+    if $GTKDOC ; then
       AC_MSG_RESULT(yes)
-   else
+    else
       AC_MSG_RESULT(no)
-      GTKDOC=false
-   fi
+    fi
 fi
 
 AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
@@ -1767,19 +2029,8 @@ _______EOF
 
 _______EOF
 
-       case x$glib_size_t in
-        x2) echo "typedef gint16  gssize;" >> $outfile
-            echo "typedef guint16 gsize;"  >> $outfile
-            ;;
-        x4) echo "typedef gint32  gssize;" >> $outfile
-            echo "typedef guint32 gsize;"  >> $outfile
-            ;;
-        x8) echo "typedef gint64  gssize;" >> $outfile
-            echo "typedef guint64 gsize;"  >> $outfile
-            ;;
-       *)  echo "#error size of size_t is unknown" >> $outfile
-            ;;
-        esac
+echo "typedef signed $glib_size_type_define gssize;" >> $outfile
+echo "typedef unsigned $glib_size_type_define gsize;" >> $outfile
 
        if test -z "$glib_unknown_void_p"; then
          cat >>$outfile <<_______EOF
@@ -1929,13 +2180,12 @@ _______EOF
 #define GUINT_TO_BE(val)       ((guint) GUINT${gintbits}_TO_BE (val))
 #define G_BYTE_ORDER $g_byte_order
 
-_______EOF
-
-       if test -r glibconfig-sysdefs.h; then
-         cat glibconfig-sysdefs.h >>$outfile
-       fi
-
-       cat >>$outfile <<_______EOF
+#define GLIB_SYSDEF_POLLIN =$g_pollin
+#define GLIB_SYSDEF_POLLOUT =$g_pollout
+#define GLIB_SYSDEF_POLLPRI =$g_pollpri
+#define GLIB_SYSDEF_POLLHUP =$g_pollhup
+#define GLIB_SYSDEF_POLLERR =$g_pollerr
+#define GLIB_SYSDEF_POLLNVAL =$g_pollnval
 
 #define G_MODULE_SUFFIX "$g_module_suffix"
 
@@ -2060,7 +2310,8 @@ $ac_cv_sizeof___int64)
   gint64_constant='(val##i64)'
   ;;
 esac
-glib_size_t=$glib_cv_sizeof_size_t
+glib_size_t=$ac_cv_sizeof_size_t
+glib_size_type_define=$glib_size_type
 glib_void_p=$ac_cv_sizeof_long
 glib_long=$ac_cv_sizeof_void_p
 
@@ -2154,6 +2405,13 @@ x$ac_cv_c_bigendian)
   ;;
 esac
 
+g_pollin=$glib_cv_value_POLLIN
+g_pollout=$glib_cv_value_POLLOUT
+g_pollpri=$glib_cv_value_POLLPRI
+g_pollhup=$glib_cv_value_POLLHUP
+g_pollerr=$glib_cv_value_POLLERR
+g_pollnval=$glib_cv_value_POLLNVAL
+
 g_stack_grows=$glib_cv_stack_grows
 
 g_have_eilseq=$have_eilseq
@@ -2209,6 +2467,7 @@ build/win32/Makefile
 build/win32/dirent/Makefile
 glib/Makefile
 glib/libcharset/Makefile
+glib/trio/Makefile
 gmodule/gmoduleconf.h
 gmodule/Makefile
 gobject/Makefile
@@ -2218,7 +2477,13 @@ po/Makefile.in
 docs/Makefile
 docs/reference/Makefile
 docs/reference/glib/Makefile
+docs/reference/glib/version.xml
 docs/reference/gobject/Makefile
+docs/reference/gobject/version.xml
 tests/Makefile
 m4macros/Makefile
+],[
+chmod 0755 glib-zip
+chmod 0755 glib-gettextize
+chmod 0755 gobject/glib-mkenums
 ])