$NetBSD: patch-aa,v 1.46 2009/09/22 15:50:46 joerg Exp $

--- configure.orig	2009-10-07 15:56:34.000000000 +0200
+++ configure
@@ -837,6 +837,7 @@ GIO
 GSPAWN
 GLIB_DEBUG_FLAGS
 G_MODULE_NEED_USCORE
+G_MODULE_BROKEN_DLOPEN_NULL
 G_MODULE_BROKEN_RTLD_GLOBAL
 G_MODULE_HAVE_DLERROR
 G_MODULE_LDFLAGS
@@ -27067,8 +27068,8 @@ cat >>conftest.$ac_ext <<_ACEOF
 			{
 			  long long b, a = -0x3AFAFAFAFAFAFAFALL;
 			  char buffer[1000];
-			  sprintf (buffer, "%${format}u", a);
-  			  sscanf (buffer, "%${format}u", &b);
+			  sprintf (buffer, "%${format}d", a);
+  			  sscanf (buffer, "%${format}d", &b);
 			  exit (b!=a);
 			}
 
@@ -27112,8 +27113,8 @@ fi
 fi
 
 	if test -n "$glib_cv_long_long_format"; then
-	  { $as_echo "$as_me:$LINENO: result: %${glib_cv_long_long_format}u" >&5
-$as_echo "%${glib_cv_long_long_format}u" >&6; }
+	  { $as_echo "$as_me:$LINENO: result: %${glib_cv_long_long_format}d" >&5
+$as_echo "%${glib_cv_long_long_format}d" >&6; }
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_LONG_LONG_FORMAT 1
@@ -27136,8 +27137,8 @@ elif test x$ac_cv_sizeof___int64 = x8; t
 $as_echo_n "checking for format to printf and scanf a guint64... " >&6; }
 	# We know this is MSVCRT.DLL, and what the formats are
 	glib_cv_long_long_format=I64
-	{ $as_echo "$as_me:$LINENO: result: %${glib_cv_long_long_format}u" >&5
-$as_echo "%${glib_cv_long_long_format}u" >&6; }
+	{ $as_echo "$as_me:$LINENO: result: %${glib_cv_long_long_format}d" >&5
+$as_echo "%${glib_cv_long_long_format}d" >&6; }
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_LONG_LONG_FORMAT 1
@@ -34951,13 +34952,13 @@ $as_echo "$ac_cv_func_res_query" >&6; }
 if test "x$ac_cv_func_res_query" = x""yes; then
   :
 else
-  { $as_echo "$as_me:$LINENO: checking for res_query in -lresolv" >&5
-$as_echo_n "checking for res_query in -lresolv... " >&6; }
-if test "${ac_cv_lib_resolv_res_query+set}" = set; then
+  { $as_echo "$as_me:$LINENO: checking for res_query in -lsocket" >&5
+$as_echo_n "checking for res_query in -lsocket... " >&6; }
+if test "${ac_cv_lib_socket_res_query+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv  $LIBS"
+LIBS="-lsocket  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -35001,12 +35002,12 @@ $as_echo "$ac_try_echo") >&5
 	 test "$cross_compiling" = yes ||
 	 $as_test_x conftest$ac_exeext
        }; then
-  ac_cv_lib_resolv_res_query=yes
+  ac_cv_lib_socket_res_query=yes
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_resolv_res_query=no
+	ac_cv_lib_socket_res_query=no
 fi
 
 rm -rf conftest.dSYM
@@ -35014,15 +35015,15 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_query" >&5
-$as_echo "$ac_cv_lib_resolv_res_query" >&6; }
-if test "x$ac_cv_lib_resolv_res_query" = x""yes; then
-   LIBASYNCNS_LIBADD="-lresolv"
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_res_query" >&5
+$as_echo "$ac_cv_lib_socket_res_query" >&6; }
+if test "x$ac_cv_lib_socket_res_query" = x""yes; then
+   LIBASYNCNS_LIBADD="-lsocket"
 else
    save_libs="$LIBS"
-        LIBS="-lresolv $LIBS"
-        { $as_echo "$as_me:$LINENO: checking for res_query in -lresolv (alternate version)" >&5
-$as_echo_n "checking for res_query in -lresolv (alternate version)... " >&6; }
+        LIBS="-lsocket $LIBS"
+        { $as_echo "$as_me:$LINENO: checking for res_query in -lsocket (alternate version)" >&5
+$as_echo_n "checking for res_query in -lsocket (alternate version)... " >&6; }
         cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -35061,7 +35062,7 @@ $as_echo "$ac_try_echo") >&5
        }; then
    { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
-  	  LIBASYNCNS_LIBADD="-lresolv"
+  	  LIBASYNCNS_LIBADD="-lsocket"
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -37114,6 +37115,7 @@ else
 fi
 G_MODULE_NEED_USCORE=0
 G_MODULE_BROKEN_RTLD_GLOBAL=0
+G_MODULE_BROKEN_DLOPEN_NULL=0
 G_MODULE_HAVE_DLERROR=0
 if test -z "$G_MODULE_IMPL"; then
   case "$host" in
@@ -37949,6 +37951,87 @@ fi
 
 	LIBS="$LIBS_orig"
 fi
+	{ $as_echo "$as_me:$LINENO: checking for dlopen(NULL, 0) brokenness" >&5
+$as_echo_n "checking for dlopen(NULL, 0) brokenness... " >&6; }
+if test "${glib_cv_dlopennull_broken+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+
+		if test "$cross_compiling" = yes; then
+  glib_cv_dlopennull_broken=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#include <dlfcn.h>
+#ifndef RTLD_GLOBAL
+#  define RTLD_GLOBAL 0
+#endif
+#ifndef RTLD_LAZY
+#  define RTLD_LAZY 0
+#endif
+int gettext;
+int main () {
+    void *handle;
+    handle = dlopen ("libm.so", RTLD_GLOBAL | RTLD_LAZY);
+    if (!handle) return 0;
+    handle = dlopen (NULL, 0);
+    if (!handle) return 0;
+    handle = dlsym (handle, "sin");
+    return handle == NULL;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  glib_cv_dlopennull_broken=no
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+glib_cv_dlopennull_broken=yes
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $glib_cv_dlopennull_broken" >&5
+$as_echo "$glib_cv_dlopennull_broken" >&6; }
+	if test "x$glib_cv_dlopennull_broken" = "xyes"; then
+		G_MODULE_BROKEN_DLOPEN_NULL=1
+	else
+		G_MODULE_BROKEN_DLOPEN_NULL=0
+	fi
 if test -z "$G_MODULE_IMPL"; then
 	G_MODULE_IMPL=0
         G_MODULE_SUPPORTED=false
@@ -37985,6 +38068,8 @@ fi
 
 
 
+
+
 { $as_echo "$as_me:$LINENO: checking for gspawn implementation" >&5
 $as_echo_n "checking for gspawn implementation... " >&6; }
 case "$host" in
@@ -39832,117 +39917,8 @@ if test x"$have_threads" != xno; then
         G_THREAD_LIBS="-lpthread -lthread"
         ;;
       *)
-        for flag in pthread pthreads mt; do
-          glib_save_CFLAGS="$CFLAGS"
-          CFLAGS="$CFLAGS -$flag"
-          if test "$cross_compiling" = yes; then
-  cat >conftest.$ac_ext <<_ACEOF
-
-#include <pthread.h>
-int check_me = 0;
-void* func(void* data) {check_me = 42; return &check_me;}
-int main()
- { pthread_t t;
-   void *ret;
-   pthread_create (&t, 0, func, 0);
-   pthread_join (t, &ret);
-   return (check_me != 42 || ret != &check_me);
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  glib_flag_works=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	glib_flag_works=no
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-#include <pthread.h>
-int check_me = 0;
-void* func(void* data) {check_me = 42; return &check_me;}
-int main()
- { pthread_t t;
-   void *ret;
-   pthread_create (&t, 0, func, 0);
-   pthread_join (t, &ret);
-   return (check_me != 42 || ret != &check_me);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  glib_flag_works=yes
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-glib_flag_works=no
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-          CFLAGS="$glib_save_CFLAGS"
-          if test $glib_flag_works = yes ; then
-             G_THREAD_CFLAGS=-$flag
-	     G_THREAD_LIBS=-$flag
-	     break;
-          fi
-        done
+	G_THREAD_LIBS="${PTHREAD_LDFLAGS} ${PTHREAD_LIBS}"
+	G_THREAD_CFLAGS="${PTHREAD_CFLAGS}"
          ;;
     esac
   fi
@@ -42136,6 +42112,10 @@ case $host in
   *)
     G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS"
     ;;
+  *-*-netbsd*)
+    # On NetBSD, pkgsrc's libtool does the right thing.
+    G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS"
+    ;;
 esac
