$NetBSD: patch-as,v 1.4 2014/03/26 13:56:22 ryoon Exp $

Treat DragonFly like FreeBSD.

--- js/src/configure.in.orig	2014-03-15 16:06:29.000000000 +0000
+++ js/src/configure.in
@@ -2431,6 +2431,7 @@ EOF
 #pragma GCC visibility push(hidden)
 #pragma GCC visibility push(default)
 #include <string.h>
+#include <iterator>
 #pragma GCC visibility pop
 
 __attribute__ ((visibility ("default"))) void Func() {
@@ -2439,7 +2440,7 @@ __attribute__ ((visibility ("default")))
 }
 EOF
                        ac_cv_have_visibility_builtin_bug=no
-                       if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
+                       if ! ${CXX-c++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
                          ac_cv_have_visibility_builtin_bug=yes
                        else
                          if test `grep -c "@PLT" conftest.S` = 0; then
@@ -2504,7 +2505,7 @@ AC_LANG_C
 
 AC_ARG_ENABLE(dtrace,
               [  --enable-dtrace         build with dtrace support if available (default=no)],
-              [enable_dtrace="yes"],)
+              [enable_dtrace=$enableval],)
 if test "x$enable_dtrace" = "xyes"; then
   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
   if test -n "$HAVE_DTRACE"; then
@@ -2664,7 +2665,7 @@ then
     fi
 
 	case "$target" in
-	    *-*-freebsd*)
+	    *-*-freebsd*|*-dragonfly*)
 			AC_DEFINE(_REENTRANT)
 			AC_DEFINE(_THREAD_SAFE)
 			dnl -pthread links in -lpthread, so don't specify it explicitly.
@@ -2743,14 +2744,19 @@ fi
 AC_CACHE_CHECK(
     [for res_ninit()],
     ac_cv_func_res_ninit,
-    [AC_TRY_LINK([
+    [AC_TRY_RUN([
         #ifdef linux
         #define _BSD_SOURCE 1
         #endif
+        #ifdef __NetBSD__
+        #error use of global _res variable in threaded programs is not portable
+        #endif
         #include <resolv.h>
-        ],
-        [int foo = res_ninit(&_res);],
+        int main(int argc, char **argv){
+            int foo = res_ninit(&_res);
+        }],
         [ac_cv_func_res_ninit=yes],
+        [ac_cv_func_res_ninit=no],
         [ac_cv_func_res_ninit=no])
     ])
 
@@ -3524,7 +3530,7 @@ if test "$MOZ_MEMORY"; then
   *-darwin*)
     AC_DEFINE(MOZ_MEMORY_DARWIN)
     ;;
-  *-*freebsd*)
+  *-*freebsd*|*-*dragonfly*)
     AC_DEFINE(MOZ_MEMORY_BSD)
     ;;
   *-android*|*-linuxandroid*)
@@ -4424,6 +4430,16 @@ fi
 dnl ========================================================
 dnl ECMAScript Internationalization API Support (uses ICU)
 dnl ========================================================
+ICU_LIB_NAMES=
+MOZ_NATIVE_ICU=
+MOZ_ARG_WITH_BOOL(system-icu,
+[  --with-system-icu
+                          Use system icu (located with pkgconfig)],
+    MOZ_NATIVE_ICU=1)
+
+if test -n "$MOZ_NATIVE_ICU"; then
+    PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1)
+fi
 
 if test -n "$JS_STANDALONE"; then
     ENABLE_INTL_API=1
@@ -4436,37 +4452,36 @@ MOZ_ARG_ENABLE_BOOL(intl-api,
 dnl Settings for the implementation of the ECMAScript Internationalization API
 if test -n "$ENABLE_INTL_API"; then
     AC_DEFINE(ENABLE_INTL_API)
-    # We build ICU as a static library.
-    AC_DEFINE(U_STATIC_IMPLEMENTATION)
 
-    case "$OS_TARGET" in
-        WINNT)
-            ICU_LIB_NAMES="icuin icuuc icudt"
-            ;;
-        Darwin|Linux)
-            ICU_LIB_NAMES="icui18n icuuc icudata"
-            ;;
-        *)
-            AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform])
-    esac
-
-    ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/lib)'
-else
-    ICU_LIB_NAMES=
-    ICU_LIBS=
+    if test -z "$MOZ_NATIVE_ICU"; then
+        case "$OS_TARGET" in
+            WINNT)
+                ICU_LIB_NAMES="icuin icuuc icudt"
+                ;;
+            Darwin|Linux)
+                ICU_LIB_NAMES="icui18n icuuc icudata"
+                ;;
+            *)
+                AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform])
+        esac
+        MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/lib)'
+    fi
 fi
 
 AC_SUBST(ENABLE_INTL_API)
 AC_SUBST(ICU_LIB_NAMES)
-AC_SUBST(ICU_LIBS)
+AC_SUBST(MOZ_ICU_LIBS)
+AC_SUBST(MOZ_NATIVE_ICU)
 
-dnl Source files that use ICU should have control over which parts of the ICU
-dnl namespace they want to use.
-AC_DEFINE(U_USING_ICU_NAMESPACE,0)
+dnl Settings for ICU
+if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then
+    dnl We build ICU as a static library.
+    AC_DEFINE(U_STATIC_IMPLEMENTATION)
 
+    dnl Source files that use ICU should have control over which parts of the ICU
+    dnl namespace they want to use.
+    AC_DEFINE(U_USING_ICU_NAMESPACE,0)
 
-dnl Settings for ICU
-if test -n "$ENABLE_INTL_API" ; then
     # Set ICU compile options
     ICU_CPPFLAGS=""
     # don't use icu namespace automatically in client code
