From 255d3c92d7bf021c109a7ef7a0376fcbf7cb9ac5 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Sat, 9 Nov 2013 02:30:27 +0100
Subject: Defs-haiku.gmk: Fix Haiku specific *_PATH variables

* /boot/common has been removed in Haiku.
* USRBIN_PATH is /system/bin.
* UNIXCCS_PATH: The installation directory for binutils/gcc has
  changed.
* DEVTOOLS_PATH: Match the comment. Tools like zip etc. live in
  /system/bin.

diff --git a/make/common/shared/Defs-haiku.gmk b/make/common/shared/Defs-haiku.gmk
index c1cc440..134e128 100644
--- a/make/common/shared/Defs-haiku.gmk
+++ b/make/common/shared/Defs-haiku.gmk
@@ -54,11 +54,10 @@ $(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
 endef
 
 BOOTSYSTEMBIN_PATH = $(shell finddir B_SYSTEM_BIN_DIRECTORY)/
-BOOTCOMMONBIN_PATH = $(shell finddir B_COMMON_BIN_DIRECTORY)/
 BOOTSYSTEMDEVELOP_PATH = $(shell finddir B_SYSTEM_DEVELOP_DIRECTORY)/
 
 # Location on system where jdk installs might be
-USRJDKINSTANCES_PATH =$(BOOTCOMMONBIN_PATH)/java
+USRJDKINSTANCES_PATH =$(BOOTSYSTEMBIN_PATH)/java
 
 # UNIXCOMMAND_PATH: path to where the most common Unix commands are.
 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
@@ -73,7 +72,7 @@ endif
 ifneq "$(origin ALT_USRBIN_PATH)" "undefined"
   USRBIN_PATH :=$(call PrefixPath,$(ALT_USRBIN_PATH))
 else
-  USRBIN_PATH  = $(BOOTCOMMONBIN_PATH)
+  USRBIN_PATH  = $(BOOTSYSTEMBIN_PATH)
 endif
 
 # UNIXCCS_PATH: path to where the Solaris ported UNIX commands can be found
@@ -81,7 +80,7 @@ endif
 ifneq "$(origin ALT_UNIXCCS_PATH)" "undefined"
   UNIXCCS_PATH :=$(call PrefixPath,$(ALT_UNIXCCS_PATH))
 else
-  UNIXCCS_PATH = $(BOOTSYSTEMDEVELOP_PATH)/tools/gnupro/
+  UNIXCCS_PATH = $(BOOTSYSTEMDEVELOP_PATH)/tools/
 endif
 
 # SLASH_JAVA: location of all network accessable files
@@ -103,7 +102,7 @@ endif
 ifneq "$(origin ALT_COMPILER_PATH)" "undefined"
   COMPILER_PATH :=$(call PrefixPath,$(ALT_COMPILER_PATH))
 else
-  COMPILER_PATH  = $(BOOTSYSTEMDEVELOP_PATH)/tools/gnupro/bin/
+  COMPILER_PATH  = $(BOOTSYSTEMBIN_PATH)
 endif
 
 # OPENWIN_HOME: path to where the X11 environment is installed.
@@ -119,7 +118,7 @@ endif
 ifneq "$(origin ALT_DEVTOOLS_PATH)" "undefined"
   DEVTOOLS_PATH :=$(call PrefixPath,$(ALT_DEVTOOLS_PATH))
 else
-  DEVTOOLS_PATH =$(BOOTSYSTEMDEVELOP_PATH)/tools/gnupro/bin/
+  DEVTOOLS_PATH =$(BOOTSYSTEMBIN_PATH)
 endif
 
 # _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
-- 
1.8.3.4


From 9e2dcc26b19f2fa0694ee7608c74ad3716054679 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Sat, 9 Nov 2013 02:35:20 +0100
Subject: PLATFORM_API_HaikuOS_PCM.cpp: Fix SoundConsumer include

It's a private system header, so specify its path explicitly.

diff --git a/src/solaris/native/com/sun/media/sound/PLATFORM_API_HaikuOS_PCM.cpp b/src/solaris/native/com/sun/media/sound/PLATFORM_API_HaikuOS_PCM.cpp
index ec111fc..d69c6a9 100644
--- a/src/solaris/native/com/sun/media/sound/PLATFORM_API_HaikuOS_PCM.cpp
+++ b/src/solaris/native/com/sun/media/sound/PLATFORM_API_HaikuOS_PCM.cpp
@@ -35,7 +35,7 @@ extern "C" {
 #include <MediaDefs.h>
 #include <MediaNode.h>
 #include <MediaRoster.h>
-#include <SoundConsumer.h>
+#include <private/media/SoundConsumer.h>
 #include <SoundPlayer.h>
 #include <TimeSource.h>
 
-- 
1.8.3.4


From 645161b7ecc348da7f94ddac74277a9569321f6b Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Sat, 9 Nov 2013 14:52:36 +0100
Subject: Fix freetype paths for Haiku


diff --git a/make/common/Defs.gmk b/make/common/Defs.gmk
index a478f97..c0dc0d0 100644
--- a/make/common/Defs.gmk
+++ b/make/common/Defs.gmk
@@ -170,8 +170,8 @@ ifeq ($(PLATFORM), solaris)
   DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/$(ARCH_FAMILY)/freetype-$(ARCH)
 endif
 ifeq ($(PLATFORM), haiku)
-  ALT_FREETYPE_HEADERS_PATH=$(shell finddir B_SYSTEM_HEADERS_DIRECTORY)/3rdparty/freetype2
-  ALT_FREETYPE_LIB_PATH=$(shell finddir B_SYSTEM_LIB_DIRECTORY)/gcc4
+  ALT_FREETYPE_HEADERS_PATH=$(shell finddir B_SYSTEM_HEADERS_DIRECTORY)
+  ALT_FREETYPE_LIB_PATH=$(shell finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib
 endif
 
 DEVTOOLS_FT_DIR_EXISTS = $(shell \
-- 
1.8.3.4


From daedb42f69c0c3b4a39e4ea354a53799c89265ab Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Sat, 9 Nov 2013 14:53:56 +0100
Subject: HaikuFontManager: Use BPathFinder API to find font dirs


diff --git a/src/solaris/native/sun/hawt/HaikuFontManager.cpp b/src/solaris/native/sun/hawt/HaikuFontManager.cpp
index a645d00..66af9ab 100644
--- a/src/solaris/native/sun/hawt/HaikuFontManager.cpp
+++ b/src/solaris/native/sun/hawt/HaikuFontManager.cpp
@@ -25,9 +25,8 @@
 
 #include <jni.h>
 
-#include <FindDirectory.h>
-#include <Path.h>
-#include <String.h>
+#include <PathFinder.h>
+#include <StringList.h>
 
 extern "C" {
 
@@ -40,19 +39,9 @@ JNIEXPORT jstring JNICALL
 Java_sun_hawt_HaikuFontManager_nativeGetFontPath
   (JNIEnv *env, jobject thiz)
 {
-	BPath systemFontsDirectory;
-	BPath commonFontsDirectory;
-	BPath userFontsDirectory;
-	
-	find_directory(B_SYSTEM_FONTS_DIRECTORY, &systemFontsDirectory);
-	find_directory(B_COMMON_FONTS_DIRECTORY, &commonFontsDirectory);
-	find_directory(B_USER_FONTS_DIRECTORY, &userFontsDirectory);
-	
-	BString path;
-	path << systemFontsDirectory.Path() << "/ttfonts:"
-		<< commonFontsDirectory.Path() << "/ttfonts:"
-		<< userFontsDirectory.Path() << "/ttfonts";
-	return env->NewStringUTF(path.String());
+	BStringList paths;
+	BPathFinder().FindPaths(B_FIND_PATH_FONTS_DIRECTORY, "ttfonts", paths);
+	return env->NewStringUTF(paths.Join(":").String());
 }
 
 }
-- 
1.8.3.4


From 7052c7beb2d10b40f35ac6c4868cb238d3b0d7db Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Tue, 26 Nov 2013 17:50:46 +0100
Subject: Make use of $ORIGIN in rpath now supported in Haiku


diff --git a/make/common/Defs-haiku.gmk b/make/common/Defs-haiku.gmk
index 7375327..70ae24b 100644
--- a/make/common/Defs-haiku.gmk
+++ b/make/common/Defs-haiku.gmk
@@ -219,15 +219,6 @@ ifdef LIBRARY
   #   The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
   #   Try: 'readelf -d lib*.so' to see these settings in a library.
   #
-  #   On Haiku, %A is sort of like $ORIGIN except that it's relative to the
-  #   program's directory rather than the library's. This causes problems
-  #   with some of the libraries (like nio for one) so you should add the
-  #   library directory to your LIBRARY_PATH if you need those.
-  #
-  #   I plan to see if I can add a %B or some such to the runtime loader
-  #   for proper relative-to-the-library rpaths. At the moment %A gets the
-  #   basics done for the launchers.
-  #
   Z_ORIGIN_FLAG/sparc = -Xlinker -z -Xlinker origin
   Z_ORIGIN_FLAG/i586  = -Xlinker -z -Xlinker origin
   Z_ORIGIN_FLAG/amd64 = -Xlinker -z -Xlinker origin
@@ -238,8 +229,8 @@ ifdef LIBRARY
 
   LDFLAG_Z_ORIGIN = $(Z_ORIGIN_FLAG/$(ARCH_FAMILY))
 
-  LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \%A
-  LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \%A/%)
+  LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN
+  LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN/%)
 
 endif
 
diff --git a/make/common/Program.gmk b/make/common/Program.gmk
index 87e9d00..ec0a555 100644
--- a/make/common/Program.gmk
+++ b/make/common/Program.gmk
@@ -99,8 +99,8 @@ ifneq (,$(findstring $(PLATFORM), linux solaris haiku))	# UNIX systems
     ifeq ($(PLATFORM), haiku)
 	LDFLAGS += $(LDFLAG_Z_ORIGIN)
 	LDFLAGS += -Wl,--allow-shlib-undefined
-	LDFLAGS += -Wl,-rpath -Wl,\%A/../lib/$(LIBARCH)/jli
-	LDFLAGS += -Wl,-rpath -Wl,\%A/../jre/lib/$(LIBARCH)/jli
+	LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
+	LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
     endif
 endif
 ifeq ($(PLATFORM), windows)
diff --git a/make/java/instrument/Makefile b/make/java/instrument/Makefile
index bb0db1e..74e744e 100644
--- a/make/java/instrument/Makefile
+++ b/make/java/instrument/Makefile
@@ -120,7 +120,7 @@ else
   ifeq ($(PLATFORM), haiku)
     LDFLAGS += $(LDFLAG_Z_ORIGIN)
     LDFLAGS += -Wl,--allow-shlib-undefined
-    LDFLAGS += -Wl,-rpath -Wl,\%A/jli
+    LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/jli
   endif
 endif
 
-- 
1.8.3.4


From c0578bc31277c67e94d8a8d71f7e47db49d0ec37 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Wed, 4 Dec 2013 03:23:53 +0100
Subject: make/java/java/Makefile: Missing generated classes

Add AUTO_FILES_JAVA_DIRS, so that the auto-generated classes are
picked up.

diff --git a/make/java/java/Makefile b/make/java/java/Makefile
index 93878e6..bd94e8f 100644
--- a/make/java/java/Makefile
+++ b/make/java/java/Makefile
@@ -59,6 +59,7 @@ endif
 include FILES_c.gmk
 include FILES_java.gmk
 include Exportedfiles.gmk
+AUTO_FILES_JAVA_DIRS = java/lang
 
 ifeq ($(PLATFORM),windows)
 FILES_java += 	java/io/Win32FileSystem.java \
-- 
1.8.3.4


From e730fb5a7d27fdc3f9213f2d75ad5ef5519e20c4 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Sun, 22 Dec 2013 21:21:11 +0100
Subject: Add support for using an external zlib

To enable it, USE_EXTERNAL_ZLIB must be set to true. EXTERNAL_ZLIB_LIB
and EXTERNAL_ZLIB_HEADERS_PATH can be set to the library to link
against and the headers path respectively. The former defaults to
"-lz".

diff --git a/make/com/sun/java/pack/Makefile b/make/com/sun/java/pack/Makefile
index 22e0b69..ce28479 100644
--- a/make/com/sun/java/pack/Makefile
+++ b/make/com/sun/java/pack/Makefile
@@ -70,9 +70,14 @@ ifeq ($(STANDALONE),true)
 	     $(ZIPOBJDIR)/inftrees.$(OBJECT_SUFFIX) \
 	     $(ZIPOBJDIR)/inffast.$(OBJECT_SUFFIX)
 
-  ZINCLUDE=-I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
-  OTHER_CXXFLAGS += $(ZINCLUDE)
-  LDDFLAGS += $(ZIPOBJS)
+  ifeq ($(USE_EXTERNAL_ZLIB), true)
+    OTHER_CXXFLAGS += $(EXTERNAL_ZLIB_CPPFLAGS)
+    LDDFLAGS += $(EXTERNAL_ZLIB_LIB)
+  else
+    ZINCLUDE=-I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+    OTHER_CXXFLAGS += $(ZINCLUDE)
+    LDDFLAGS += $(ZIPOBJS)
+  endif
 else
   OTHER_CXXFLAGS += -DNO_ZLIB -DUNPACK_JNI
   OTHER_LDLIBS += $(JVMLIB)
diff --git a/make/common/Defs.gmk b/make/common/Defs.gmk
index c0dc0d0..07849f3 100644
--- a/make/common/Defs.gmk
+++ b/make/common/Defs.gmk
@@ -210,6 +210,21 @@ ZLIB_VERSION = 1.2.3
 
 
 #
+# External zlib support
+#
+ifeq ($(USE_EXTERNAL_ZLIB), true)
+  ifndef EXTERNAL_ZLIB_LIB
+    EXTERNAL_ZLIB_LIB = -lz
+  endif
+  ifdef EXTERNAL_ZLIB_HEADERS_PATH
+    EXTERNAL_ZLIB_CPPFLAGS = -I$(EXTERNAL_ZLIB_HEADERS_PATH)
+  else
+    EXTERNAL_ZLIB_CPPFLAGS = 
+  endif
+endif
+
+
+#
 # Localizations for the different parts of the product beyond English
 #
 
diff --git a/make/java/jli/Makefile b/make/java/jli/Makefile
index 3e5994d..5500e73 100644
--- a/make/java/jli/Makefile
+++ b/make/java/jli/Makefile
@@ -69,13 +69,17 @@ FILES_c = \
 	parse_manifest.c \
 	version_comp.c \
 	wildcard.c \
-	jli_util.c \
-	inflate.c \
-	inftrees.c \
-	inffast.c \
-	zadler32.c \
-	zcrc32.c \
-	zutil.c
+	jli_util.c
+
+ifneq ($(USE_EXTERNAL_ZLIB), true)
+	FILES_c += \
+		inflate.c \
+		inftrees.c \
+		inffast.c \
+		zadler32.c \
+		zcrc32.c \
+		zutil.c
+endif
 
 ifneq ($(PLATFORM), windows)
   FILES_c += ergo.c 
@@ -131,7 +135,12 @@ endif
 
 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)
 OTHER_INCLUDES += -I$(LAUNCHER_PLATFORM_SRC)
-OTHER_INCLUDES += -I$(ZIP_SRC)
+
+ifeq ($(USE_EXTERNAL_ZLIB), true)
+  OTHER_INCLUDES += $(EXTERNAL_ZLIB_CPPFLAGS)
+else
+  OTHER_INCLUDES += -I$(ZIP_SRC)
+endif
 
 #
 # Library to compile.
@@ -164,6 +173,13 @@ library:: $(STATIC_LIBRARY)
 endif	# PLATFORM
 
 #
-# Add to ambient vpath so we pick up the library files
+# Add to ambient vpath so we pick up the library files. When using an external
+# zlib, add the library instead of the sources.
 #
-vpath %.c $(LAUNCHER_SHARE_SRC) $(ZIP_SRC) $(LAUNCHER_PLATFORM_SRC)
+vpath %.c $(LAUNCHER_SHARE_SRC) $(LAUNCHER_PLATFORM_SRC)
+
+ifeq ($(USE_EXTERNAL_ZLIB), true)
+  LDLIBS += $(EXTERNAL_ZLIB_LIB)
+else
+  vpath %.c $(ZIP_SRC)
+endif
diff --git a/make/java/zip/FILES_c.gmk b/make/java/zip/FILES_c.gmk
index 6664887..97c6d3f 100644
--- a/make/java/zip/FILES_c.gmk
+++ b/make/java/zip/FILES_c.gmk
@@ -29,16 +29,20 @@ FILES_c = \
 	Deflater.c \
 	Inflater.c \
 	ZipFile.c \
-	zip_util.c \
-	compress.c \
-	deflate.c \
-	gzio.c \
-	infback.c \
-	inffast.c \
-	inflate.c \
-	inftrees.c \
-	trees.c \
-	uncompr.c \
-	zadler32.c \
-	zcrc32.c \
-	zutil.c 
+	zip_util.c
+
+ifneq ($(USE_EXTERNAL_ZLIB), true)
+	FILES_c += \
+		compress.c \
+		deflate.c \
+		gzio.c \
+		infback.c \
+		inffast.c \
+		inflate.c \
+		inftrees.c \
+		trees.c \
+		uncompr.c \
+		zadler32.c \
+		zcrc32.c \
+		zutil.c 
+endif
diff --git a/make/java/zip/Makefile b/make/java/zip/Makefile
index 906e7e8..15b2d45 100644
--- a/make/java/zip/Makefile
+++ b/make/java/zip/Makefile
@@ -74,14 +74,24 @@ else
 CPPFLAGS += -UDEBUG 
 endif
 
-CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+ifeq ($(USE_EXTERNAL_ZLIB), true)
+  CPPFLAGS += $(EXTERNAL_ZLIB_CPPFLAGS)
+else
+  CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+endif
+
 CPPFLAGS += -I$(SHARE_SRC)/native/java/io
 CPPFLAGS += -I$(PLATFORM_SRC)/native/java/io
 
 #
-# Add to ambient vpath so we pick up the library files
+# Add to ambient vpath so we pick up the library files. When using an external
+# zlib, add the library instead.
 #
-vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/zlib-$(ZLIB_VERSION)
+ifeq ($(USE_EXTERNAL_ZLIB), true)
+  LDLIBS += $(EXTERNAL_ZLIB_LIB)
+else
+  vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/zlib-$(ZLIB_VERSION)
+endif
 
 #
 # Link to JVM library for JVM_Zip* functions
-- 
1.8.3.4

