From: Mike Hommey <glandium@debian.org>
Date: Tue, 11 Mar 2008 08:29:25 +0100
Subject: Support building on GNU/Hurd

https://bugzilla.mozilla.org/show_bug.cgi?id=555901
---
 config/rules.mk                                    |    8 ++++++++
 configure.in                                       |    7 ++++---
 js/src/config/rules.mk                             |    8 ++++++++
 js/src/configure.in                                |   10 +++++++---
 xpcom/glue/standalone/Makefile.in                  |    2 +-
 xpcom/reflect/xptcall/src/md/unix/Makefile.in      |    2 +-
 .../src/md/unix/xptc_platforms_unixish_x86.h       |    2 +-
 7 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/config/rules.mk b/config/rules.mk
index d9864a0..f0b80ea 100644
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -666,6 +666,14 @@ endif
 endif 
 
 #
+# GNU doesn't have path length limitation
+#
+
+ifeq ($(OS_ARCH),GNU)
+OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
+endif
+
+#
 # MINGW32
 #
 ifeq ($(OS_ARCH),WINNT)
diff --git a/configure.in b/configure.in
index 0f4471b..bc19dc1 100644
--- a/configure.in
+++ b/configure.in
@@ -1022,6 +1022,7 @@ if test -n "$CROSS_COMPILE"; then
     case "${target_os}" in
         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
+        gnu*)         OS_ARCH=GNU ;;
         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
         mingw*)       OS_ARCH=WINNT ;;
         wince*)       OS_ARCH=WINCE ;;
@@ -1624,7 +1625,7 @@ case "$host" in
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL -lobjc'
     ;;
 
-*-linux*|*-kfreebsd*-gnu)
+*-linux*|*-kfreebsd*-gnu|*-gnu*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
@@ -2645,7 +2646,7 @@ dnl ========================================================
 dnl = Flags to strip unused symbols from .so components
 dnl ========================================================
 case "$target" in
-    *-linux*|*-kfreebsd*-gnu)
+    *-linux*|*-kfreebsd*-gnu|*-gnu*)
         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
         ;;
     *-solaris*)
@@ -3328,7 +3329,7 @@ then
 			fi
 			;;
 
-	    *-*-linux*|*-*-kfreebsd*-gnu)
+	    *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
 			AC_DEFINE(_REENTRANT) 
 			;;
 
diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk
index d9864a0..f0b80ea 100644
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -666,6 +666,14 @@ endif
 endif 
 
 #
+# GNU doesn't have path length limitation
+#
+
+ifeq ($(OS_ARCH),GNU)
+OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
+endif
+
+#
 # MINGW32
 #
 ifeq ($(OS_ARCH),WINNT)
diff --git a/js/src/configure.in b/js/src/configure.in
index 917e0ef..206e3ee 100644
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -923,6 +923,7 @@ if test -n "$CROSS_COMPILE"; then
     case "${target_os}" in
         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
+        gnu*)         OS_ARCH=GNU ;;
         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
         mingw*)       OS_ARCH=WINNT ;;
         wince*)       OS_ARCH=WINCE ;;
@@ -1524,7 +1525,7 @@ case "$host" in
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL -lobjc'
     ;;
 
-*-linux*|*-kfreebsd*-gnu)
+*-linux*|*-kfreebsd*-gnu|*-gnu*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
@@ -2423,7 +2424,7 @@ dnl ========================================================
 dnl = Flags to strip unused symbols from .so components
 dnl ========================================================
 case "$target" in
-    *-linux*|*-kfreebsd*-gnu)
+    *-linux*|*-kfreebsd*-gnu|*-gnu*)
         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
         ;;
     *-solaris*)
@@ -2506,6 +2507,9 @@ solaris*)
 freebsd*|kfreebsd*)
     AC_DEFINE(AVMPLUS_UNIX)
     ;;
+gnu*)
+    AC_DEFINE(AVMPLUS_UNIX)
+    ;;
 *cygwin*|*mingw*|*mks*|*msvc*|*wince)
     AC_DEFINE(AVMPLUS_WIN32)
     ;;
@@ -3095,7 +3099,7 @@ then
 			fi
 			;;
 
-	    *-*-linux*|*-*-kfreebsd*-gnu)
+	    *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
 			AC_DEFINE(_REENTRANT) 
 			;;
 
diff --git a/xpcom/glue/standalone/Makefile.in b/xpcom/glue/standalone/Makefile.in
index 08411fe..a52ddbc 100644
--- a/xpcom/glue/standalone/Makefile.in
+++ b/xpcom/glue/standalone/Makefile.in
@@ -62,7 +62,7 @@ endif
 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
 LINKSRC = nsGlueLinkingWin.cpp
 endif
-ifneq (,$(filter AIX DragonFly FreeBSD Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
+ifneq (,$(filter AIX DragonFly FreeBSD GNU GNU_% Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
 LINKSRC = nsGlueLinkingDlopen.cpp
 endif
 ifeq (OS2,$(OS_ARCH))
diff --git a/xpcom/reflect/xptcall/src/md/unix/Makefile.in b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
index 96ba820..b1a8829 100644
--- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
@@ -64,7 +64,7 @@ include $(topsrcdir)/config/config.mk
 #
 # Lots of Unixish x86 flavors
 #
-ifneq (,$(filter FreeBSD NetBSD OpenBSD BSD_OS Darwin,$(OS_ARCH)))
+ifneq (,$(filter FreeBSD NetBSD OpenBSD BSD_OS Darwin GNU,$(OS_ARCH)))
 ifeq (86,$(findstring 86,$(OS_TEST)))
 CPPSRCS		:= xptcinvoke_unixish_x86.cpp xptcstubs_unixish_x86.cpp
 ifeq (Darwin,$(OS_ARCH))
diff --git a/xpcom/reflect/xptcall/src/md/unix/xptc_platforms_unixish_x86.h b/xpcom/reflect/xptcall/src/md/unix/xptc_platforms_unixish_x86.h
index 71fd140..d453e55 100644
--- a/xpcom/reflect/xptcall/src/md/unix/xptc_platforms_unixish_x86.h
+++ b/xpcom/reflect/xptcall/src/md/unix/xptc_platforms_unixish_x86.h
@@ -67,7 +67,7 @@
 *
 */
 
-#if defined(LINUX) || (defined(__GLIBC__) && defined(__FreeBSD_kernel__))
+#if defined(LINUX) || (defined(__GLIBC__) && (defined(__FreeBSD_kernel__) || defined(__GNU__)))
 
 #if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)
 /* Old gcc 2.7.x.x.  What does gcc 2.8.x do?? */
