$NetBSD: patch-aa,v 1.62 2018/10/08 10:12:06 prlw1 Exp $

- solaris sun studio check and fix
- use pkgsrc libtool

--- configure.orig	2018-04-07 02:37:11.000000000 +0000
+++ configure
@@ -5512,6 +5513,9 @@ $as_echo_n "checking for Mac OS X Carbon
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+#error too old
+#endif
 #include <Carbon/Carbon.h>
 #include <CoreServices/CoreServices.h>
 
@@ -5530,6 +5534,9 @@ $as_echo_n "checking for Mac OS X Cocoa 
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+#error too old
+#endif
 #include <Cocoa/Cocoa.h>
 #ifdef GNUSTEP_BASE_VERSION
 #error "Detected GNUstep, not Cocoa"
@@ -21597,6 +21604,8 @@ else
 # ifdef _MSC_VER
 #  include <malloc.h>
 #  define alloca _alloca
+# elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
+#   include <stdlib.h>
 # else
 #  ifdef HAVE_ALLOCA_H
 #   include <alloca.h>
@@ -22524,8 +22533,8 @@ else
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether using Sun Studio C compiler" >&5
-$as_echo_n "checking whether using Sun Studio C compiler... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether using Sun Studio C compiler visibility" >&5
+$as_echo_n "checking whether using Sun Studio C compiler visibility... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #if defined(__SUNPRO_C) || (__SUNPRO_C >= 0x550)
@@ -24521,16 +24530,48 @@ fi
 
 case $host in
   *-*-solaris* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether using Sun Studio C compiler with C99" >&5
+$as_echo_n "checking whether using Sun Studio C compiler with C99... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if defined(__STDC_VERSION__) || (__STDC_VERSION__ - 0 >= 199901L)
+#else
+# include "error: this is STD C99."
+#endif
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   g_have_sunstudio_c99=yes
+else
+   g_have_sunstudio_c99=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $g_have_sunstudio_c99" >&5
+$as_echo "$g_have_sunstudio_c99" >&6; }
+    if test $g_have_sunstudio_c99 = yes; then
+
+$as_echo "#define _XOPEN_SOURCE 600" >>confdefs.h
+
+    else
 
 $as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h
 
 
 $as_echo "#define _XOPEN_SOURCE 2" >>confdefs.h
 
+    fi
+
 
 $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h
 
-     ;;
+    ;;
 esac
 
 if test "$ac_cv_func_statfs" = yes; then :
@@ -25817,9 +25859,9 @@ if  test "$G_MODULE_IMPL" = "G_MODULE_IM
 	LIBS="$G_MODULE_LIBS $LIBS"
 	LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
 	echo "void glib_plugin_test(void) { }" > plugin.c
-	${SHELL} ./libtool --mode=compile --tag=CC ${CC} ${CFLAGS} \
+	${SHELL} libtool --mode=compile --tag=CC ${CC} ${CFLAGS} \
 		${CPPFLAGS} -c -o plugin.lo plugin.c >/dev/null 2>&1
-	${SHELL} ./libtool --mode=link --tag=CC ${CC} ${CFLAGS} \
+	${SHELL} libtool --mode=link --tag=CC ${CC} ${CFLAGS} \
 		${LDFLAGS} -module -o plugin.la -export-dynamic \
 		-shrext ".o" -avoid-version plugin.lo \
 		-rpath /dont/care >/dev/null 2>&1
@@ -25989,6 +26081,7 @@ fi
 
 
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gspawn implementation" >&5
 $as_echo_n "checking for gspawn implementation... " >&6; }
 case "$host" in
@@ -27039,62 +27132,8 @@ if  test x"$have_threads" = xposix; 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* 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
-if ac_fn_c_try_link "$LINENO"; then :
-  glib_flag_works=yes
-else
-  glib_flag_works=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* 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
-if ac_fn_c_try_run "$LINENO"; then :
-  glib_flag_works=yes
-else
-  glib_flag_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam 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
 
