jdk/makefiles/CompileNativeLibraries.gmk
changeset 13164 72c5d01a857d
parent 12892 3ef14bab6254
child 13702 efd6a05935b2
--- a/jdk/makefiles/CompileNativeLibraries.gmk	Wed Jul 05 18:14:56 2017 +0200
+++ b/jdk/makefiles/CompileNativeLibraries.gmk	Tue Jul 03 16:10:44 2012 -0700
@@ -35,13 +35,16 @@
 # Copy files (can now depend on $(COPY_FILES))
 include CopyFiles.gmk
 
+# Build tools
+include Tools.gmk
+
 # Include the javah generated headers.
 CFLAGS_JDKLIB += -I$(JDK_OUTPUTDIR)/gensrc_headers
 CXXFLAGS_JDKLIB += -I$(JDK_OUTPUTDIR)/gensrc_headers
 
-# Put the libraries here. Different locations for different host apis.
-ifeq ($(HOST_OS_API),posix)
-    ifneq ($(HOST_OS),macosx)
+# Put the libraries here. Different locations for different target apis.
+ifeq ($(OPENJDK_TARGET_OS_API),posix)
+    ifneq ($(OPENJDK_TARGET_OS),macosx)
         INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib/$(LIBARCH)
         LIBARCHDIR=$(LIBARCH)/
     else
@@ -52,465 +55,213 @@
     INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/bin
 endif
 
-$(INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX) : $(JDK_OUTPUTDIR)/objs/%$(SHARED_LIBRARY_SUFFIX)
-	$(ECHO) Copying $(@F)
-	$(CP) $< $@
-
 BUILD_LIBRARIES=
 
-# TODO: Temporary until awt is converted:
-# OBJDIRNAME is the name of the directory where the object code is to
-#   be placed. It's name depends on whether the data model architecture 
-#   is 32-bit or not.
-ifneq ($(ARCH_DATA_MODEL), 32)
-  OBJDIRNAME  = obj$(ARCH_DATA_MODEL)$(OBJDIRNAME_SUFFIX)
-else
-  OBJDIRNAME  = obj$(OBJDIRNAME_SUFFIX)
-endif
+# Absolute paths to lib files on windows for use in LDFLAGS. Should figure out a more
+# elegant solution to this.
+WIN_VERIFY_LIB := $(JDK_OUTPUTDIR)/objs/libverify/verify.lib
+WIN_JAVA_LIB := $(JDK_OUTPUTDIR)/objs/libjava/java.lib
+WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib
 
 ##########################################################################################
 
-BUILD_LIBZIP_FILES := \
-        CRC32.c \
-	Adler32.c \
-	Deflater.c \
-	Inflater.c \
-	ZipFile.c \
-	zip_util.c
-
-ifeq ($(USE_EXTERNAL_LIBZ),true)
-	LIBZ := -lz
-else
-BUILD_LIBZIP_FILES += \
-	compress.c \
-	deflate.c \
-	gzclose.c \
-	gzlib.c \
-	gzread.c \
-	gzwrite.c \
-	infback.c \
-	inffast.c \
-	inflate.c \
-	inftrees.c \
-	trees.c \
-	uncompr.c \
-	zadler32.c \
-	zcrc32.c \
-	zutil.c
-	LIBZ_INCLUDE := -I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
+BUILD_LIBFDLIBM_OPTIMIZATION:=HIGH
+
+ifneq ($(OPENJDK_TARGET_OS), solaris)
+      BUILD_LIBFDLIBM_OPTIMIZATION:=NONE
 endif
 
-$(eval $(call SetupNativeCompilation,BUILD_LIBZIP,\
-                SRC:=$(JDK_TOPDIR)/src/share/native/java/util/zip \
-                     $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5,\
-		INCLUDE_FILES := $(BUILD_LIBZIP_FILES), \
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        $(LIBZ_INCLUDE) \
-		        -I$(JDK_TOPDIR)/src/share/native/java/io \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/io,\
-		CFLAGS_posix:=-DUSE_MMAP -UDEBUG,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libzip/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(EXPORT_ZIP_FUNCS), \
-		LDFLAGS_winapi:=-export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \
-                                -export:ZIP_ReadEntry -export:ZIP_GetNextEntry jvm.lib \
-                                java.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBZ),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libzip,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)zip$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)zip$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)zip$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-LIBUNPACK_LIB_FILE := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK,\
-                SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/java/util/jar/pack,\
-		EXCLUDE_FILES:=main.cpp,\
-		LANG:=C++,\
-		CFLAGS:=$(CXXFLAGS_JDKLIB) $(CXX_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-			 -DNO_ZLIB -DUNPACK_JNI -DFULL,\
-		CFLAGS_release:=-DPRODUCT,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libunpack/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB)\
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_winapi:=-map:$(JDK_OUTPUTDIR)/objs/unpack.map /debug \
-				jvm.lib java.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_posix:=$(LIBCXX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libunpack,\
-		LIB:=$(LIBUNPACK_LIB_FILE),\
-		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
-		RC_FLAGS:=$(RC_FLAGS)\
-			  /D "JDK_FNAME=unpack.dll" \
-			  /D "JDK_INTERNAL_NAME=unpack" \
-			  /D "JDK_FTYPE=0x2L"))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)
-
-ifeq ($(HOST_OS_API),winapi)
-    $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.map: $(LIBUNPACK_LIB_FILE)
-	$(ECHO) Copying $(@F)
-	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX),%.map,$<) $@
-
-    $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.pdb: $(LIBUNPACK_LIB_FILE)
-	$(ECHO) Copying $(@F)
-	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX),%.pdb,$<) $@
-endif
-
-##########################################################################################
-
-BUILD_LIBFDLIBM_OPTIMIZATION:= $(C_O_FLAG_HI)
-
-ifneq ($(PLATFORM), solaris)
-      BUILD_LIBFDLIBM_OPTIMIZATION := $(C_O_FLAG_NONE)
-endif
-
-ifneq ($(PLATFORM),macosx)
+ifneq ($(OPENJDK_TARGET_OS),macosx)
 $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM,\
+                STATIC_LIBRARY:=fdlibm,\
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs,\
                 SRC:=$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/src,\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBFDLIBM_OPTIMIZATION) \
+		OPTIMIZATION:=$(BUILD_LIBFDLIBM_OPTIMIZATION), \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
 		CFLAGS_winapi_debug:=-DLOGGING,\
 		ARFLAGS:=$(ARFLAGS),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
+
+BUILD_LIBRARIES += $(BUILD_LIBFDLIBM)
+
 else
 #
 # On macosx they do partial (incremental) linking of fdlibm
 #   code it here...rather than add support to NativeCompilation
 #   as this is firt time I see it
 $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM,\
+                LIBRARY:=fdlibm,\
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
                 SRC:=$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/src,\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBFDLIBM_OPTIMIZATION) \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
-		LDFLAGS := -nostdlib -r,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) : \
-	$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS:=-nostdlib -r,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
+
+$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) : $(BUILD_LIBFDLIBM)
 	$(CP) -a $< $@
-endif
-
 
 BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-LIBATTACH_EXCLUDE_FILES:=
-ifneq ($(PLATFORM),solaris)
-    LIBATTACH_EXCLUDE_FILES+=SolarisVirtualMachine.c
-endif
-ifneq ($(PLATFORM),linux)
-    LIBATTACH_EXCLUDE_FILES+=LinuxVirtualMachine.c
-endif
-ifneq ($(PLATFORM),macosx)
-    LIBATTACH_EXCLUDE_FILES+=BsdVirtualMachine.c
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/tools/attach,\
-		EXCLUDE_FILES:=$(LIBATTACH_EXCLUDE_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libattach/mapfile-$(PLATFORM), \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_solaris:=-ldoor,\
-		LDFLAGS_winapi:=psapi.lib advapi32.lib java.lib jvm.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libattach,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBDT_SOCKET,\
-                SRC:=$(JDK_TOPDIR)/src/share/transport/socket \
-			$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/transport/socket,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) -DUSE_MMAP $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(PLATFORM) \
-                        -I$(JDK_TOPDIR)/src/share/transport/socket \
-		        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/transport/socket \
-                        -I$(JDK_TOPDIR)/src/share/back/export \
-                        -I$(JDK_TOPDIR)/src/share/back,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libdt_socket/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB), \
-		LDFLAGS_SUFFIX_linux:=-lpthread,\
-		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket,\
-		LDFLAGS_SUFFIX_winapi:=-export:jdwpTransport_OnLoad ws2_32.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libdt_socket,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)dt_socket$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)dt_socket$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)dt_socket$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-ifeq ($(HOST_OS_API),winapi)
-
-  $(eval $(call SetupNativeCompilation,BUILD_LIBDT_SHMEM,\
-                SRC:= $(JDK_TOPDIR)/src/share/native/com/sun/tools/jdi \
-			$(JDK_TOPDIR)/src/share/transport/shmem \
-			$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/transport/shmem,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) -DUSE_MMAP $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS)\
-                        -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(PLATFORM) \
-                        -I$(JDK_TOPDIR)/src/share/transport/shmem \
-		        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/transport/shmem \
-                        -I$(JDK_TOPDIR)/src/share/back/export, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB),\
-		LDFLAGS_winapi:=-export:jdwpTransport_OnLoad,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libdt_shmem,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)dt_shmem$(SHARED_LIBRARY_SUFFIX)))
-
-  BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)dt_shmem$(SHARED_LIBRARY_SUFFIX)
-
-endif # PLATFORM
-
-##########################################################################################
-# JDWP_LOGGING causes log messages to be compiled into the library. These reference the 
-# __FILE__ macro which here expands to the absolute path of the file while the old build 
-# system used a relative path. This causes the binaries to differ in size.
-$(eval $(call SetupNativeCompilation,BUILD_LIBJDWP,\
-                SRC:=$(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/back,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) -DJDWP_LOGGING $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS)\
-		 -I$(JDK_TOPDIR)/src/share/transport/export \
-                 -I$(JDK_TOPDIR)/src/share/back/export \
-                 -I$(JDK_TOPDIR)/src/share/npt \
-                 -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/npt \
-                 -I$(JDK_TOPDIR)/src/share/back \
-                 -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/back \
-		 -I$(JDK_OUTPUTDIR)/gensrc_jdwp_headers,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjdwp/mapfile-vers, \
-		LDFLAGS:=$(filter-out -ljava,$(LDFLAGS_JDKLIB)), \
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_linux:=$(LIBDL),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjdwp,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jdwp$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jdwp$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jdwp$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-LIBJAAS_MAPFILE :=
-ifneq ($(PLATFORM),solaris)
-   LIBJAAS_EXCLUDE_FILES:=Solaris.c
-else
-   # only on solaris...wonder why
-   LIBJAAS_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjaas/mapfile-vers
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJAAS,\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/com/sun/security/auth/module,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS),\
-		MAPFILE := $(LIBJAAS_MAPFILE),\
-		LDFLAGS:=$(filter-out -ljava,$(LDFLAGS_JDKLIB)) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_winapi:=netapi32.lib user32.lib mpr.lib advapi32.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		EXCLUDE_FILES:=$(LIBJAAS_EXCLUDE_FILES),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjaas,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jaas$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jaas$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jaas$(SHARED_LIBRARY_SUFFIX)
-
-# Oddly enough, it is called jaas_nt.dll under winapi and libjaas_unix.so under posix.
-ifeq ($(PLATFORM),windows)
-    $(INSTALL_LIBRARIES_HERE)/jaas_nt.dll : $(JDK_OUTPUTDIR)/objs/jaas.dll
-	$(ECHO) Copying $(@F)
-	$(CP) $< $@
-    BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/jaas_nt.dll
-else
-    $(INSTALL_LIBRARIES_HERE)/libjaas_unix$(SHARED_LIBRARY_SUFFIX) : $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jaas$(SHARED_LIBRARY_SUFFIX)
-	$(ECHO) Copying $(@F)
-	$(CP) $< $@
-    BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/libjaas_unix$(SHARED_LIBRARY_SUFFIX)
 endif
 
 ##########################################################################################
 
-ifeq ($(HOST_OS_API),posix)
-  # TODO make this work on macosx
-  ifneq ($(HOST_OS),macosx)
-
-    $(eval $(call SetupNativeCompilation,BUILD_LIBSCTP,\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/nio/ch/sctp,\
+BUILD_LIBVERIFY_SRC:=check_code.c check_format.c
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+	ifneq ($(ARCH), amd64)
+		BUILD_LIBVERIFY_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libverify/reorder-$(ARCH)
+	endif
+endif
+
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBVERIFY,\
+		LIBRARY:=verify, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/share/native/common,\
+		INCLUDE_FILES:=$(BUILD_LIBVERIFY_SRC),\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS)\
-			-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch \
-			-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch/sctp \
-			-I$(JDK_TOPDIR)/src/share/native/java/net \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/nio/ch \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/net,\
-		CFLAGS_linux:=-Werror,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libsctp/mapfile-vers, \
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libverify/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_linux:=-lpthread,\
-		LDFLAGS_SUFFIX_posix:=$(LIBDL) -lnio -lnet,\
-		LDFLAGS_SUFFIX_solaris:=-lsocket,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		INCLUDE_FILES:=SctpNet.c SctpChannelImpl.c SctpServerChannelImpl.c,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libsctp,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX)))
-
-    BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX)
-
-    $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX)
-  endif
-endif
-
-##########################################################################################
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJSDT,\
-                SRC:=$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace\
-			$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/tracing/dtrace,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS)\
-			-I$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjsdt/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBDL),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjsdt,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsdt$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsdt$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jsdt$(SHARED_LIBRARY_SUFFIX)
+			 $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS_SUFFIX_posix:=-ljvm -lc,\
+		LDFLAGS_SUFFIX_windows:=jvm.lib,\
+		REORDER:=$(BUILD_LIBVERIFY_REORDER),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libverify,\
+		DEBUG_SYMBOLS:=true))
+
+BUILD_LIBRARIES += $(BUILD_LIBVERIFY)
 
 ##########################################################################################
 
-ifdef OPENJDK
-    # TODO: Update awt lib path when awt is converted
-    $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS,\
-                SRC:=$(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms \
-		     $(JDK_TOPDIR)/src/share/native/sun/java2d/,\
-		INCLUDE_FILES:=cmscam02.c cmscgats.c cmscnvrt.c cmserr.c \
-			       cmsgamma.c cmsgmt.c cmsintrp.c cmsio0.c \
-			       cmsio1.c cmslut.c cmsmd5.c cmsmtrx.c \
-			       cmsnamed.c cmsopt.c cmspack.c cmspcs.c \
-			       cmsplugin.c cmsps2.c cmssamp.c cmssm.c \
-			       cmstypes.c cmsvirt.c cmswtpnt.c cmsxform.c \
-			       LCMS.c,\
+LIBJAVA_SRC_DIRS:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/lang \
+		$(JDK_TOPDIR)/src/share/native/java/lang \
+		$(JDK_TOPDIR)/src/share/native/java/lang/ref \
+		$(JDK_TOPDIR)/src/share/native/java/lang/reflect \
+		$(JDK_TOPDIR)/src/share/native/java/io \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/io \
+		$(JDK_TOPDIR)/src/share/native/java/nio \
+		$(JDK_TOPDIR)/src/share/native/java/security \
+		$(JDK_TOPDIR)/src/share/native/common \
+		$(JDK_TOPDIR)/src/share/native/sun/misc \
+		$(JDK_TOPDIR)/src/share/native/sun/reflect \
+		$(JDK_TOPDIR)/src/share/native/java/sql \
+		$(JDK_TOPDIR)/src/share/native/java/util \
+		$(JDK_TOPDIR)/src/share/native/java/util/concurrent/atomic \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/common \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/util \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/provider \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/io
+
+#
+# TODO
+#
+ARCHPROPNAME:=$(LIBARCH)
+ifeq ($(OPENJDK_TARGET_OS)-$(ARCH), solaris-i586)
+     ARCHPROPNAME:=x86
+else ifeq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL), windows-32)
+     ARCHPROPNAME:=x86
+else ifeq ($(OPENJDK_TARGET_OS), macosx)
+     ARCHPROPNAME:=$(ARCH)
+endif
+
+LIBJAVA_CFLAGS:=$(foreach dir,$(LIBJAVA_SRC_DIRS),-I$(dir)) \
+		  -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \
+                  -DARCHPROPNAME='"$(ARCHPROPNAME)"'
+
+LIBJAVA_CFLAGS += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
+                  -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
+                  -DJDK_MICRO_VERSION='"$(JDK_MICRO_VERSION)"' \
+                  -DJDK_BUILD_NUMBER='"$(JDK_BUILD_NUMBER)"' 
+
+ifneq (,$(JDK_UPDATE_VERSION))
+	LIBJAVA_CFLAGS += -DJDK_UPDATE_VERSION='"$(JDK_UPDATE_VERSION)"'
+endif
+
+LIBJAVA_EXCLUDE_FILES:=check_code.c check_format.c
+
+ifneq ($(OPENJDK_TARGET_OS),macosx)
+	LIBJAVA_EXCLUDE_FILES += java_props_macosx.c
+else
+	BUILD_LIBJAVA_java_props_md.c_CFLAGS:=-x objective-c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+        LIBJAVA_EXCLUDE_FILES += \
+		UNIXProcess_md.c \
+		UnixFileSystem_md.c \
+		FileSystemPreferences.c
+else
+	LIBJAVA_EXCLUDE_FILES += \
+		ProcessImpl_md.c \
+		Win32FileSystem_md.c \
+		WinNTFileSystem_md.c \
+		dirent_md.c \
+		WindowsPreferences.c \
+		sun/security/provider/WinCAPISeedGenerator.c \
+		sun/io/Win32ErrorMode.c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+    ifneq ($(ARCH), amd64)
+        LIBJAVA_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libjava/reorder-$(ARCH)
+    endif
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJAVA,\
+		LIBRARY:=java,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(LIBJAVA_SRC_DIRS),\
+		EXCLUDES:=fdlibm/src zip, \
+		EXCLUDE_FILES:=$(LIBJAVA_EXCLUDE_FILES), \
 		LANG:=C,\
-		CFLAGS:=$(filter-out -xc99=%none,$(CFLAGS_JDKLIB)) $(C_O_FLAG_NORM) \
-			$(SHARED_LIBRARY_FLAGS) \
-			-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-			-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug,\
-		CFLAGS_solaris:=-xc99=no_lib,\
-		CFLAGS_winapi:=-DCMS_IS_WINDOWS_,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/liblcms/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB), \
-		LDFLAGS_solaris:=/usr/lib$(ISA_DIR)/libm.so.2,\
-		LDFLAGS_winapi:=awt.lib java.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_posix:=-lawt,\
-		LDFLAGS_SUFFIX_linux:=-lm,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/liblcms,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)lcms$(SHARED_LIBRARY_SUFFIX)))
-
-    BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)lcms$(SHARED_LIBRARY_SUFFIX)
-
-    $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)lcms$(SHARED_LIBRARY_SUFFIX) : \
-	$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)
-endif
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        $(LIBJAVA_CFLAGS),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjava/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS_windows:=-export:winFileHandleOpen -export:handleLseek \
+				 $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) jvm.lib \
+				 shell32.lib delayimp.lib /DELAYLOAD:shell32.dll \
+				 advapi32.lib,\
+		LDFLAGS_SUFFIX_posix:=-ljvm -lverify, \
+		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc,\
+		LDFLAGS_SUFFIX_linux:=$(LIBDL) $(BUILD_LIBFDLIBM),\
+		LDFLAGS_SUFFIX_macosx:=$(BUILD_LIBFDLIBM) \
+                                         -framework CoreFoundation \
+                                         -framework Security -framework SystemConfiguration, \
+		REORDER:=$(LIBJAVA_REORDER), \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava))
+
+BUILD_LIBRARIES += $(BUILD_LIBJAVA)
+
+$(BUILD_LIBJAVA) : $(LIBJLI_BINARY)
+
+$(BUILD_LIBJAVA) : $(BUILD_LIBVERIFY)
+
+$(BUILD_LIBJAVA) : $(BUILD_LIBFDLIBM)
 
 ##########################################################################################
 
-ifdef OPENJDK
-    BUILD_LIBJPEG_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/mapfile-vers
-else
-    BUILD_LIBJPEG_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/mapfile-vers-closed
-    BUILD_LIBJPEG_CLOSED_SRC := $(JDK_TOPDIR)/src/closed/share/native/sun/awt/image/jpeg
-    BUILD_LIBJPEG_CLOSED_INCLUDES := -I$(BUILD_LIBJPEG_CLOSED_SRC)
-endif
-
-BUILD_LIBJPEG_REORDER :=
-ifeq ($(PLATFORM), solaris)
-    ifneq ($(ARCH), amd64)
-        BUILD_LIBJPEG_REORDER := $(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/reorder-$(ARCH)
-    endif
-endif
-
-# Suppress gcc warnings like "variable might be clobbered by 'longjmp'
-# or 'vfork'": this warning indicates that some variable is placed to
-# a register by optimized compiler and it's value might be lost on longjmp().
-# Recommended way to avoid such warning is to declare the variable as
-# volatile to prevent the optimization. However, this approach does not
-# work because we have to declare all variables as volatile in result.
-#ifndef CROSS_COMPILE_ARCH
-#    CC_43_OR_NEWER := \
-#        $(shell $(EXPR) $(CC_MAJORVER) \> 4 \| \
-#              \( $(CC_MAJORVER) = 4 \& $(CC_MINORVER) \>= 3 \) )
-#    ifeq ($(CC_43_OR_NEWER),1)
-#        BUILD_LIBJPEG_CFLAGS_linux += -Wno-clobbered
-#    endif
-#endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJPEG,\
-                SRC:=$(BUILD_LIBJPEG_CLOSED_SRC) \
-		     $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HIGHEST) $(SHARED_LIBRARY_FLAGS) \
-			$(BUILD_LIBJPEG_CLOSED_INCLUDES) \
-			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg,\
-		MAPFILE := $(BUILD_LIBJPEG_MAPFILE), \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_linux:=$(LIBDL),\
-		LDFLAGS_winapi:=java.lib jvm.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		REORDER := $(BUILD_LIBJPEG_REORDER),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjpeg,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jpeg$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jpeg$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jpeg$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-BUILD_LIBMLIB_SRC := $(JDK_TOPDIR)/src/share/native/sun/awt/medialib
-BUILD_LIBMLIB_CFLAGS := -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES \
+BUILD_LIBMLIB_SRC:=$(JDK_TOPDIR)/src/share/native/sun/awt/medialib
+BUILD_LIBMLIB_CFLAGS:=-D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES \
 			-I$(BUILD_LIBMLIB_SRC) \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/awt/medialib 
-
-BUILD_LIBMLIB_LDLIBS :=
-BUILD_LIBMLIB_IMAGE_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libmlib_image/mapfile-vers
-
-ifneq ($(PLATFORM), sparc)
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt/medialib 
+
+BUILD_LIBMLIB_LDLIBS:=
+BUILD_LIBMLIB_IMAGE_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libmlib_image/mapfile-vers
+
+ifneq ($(OPENJDK_TARGET_OS), sparc)
+#
+# Yes, this will always be true (until someone makes an OS called sparc)
+#   but this is how it was writtin in old system...keep it like this for now
+#
 	BUILD_LIBMLIB_CFLAGS += -DMLIB_NO_LIBSUNMATH
 endif
 
@@ -518,43 +269,44 @@
 	BUILD_LIBMLIB_CFLAGS += -DMLIB_OS64BIT
 endif
 
-ifneq ($(PLATFORM), windows)
+ifneq ($(OPENJDK_TARGET_OS), windows)
 	BUILD_LIBMLIB_LDLIBS += $(LIBM) $(LIBDL)
 endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE,\
-		SRC:=$(BUILD_LIBMLIB_SRC),\
+		LIBRARY:=mlib_image,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(BUILD_LIBMLIB_SRC),\
 		EXCLUDE_FILES:=awt_ImagingLib.c mlib_c_ImageBlendTable.c,\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HIGHEST) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=HIGHEST, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
                         $(BUILD_LIBMLIB_CFLAGS),\
-		MAPFILE := $(BUILD_LIBMLIB_IMAGE_MAPFILE), \
+		MAPFILE:=$(BUILD_LIBMLIB_IMAGE_MAPFILE), \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
                          $(BUILD_LIBMLIB_LDLIBS) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-                LDFLAGS_SUFFIX_posix := -lm,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libmlib_image,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX)
+                LDFLAGS_SUFFIX_posix:=-lm,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image))
+
+$(BUILD_LIBMLIB_IMAGE) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBMLIB_IMAGE)
 
 ##########################################################################################
 
-ifeq ($(PLATFORM),solaris)
+ifeq ($(OPENJDK_TARGET_OS),solaris)
 ifeq ($(ARCH),sparc)
-	BUILD_LIBMLIB_IMAGE_V := 1
+	BUILD_LIBMLIB_IMAGE_V:=1
 else ifeq ($(ARCH), sparcv9)
-	BUILD_LIBMLIB_IMAGE_V := 1
+	BUILD_LIBMLIB_IMAGE_V:=1
 endif
 endif
 
 ifeq ($(BUILD_LIBMLIB_IMAGE_V), 1)
 
-BUILD_LIBMLIB_IMAGE_V_FILES :=  \
+BUILD_LIBMLIB_IMAGE_V_FILES:=\
         mlib_v_ImageLookUp.c \
         mlib_ImageCreate.c \
         mlib_ImageAffine.c \
@@ -648,1185 +400,355 @@
         mlib_ImageUtils.c \
         mlib_ImageDivTables.c
 
-#
-# TODO
-#
-# ASFLAGS += -P
-# INLINE = $(PLATFORM_SRC)/native/sun/awt/medialib/vis_$(ARCH_DATA_MODEL).il
+BUILD_LIBMLIB_V_CFLAGS := $(filter-out -DMLIB_NO_LIBSUNMATH,$(BUILD_LIBMLIB_CFLAGS))
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE_V,\
-		SRC:=$(JDK_TOPDIR)/src/share/native/sun/awt/medialib \
+		LIBRARY:=mlib_image_v, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/sun/awt/medialib \
 		     $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib,\
 		LANG:=C,\
-		INCLUDE_FILES := $(BUILD_LIBMLIB_IMAGE_V_FILES),\
-		CFLAGS:=$(BUILD_LIBMLIB_CFLAGS) \
-                        $(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(SHARED_LIBRARY_FLAGS) \
-		MAPFILE := $(JDK_TOPDIR)/$(BUILD_LIBMLIB_IMAGE_MAPFILE), \
+		INCLUDE_FILES:=$(BUILD_LIBMLIB_IMAGE_V_FILES),\
+		OPTIMIZATION:=HIGHEST, \
+		CFLAGS:=-xarch=sparcvis \
+                      $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib/vis_$(ARCH_DATA_MODEL).il\
+                      $(BUILD_LIBMLIB_V_CFLAGS) \
+                      $(CFLAGS_JDKLIB), \
+		MAPFILE:=$(BUILD_LIBMLIB_IMAGE_MAPFILE), \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
                          $(BUILD_LIBMLIB_LDLIBS) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)mlib_image_v$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)mlib_image_v$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v))
+
+BUILD_LIBRARIES += $(BUILD_LIBMLIB_IMAGE_V)
 
 endif
 
 ##########################################################################################
 
-ifndef OPENJDK
-    FONT_HEADERS := -I$(CLOSED_SRC)/share/native/$(PKGDIR)/t2k
-    BUILD_LIBFONTMANAGER_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libfontmanager/mapfile-vers
-    LIBFONTMANAGER_EXCLUDE_FILES += freetypeScaler.c
-else
-    FONT_HEADERS := $(FREETYPE2_CFLAGS)
-    BUILD_LIBFONTMANAGER_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libfontmanager/mapfile-vers.openjdk
-    BUILD_LIBFONTMANAGER_FONTLIB := $(FREETYPE2_LIBS)
-endif
-
-ifeq ($(PLATFORM),windows)
-    LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
-				    X11TextRenderer.c
-else
-    LIBFONTMANAGER_EXCLUDE_FILES += fontpath.c \
-				    lcdglyph.c
-endif
-
-BUILD_LIBFONTMANAGER_CFLAGS_COMMON := $(SHARED_LIBRARY_FLAGS) \
-			-DLE_STANDALONE -DHEADLESS \
-			$(FONT_HEADERS) \
-			-I$(JDK_TOPDIR)/src/share/native/sun/font \
-			-I$(JDK_TOPDIR)/src/share/native/sun/font/layout \
-			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/awt \
-			-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-			-I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
-			-I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d \
-			-I$(JDK_TOPDIR)/src/share/native/sun/java2d
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER,\
-                SRC:=$(JDK_TOPDIR)/src/share/native/sun/font\
-		     $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/font,\
-		EXCLUDE_FILES:=$(LIBFONTMANAGER_EXCLUDE_FILES) \
-			       AccelGlyphCache.c,\
-		LANG:=C++,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBFONTMANAGER_CFLAGS_COMMON),\
-		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(BUILD_LIBFONTMANAGER_CFLAGS_COMMON),\
-		CFLAGS_posix:=$(C_O_FLAG_HI),\
-		CXXFLAGS_posix:=$(CXX_O_FLAG_HI),\
-		CFLAGS_windows=$(C_O_FLAG_NORM)\
-				-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/windows \
-				-DCC_NOEX, \
-		MAPFILE := $(BUILD_LIBFONTMANAGER_MAPFILE), \
-		LDFLAGS:=$(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_windows:=advapi32.lib user32.lib gdi32.lib awt.lib java.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) \
-				$(BUILD_LIBFONTMANAGER_FONTLIB),\
-		LDFLAGS_SUFFIX_linux:=-lawt $(LIBM) $(LIBCXX),\
-		LDFLAGS_SUFFIX_solaris:=-lawt -lawt_xawt -lc $(LIBM) $(LIBCXX),\
-		LDFLAGS_SUFFIX_macosx:=-lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libfontmanager,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX) : \
-	$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)
-
-ifneq (,$(findstring $(PLATFORM),solaris macosx))
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX) : \
-	$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX)
-endif
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-ifndef OPENJDK
-
-#    ifeq ($(PLATFORM), linux)
-#        ifeq ("$(CC_VER_MAJOR)", "3")
-#            OTHER_LDLIBS  += -Wl,-Bstatic -lgcc_eh -Wl,-Bdynamic
-#        endif                           
-#    endif
-#
-# The resulting size of the t2k lib file is (at least on linux) dependant on the order of 
-# the input .o files. Because of this the new build will differ in size to the old build.
-    BUILD_LIBT2K_CFLAGS_COMMON:=-I$(JDK_TOPDIR)/src/share/native/sun/font \
-		            -I$(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k \
-		            -I$(JDK_TOPDIR)/src/closed/share/native/sun/font \
-		            -I$(JDK_TOPDIR)/src/share/share/native/sun/font \
-		            -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/font \
-		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
-		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-		            -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d \
-		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d
-
-    $(eval $(call SetupNativeCompilation,BUILD_LIBT2K,\
-                SRC:=$(JDK_TOPDIR)/src/closed/share/native/sun/font \
-		     $(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k \
-		     $(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k/ttHints,\
-		EXCLUDE_FILES:=orion.c,\
-		LANG:=C++,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBT2K_CFLAGS_COMMON) $(C_O_FLAG_HI),\
-		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(BUILD_LIBT2K_CFLAGS_COMMON) $(CXX_O_FLAG_HI),\
-		CFLAGS_windows=-DCC_NOEX, \
-		CXXFLAGS_windows=-DCC_NOEX, \
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libt2k/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_windows:=user32.lib $(JDK_OUTPUTDIR)/objs/fontmanager.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_macosx:=$(LIBCXX) $(LIBM) -lfontmanager,\
-		LDFLAGS_SUFFIX_linux:=$(LIBCXX) $(LIBM) -lfontmanager,\
-		LDFLAGS_SUFFIX_solaris:=$(LIBCXX) $(LIBM) -lfontmanager -lawt \
-					-lawt_xawt,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libt2k,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)t2k$(SHARED_LIBRARY_SUFFIX)))
-
-    # t2k is linked against fontmanager
-    $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)t2k$(SHARED_LIBRARY_SUFFIX): \
-	$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX)
-
-    BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)t2k$(SHARED_LIBRARY_SUFFIX)
+LIBAWT_DIRS:=\
+	$(JDK_TOPDIR)/src/share/native/sun/awt \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/image \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/image/gif \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/shell \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/medialib \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/utility \
+	$(JDK_TOPDIR)/src/share/native/sun/java2d \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+	$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
+	$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
+	$(JDK_TOPDIR)/src/share/native/sun/awt/image \
+	$(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/opengl \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/x11 \
+	$(JDK_TOPDIR)/src/share/native/sun/font \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/windows \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/d3d
+
+
+LIBAWT_CFLAGS:=-D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES \
+	$(X_CFLAGS) \
+	$(foreach dir,$(LIBAWT_DIRS),-I$(dir))
+
+LIBAWT_FILES:=\
+	gifdecoder.c \
+	imageInitIDs.c \
+	img_globals.c \
+	SurfaceData.c \
+	Region.c \
+	BufImgSurfaceData.c \
+	Disposer.c \
+	Trace.c \
+	GraphicsPrimitiveMgr.c \
+	Blit.c \
+	BlitBg.c \
+	ScaledBlit.c \
+	FillRect.c \
+	FillSpans.c \
+	FillParallelogram.c \
+	DrawParallelogram.c \
+	DrawLine.c \
+	DrawRect.c \
+	DrawPolygons.c \
+	DrawPath.c \
+	FillPath.c \
+	ProcessPath.c \
+	MaskBlit.c \
+	MaskFill.c \
+	TransformHelper.c \
+	AlphaMath.c \
+	AlphaMacros.c \
+	AnyByte.c \
+	ByteBinary1Bit.c \
+	ByteBinary2Bit.c \
+	ByteBinary4Bit.c \
+	ByteIndexed.c \
+	ByteGray.c \
+	Index8Gray.c \
+	Index12Gray.c \
+	AnyShort.c \
+	Ushort555Rgb.c \
+	Ushort565Rgb.c \
+	Ushort4444Argb.c \
+	Ushort555Rgbx.c \
+	UshortGray.c \
+	UshortIndexed.c \
+	Any3Byte.c \
+	ThreeByteBgr.c \
+	AnyInt.c \
+	IntArgb.c \
+	IntArgbPre.c \
+	IntArgbBm.c \
+	IntRgb.c \
+	IntBgr.c \
+	IntRgbx.c \
+	Any4Byte.c \
+	FourByteAbgr.c \
+	FourByteAbgrPre.c \
+	BufferedMaskBlit.c \
+	BufferedRenderPipe.c \
+	ShapeSpanIterator.c \
+	SpanClipRenderer.c \
+	awt_ImageRep.c \
+	awt_ImagingLib.c \
+	awt_Mlib.c \
+	awt_parseImage.c \
+	DataBufferNative.c \
+	dither.c \
+	debug_assert.c \
+	debug_mem.c \
+	debug_trace.c \
+	debug_util.c
+
+ifneq (,$(filter $(OPENJDK_TARGET_OS), solaris linux macosx))
+	LIBAWT_FILES += awt_LoadLibrary.c initIDs.c img_colors.c
 endif
 
-##########################################################################################
-
-#
-# TODO replace with X_FLAGS / X_LIBS
-#   and add them to configure
-#
-OPENWIN_LIB := $(OPENWIN_HOME)/lib
-
-BUILD_LIBJAWT_LIB := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jawt$(SHARED_LIBRARY_SUFFIX)
-
-ifeq ($(PLATFORM), windows)
-    ifeq ($(ARCH_DATA_MODEL), 32)
-        KERNEL32_LIB := kernel32.lib
-    endif
-    $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT,\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/windows,\
-		INCLUDE_FILES:=jawt.cpp,\
-		LANG:=C++,\
-		CFLAGS:=$(CXXFLAGS_JDKLIB) $(CXX_O_FLAG_NORM) \
-			-EHsc -DUNICODE -D_UNICODE \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/windows \
-		        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-		        -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/windows, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(KERNEL32_LIB) \
-			 advapi32.lib awt.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjawt,\
-		LIB:=$(BUILD_LIBJAWT_LIB)))
-
-$(BUILD_LIBJAWT_LIB) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX): $(BUILD_LIBJAWT_LIB)
-	$(ECHO) Copying $(@F)
-	$(CP) $< $@
-
-BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX)
-
-else # PLATFORM not windows
-
-    JAWT_LIBS := -lawt
-    ifndef BUILD_HEADLESS_ONLY
-        JAWT_LIBS += -lawt_xawt
-    else
-        JAWT_LIBS += -lawt_headless
-        HEADLESS_CFLAG += -DHEADLESS
-    endif
-
-    JAWT_FILES := jawt.c
-    ifeq ($(PLATFORM), macosx)
-	JAWT_FILES := jawt.m
-	JAWT_LIBS := -lawt_lwawt
-    endif
-
-    $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT,\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/awt \
-                     $(JDK_TOPDIR)/src/macosx/native/sun/awt,\
-		INCLUDE_FILES:=$(JAWT_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM), \
-		CFLAGS_linux:=$(HEADLESS_CFLAG),\
-		CFLAGS_macosx := -I$(JDK_TOPDIR)/src/solaris/native/sun/awt ,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjawt/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -L$(OPENWIN_LIB)$(ISA_DIR),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(JAWT_LIBS),\
-		LDFLAGS_SUFFIX_solaris:=-lXrender,\
-		LDFLAGS_SUFFIX_macosx:= -framework Cocoa, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjawt,\
-		LIB:=$(BUILD_LIBJAWT_LIB)))
-
-ifndef BUILD_HEADLESS_ONLY
-$(BUILD_LIBJAWT_LIB) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX)
-else
-$(BUILD_LIBJAWT_LIB) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX)
+ifeq ($(OPENJDK_TARGET_OS),macosx)
+	LIBAWT_DIRS += $(JDK_TOPDIR)/src/macosx/native/com/apple/resources
+	LIBAWT_FILES += awt_LoadLibrary.c MacOSXResourceBundle.m
+	LIBAWT_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks
+
+	LIBAWT_MacOSXResourceBundle.m_CFLAGS:=-O0
 endif
 
-endif # PLATFORM
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jawt$(SHARED_LIBRARY_SUFFIX)
-
-
-##########################################################################################
-
-BUILD_LIBVERIFY_SRC := check_code.c check_format.c
-
-ifeq ($(PLATFORM), solaris)
-	ifneq ($(ARCH), amd64)
-		BUILD_LIBVERIFY_REORDER := $(JDK_TOPDIR)/makefiles/mapfiles/libverify/reorder-$(ARCH)
+ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
+        LIBAWT_CFLAGS += -DMLIB_ADD_SUFF
+        LIBAWT_CFLAGS += -xarch=sparcvis
+	LIBAWT_CFLAGS += $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib/vis_$(ARCH_DATA_MODEL).il
+        LIBAWT_CFLAGS += \
+            -I$(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib \
+            -I$(JDK_TOPDIR)/src/solaris/native/sun/java2d/medialib \
+            -I$(JDK_TOPDIR)/src/solaris/native/sun/java2d/loops
+
+	LIBAWT_DIRS += $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib \
+                       $(JDK_TOPDIR)/src/solaris/native/sun/java2d/loops
+
+	LIBAWT_FILES += \
+                vis_FuncArray.c           \
+                java2d_Mlib.c             \
+                mlib_ImageCreate.c        \
+                mlib_ImageZoom_NN.c       \
+                mlib_ImageCopy_Bit.c      \
+                mlib_sys.c                \
+                mlib_v_ImageClear.c       \
+                mlib_v_ImageClear_f.c     \
+                mlib_v_ImageConstXor.c    \
+                mlib_v_ImageCopy.c        \
+                mlib_v_ImageCopy_f.c      \
+                mlib_v_ImageXor.c         \
+                mlib_v_ImageZoom_NN_f.c   \
+                vis_Interp.c              \
+                vis_AlphaMacros.c         \
+                vis_AlphaMaskBlit.c       \
+                vis_AlphaMaskFill.c       \
+                vis_ByteGray.c            \
+                vis_ByteGray_FromRgb.c    \
+                vis_ByteGray_Mask.c       \
+                vis_ByteIndexed.c         \
+                vis_DrawLine.c            \
+                vis_FourByteAbgr.c        \
+                vis_IntArgb.c             \
+                vis_IntArgbPre.c          \
+                vis_IntArgbPre_Mask.c     \
+                vis_IntBgr.c              \
+                vis_IntRgb.c              \
+                vis_IntRgbx.c             \
+                vis_SrcMaskFill.c         \
+                vis_SrcOverMaskBlit.c     \
+                vis_SrcOverMaskFill.c     \
+                vis_FourByteAbgrPre.c     \
+                vis_GlyphList.c           \
+                vis_GlyphListXor.c        \
+                vis_IntArgbBm.c           \
+                vis_ThreeByteBgr.c        \
+                vis_UshortGray.c          \
+                vis_UshortGray_FromRgb.c  \
+                vis_XorBlit.c             \
+                mlib_v_ImageCopy_blk.s
+
+	ifeq ($(OPENJDK_TARGET_CPU_BITS),64)
+		LIBAWT_ASFLAGS=-P -xarch=v9a
+	else
+		LIBAWT_ASFLAGS=-P -xarch=v8plusa
 	endif
-endif
-
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBVERIFY,\
-		SRC:=$(JDK_TOPDIR)/src/share/native/common,\
-		INCLUDE_FILES:=$(BUILD_LIBVERIFY_SRC),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(SHARED_LIBRARY_FLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libverify/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_posix:=-ljvm -lc,\
-		LDFLAGS_SUFFIX_windows:=jvm.lib,\
-		REORDER := $(BUILD_LIBVERIFY_REORDER),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libverify,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)verify$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)verify$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-ifndef OPENJDK
-ifneq ($(PLATFORM), macosx)
-
-BUILD_LIBJDBCODBC_DIR     := $(JDK_OUTPUTDIR)/objs/libjdbcodbc
-BUILD_LIBJDBCODBC_NAME    := $(LIBRARY_PREFIX)JdbcOdbc$(SHARED_LIBRARY_SUFFIX)
-BUILD_LIBJDBCODBC_CFLAGS  := 
-BUILD_LIBJDBCODBC_TARGET  := $(JDK_OUTPUTDIR)/objs/$(BUILD_LIBJDBCODBC_NAME)
-BUILD_LIBJDBCODBC_LIBS    :=
-BUILD_LIBJDBCODBC_LDFLAGS :=
-
-ifeq ($(PLATFORM), windows)
-	BUILD_LIBJDBCODBC_LDFLAGS := $(LDFLAGS_JDKLIB)
-	BUILD_LIBJDBCODBC_LIBS += odbc32.lib odbccp32.lib java.lib advapi32.lib
 else
-	BUILD_LIBJDBCODBC_CFLAGS := -DUNIX
-
-#
-# This mimics "current" build system exactly. Link against fake -lodbcinst -lodbc
-#   but...those are linked with the -soname, causing the dependency to be dropped on linux (gnu ld)
-#   but kept with other linker (solaris)
-#
-# IMO very weird behaviour...very weird
-#
-	BUILD_LIBJDBCODBC_LDFLAGS += $(patsubst defs,nodefs,$(LDFLAGS_JDKLIB)) \
-				      -Xlinker -z -Xlinker nodefs
-	BUILD_LIBJDBCODBC_LIBS += -L$(BUILD_LIBJDBCODBC_DIR) -lodbcinst -lodbc
-	BUILD_LIBJDBCODBC_FAKE_LIBS := $(BUILD_LIBJDBCODBC_DIR)/$(LIBRARY_PREFIX)odbcinst$(SHARED_LIBRARY_SUFFIX) \
-                                       $(BUILD_LIBJDBCODBC_DIR)/$(LIBRARY_PREFIX)odbc$(SHARED_LIBRARY_SUFFIX)
-
-	BUILD_LIBJDBCODBC_SONAME := $(call SET_SHARED_LIBRARY_NAME,$(BUILD_LIBJDBCODBC_NAME))
-endif
-
-ifneq ($(PLATFORM), windows)
-
-$(eval $(call SetupNativeCompilation,BUILD_FAKEODBCINST,\
-		SRC:=$(JDK_OUTPUTDIR)/gensrc_c/libjdbcodbc,\
-		INCLUDE_FILES := dummyodbc1.c,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS),\
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN) $(BUILD_LIBJDBCODBC_LDFLAGS),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(BUILD_LIBJDBCODBC_SONAME),\
-		BIN:=$(BUILD_LIBJDBCODBC_DIR),\
-		LIB:=$(BUILD_LIBJDBCODBC_DIR)/$(LIBRARY_PREFIX)odbcinst$(SHARED_LIBRARY_SUFFIX)))
-
-$(eval $(call SetupNativeCompilation,BUILD_FAKEODBC,\
-		SRC:=$(JDK_OUTPUTDIR)/gensrc_c/libjdbcodbc,\
-		INCLUDE_FILES := dummyodbc2.c,\
-		LANG:=C,\
-		CFLAGS:=$(BUILD_LIBJDBCODBC_CFLAGS) $(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS),\
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN) $(BUILD_LIBJDBCODBC_LDFLAGS),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(BUILD_LIBJDBCODBC_SONAME),\
-		BIN:=$(BUILD_LIBJDBCODBC_DIR),\
-		LIB:=$(BUILD_LIBJDBCODBC_DIR)/$(LIBRARY_PREFIX)odbc$(SHARED_LIBRARY_SUFFIX)))
-
-$(BUILD_LIBJDBCODBC_FAKE_LIBS) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-$(BUILD_LIBJDBCODBC_TARGET) : $(BUILD_LIBJDBCODBC_FAKE_LIBS)
-
+	LIBAWT_FILES += MapAccelFunc.c
 endif
 
-$(eval $(call SetupNativeCompilation,BUILD_LIBJDBCODBC,\
-		SRC:=$(JDK_TOPDIR)/src/closed/share/classes/sun/jdbc/odbc,\
-		EXCLUDE_FILES := dummyodbc.c,\
-		LANG:=C,\
-		CFLAGS:=$(BUILD_LIBJDBCODBC_CFLAGS) $(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) \
-			$(SHARED_LIBRARY_FLAGS),\
-		LDFLAGS:=$(BUILD_LIBJDBCODBC_LDFLAGS) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN) $(BUILD_LIBJDBCODBC_LIBS),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(BUILD_LIBJDBCODBC_SONAME),\
-		BIN:=$(BUILD_LIBJDBCODBC_DIR),\
-		LIB:=$(BUILD_LIBJDBCODBC_TARGET)))
-
-$(BUILD_LIBJDBCODBC_TARGET) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)JdbcOdbc$(SHARED_LIBRARY_SUFFIX)
-
-endif
-endif
-
-##########################################################################################
-
-BUILD_LIBINSTRUMENT_SRC     := $(JDK_TOPDIR)/src/share/instrument \
-                               $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/io \
-                               $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/instrument
-
-BUILD_LIBINSTRUMENT_FILES   := \
-	EncodingSupport.c \
-	EncodingSupport_md.c \
-	FileSystemSupport_md.c \
-	InstrumentationImplNativeMethods.c \
-	InvocationAdapter.c \
-	JarFacade.c \
-	JPLISAgent.c \
-	JPLISAssert.c \
-	JavaExceptions.c \
-	PathCharsValidator.c \
-	Reentrancy.c \
-	Utilities.c \
-	canonicalize_md.c
-
-BUILD_LIBINSTRUMENT_DIR     := $(JDK_OUTPUTDIR)/objs/libinstrument
-BUILD_LIBINSTRUMENT_NAME    := $(LIBRARY_PREFIX)instrument$(SHARED_LIBRARY_SUFFIX)
-BUILD_LIBINSTRUMENT_CFLAGS  := -I$(JDK_TOPDIR)/src/share/instrument \
-                               -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/instrument \
-                               -I$(JDK_TOPDIR)/src/share/bin
-
-BUILD_LIBINSTRUMENT_TARGET  := $(JDK_OUTPUTDIR)/objs/$(BUILD_LIBINSTRUMENT_NAME)
-BUILD_LIBINSTRUMENT_LDFLAGS :=
-BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX :=
-
-ifeq ($(PLATFORM), windows)
-  BUILD_LIBINSTRUMENT_LDFLAGS += jli_static.lib java.lib \
-				 -export:Agent_OnAttach
-  # equivalent of strcasecmp is stricmp on Windows
-  BUILD_LIBINSTRUMENT_CFLAGS += -Dstrcasecmp=stricmp
-else
-
-ifneq (,$(findstring $(PLATFORM), macosx))
-	ifneq ($(ARCH), universal)
-		BUILD_LIBINSTRUMENT_LDFLAGS += -Wl,-all_load
-	endif
-
-	BUILD_LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/libjli_static.a
-	BUILD_LIBINSTRUMENT_LDFLAGS += -liconv
-	BUILD_LIBINSTRUMENT_LDFLAGS += -framework Cocoa -framework Security -framework ApplicationServices
-	BUILD_LIBINSTRUMENT_LDFLAGS += $(LIBZ)
-else
-	BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX += -ljli $(LIBDL)
-endif
+ifneq ($(OPENJDK_TARGET_OS),solaris)
+	LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH
 endif
 
-$(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT,\
-		SRC:=$(BUILD_LIBINSTRUMENT_SRC),\
-		INCLUDE_FILES:=$(BUILD_LIBINSTRUMENT_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        $(BUILD_LIBINSTRUMENT_CFLAGS),\
-		CFLAGS_debug := -DJPLIS_LOGGING,\
-		CFLAGS_release := -DNO_JPLIS_LOGGING,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libinstrument/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN)\
-			 $(call SET_SHARED_LIBRARY_ORIGIN,jli) \
-                         $(BUILD_LIBINSTRUMENT_LDFLAGS),\
-		LDFLAGS_SUFFIX:=$(LIBZ) $(BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX),\
-		BIN:=$(BUILD_LIBINSTRUMENT_DIR),\
-		LIB:=$(BUILD_LIBINSTRUMENT_TARGET)))
-
-$(BUILD_LIBINSTRUMENT_TARGET) : $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX)
-$(BUILD_LIBINSTRUMENT_TARGET) : $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)
-$(BUILD_LIBINSTRUMENT_TARGET) : $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX)
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(BUILD_LIBINSTRUMENT_NAME)
-
-##########################################################################################
-
-BUILD_LIBMANAGEMENT_SRC := $(JDK_TOPDIR)/src/share/native/sun/management \
-                           $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/management \
-                           $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/com/sun/management
-
-BUILD_LIBMANAGEMENT_EXCLUDES :=
-
-BUILD_LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/management
-
-ifneq ($(PLATFORM), windows)
-	BUILD_LIBMANAGEMENT_EXCLUDES += OperatingSystem_md.c
-else
-	BUILD_LIBMANAGEMENT_EXCLUDES += UnixOperatingSystem_md.c
-endif
-
-ifneq ($(PLATFORM),solaris)
-	BUILD_LIBMANAGEMENT_EXCLUDES += SolarisOperatingSystem.c
-endif
-
-ifneq ($(PLATFORM),linux)
-	BUILD_LIBMANAGEMENT_EXCLUDES += LinuxOperatingSystem.c
-endif
-
-ifneq ($(PLATFORM),macosx)
-	BUILD_LIBMANAGEMENT_EXCLUDES += MacosxOperatingSystem.c
+LIBAWT_LANG:=C
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+	LIBAWT_FILES += AccelGlyphCache.c \
+			ShaderList.c \
+			CmdIDList.cpp \
+			Hashtable.cpp \
+			GDIHashtable.cpp \
+			Devices.cpp \
+			ObjectList.cpp \
+			GDIBlitLoops.cpp \
+			GDIRenderer.cpp \
+			GDIWindowSurfaceData.cpp \
+			WindowsFlags.cpp \
+			WPrinterJob.cpp \
+			awt_%.cpp \
+			D3DBlitLoops.cpp \
+			D3DBufImgOps.cpp \
+			D3DContext.cpp \
+			D3DGlyphCache.cpp \
+			D3DGraphicsDevice.cpp \
+			D3DMaskBlit.cpp \
+			D3DMaskCache.cpp \
+			D3DMaskFill.cpp \
+			D3DPipelineManager.cpp \
+			D3DPaints.cpp \
+			D3DRenderer.cpp \
+			D3DRenderQueue.cpp \
+			D3DResourceManager.cpp \
+			D3DSurfaceData.cpp \
+			D3DTextRenderer.cpp \
+			D3DVertexCacher.cpp \
+			ShellFolder2.cpp \
+			ThemeReader.cpp \
+			ComCtl32Util.cpp \
+			DllUtil.cpp \
+			initIDs.cpp \
+			MouseInfo.cpp \
+			rect.c
+	LIBAWT_LANG:=C++
+	LIBAWT_CFLAGS += $(GX_OPTION) -DUNICODE -D_UNICODE
+	ifeq ($(ARCH_DATA_MODEL), 64)
+		LIBAWT_CFLAGS += -DMLIB_OS64BIT
+	endif
+
+	ifdef OPENJDK
+		LIBAWT_RC_FLAGS:=-i "$(JDK_TOPDIR)/src/windows/resource/icons"
+	else
+		LIBAWT_RC_FLAGS:=-i "$(JDK_TOPDIR)/src/closed/windows/native/sun/windows"
+	endif
+	LIBAWT_VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/native/sun/windows/awt.rc
 endif
 
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT,\
-		SRC:=$(BUILD_LIBMANAGEMENT_SRC),\
-		EXCLUDE_FILES:=$(BUILD_LIBMANAGEMENT_EXCLUDES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(SHARED_LIBRARY_FLAGS) $(BUILD_LIBMANAGEMENT_CFLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libmanagement/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_windows := java.lib jvm.lib advapi32.lib psapi.lib,\
-		LDFLAGS_solaris := -lkstat,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libmanagement,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)management$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)management$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)management$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-BUILD_LIBHPROF_SRC := $(JDK_TOPDIR)/src/share/demo/jvmti/hprof $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/demo/jvmti/hprof
-BUILD_LIBHPROF_CFLAGS := -I$(JDK_TOPDIR)/src/share/demo/jvmti/hprof \
-                         -I$(JDK_TOPDIR)/src/share/npt \
-                         -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/npt \
-                         -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo
-
-BUILD_LIBHPROF_LDFLAGS :=
-
-ifeq ($(PLATFORM),solaris)
-     BUILD_LIBHPROF_LDFLAGS += -lsocket -lnsl
+ifeq ($(MILESTONE), internal)
+	LIBAWT_CFLAGS += -DINTERNAL_BUILD
 endif
 
-ifneq ($(PLATFORM),windows)
-     BUILD_LIBHPROF_LDFLAGS += $(LIBDL)
+LIBAWT_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt/mapfile-vers
+ifeq ($(OPENJDK_TARGET_OS),linux)
+	LIBAWT_MAPFILE:=
 endif
 
-$(eval $(call SetupNativeCompilation,BUILD_LIBHPROF,\
-		SRC:=$(BUILD_LIBHPROF_SRC),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HIGHEST) $(SHARED_LIBRARY_FLAGS) \
-                         $(BUILD_LIBHPROF_CFLAGS),\
-		CFLAGS_debug := -DHPROF_LOGGING,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libhprof/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_windows:=wsock32.lib winmm.lib advapi32.lib,\
-		LDFLAGS_SUFFIX:=$(BUILD_LIBHPROF_LDFLAGS),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libhprof,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)hprof$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)hprof$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJAVA_CRW_DEMO,\
-		SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjava_crw_demo/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjava_crw_demo,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)java_crw_demo$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java_crw_demo$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBNPT,\
-		SRC:=$(JDK_TOPDIR)/src/share/npt $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/npt,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        -I$(JDK_TOPDIR)/src/share/npt \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/npt,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libnpt/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_macosx := -liconv,\
-		LDFLAGS_SUFFIX_windows := -export:nptInitialize -export:nptTerminate,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libnpt,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX)
+$(eval $(call SetupNativeCompilation,BUILD_LIBAWT,\
+		LIBRARY:=awt,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(LIBAWT_DIRS),\
+		INCLUDE_FILES:=$(LIBAWT_FILES),\
+		LANG:=$(LIBAWT_LANG),\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBAWT_CFLAGS),\
+		ASFLAGS:=$(LIBAWT_ASFLAGS),\
+		MAPFILE:=$(LIBAWT_MAPFILE), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_windows:=advapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
+				 imm32.lib ole32.lib uuid.lib shell32.lib \
+				 comdlg32.lib winmm.lib comctl32.lib \
+				 shlwapi.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib \
+				 /DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
+				 /DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
+				 /DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
+				 /DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
+				 /DELAYLOAD:comctl32.dll /DELAYLOAD:shlwapi.dll,\
+		LDFLAGS_macosx:=-lmlib_image \
+                                 -framework Cocoa \
+				 -framework OpenGL \
+				 -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+				 -framework JavaNativeFoundation \
+				 -framework JavaRuntimeSupport \
+				 -framework ApplicationServices \
+				 -framework AudioToolbox,\
+		LDFLAGS_solaris:=-R/usr/dt/lib$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR),\
+		LDFLAGS_SUFFIX_posix:=-ljvm $(LIBM) -ljava $(LIBDL),\
+		VERSIONINFO_RESOURCE:=$(LIBAWT_VERSIONINFO_RESOURCE),\
+		RC_FLAGS:=$(RC_FLAGS) $(LIBAWT_RC_FLAGS) \
+			  /D "JDK_FNAME=awt.dll" \
+			  /D "JDK_INTERNAL_NAME=awt" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt))
+
+$(BUILD_LIBAWT) : $(BUILD_LIBJAVA)
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+$(BUILD_LIBAWT) : $(BUILD_LIBMLIB_IMAGE)
+endif
+
+BUILD_LIBRARIES += $(BUILD_LIBAWT)
 
 ##########################################################################################
 
-BUILD_LIBNIO_SRC := \
-        $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/nio \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/nio/ch \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/nio/fs
-
-BUILD_LIBNIO_CFLAGS := \
-	-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch \
-	-I$(JDK_TOPDIR)/src/share/native/java/io \
-	-I$(JDK_TOPDIR)/src/share/native/java/net \
-        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/net
-
-BUILD_LIBNIO_FILES := \
-        DatagramChannelImpl.c \
-        DatagramDispatcher.c \
-	FileChannelImpl.c \
-	FileDispatcherImpl.c \
-	FileKey.c \
-	IOUtil.c \
-        MappedByteBuffer.c \
-	Net.c \
-	ServerSocketChannelImpl.c \
-	SocketChannelImpl.c \
-	SocketDispatcher.c
-
-ifeq ($(PLATFORM), windows)
-	BUILD_LIBNIO_FILES += \
-		Iocp.c \
-		RegistryFileTypeDetector.c \
-		WindowsAsynchronousFileChannelImpl.c \
-		WindowsAsynchronousServerSocketChannelImpl.c \
-		WindowsAsynchronousSocketChannelImpl.c \
-		WindowsNativeDispatcher.c \
-	        WindowsSelectorImpl.c
-endif
-
-ifeq ($(PLATFORM), linux)
-	BUILD_LIBNIO_LDFLAGS_SUFFIX := -lpthread $(LIBDL)
-	BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-linux
-	BUILD_LIBNIO_FILES += \
-		EPoll.c \
-		EPollArrayWrapper.c \
-		EPollPort.c \
-		InheritedChannel.c \
-		NativeThread.c \
-	        PollArrayWrapper.c \
-		UnixAsynchronousServerSocketChannelImpl.c \
-		UnixAsynchronousSocketChannelImpl.c \
-		GnomeFileTypeDetector.c \
-		LinuxNativeDispatcher.c \
-		LinuxWatchService.c \
-		UnixCopyFile.c \
-		UnixNativeDispatcher.c
-endif
-
-ifeq ($(PLATFORM), macosx)
-	BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-bsd
-	BUILD_LIBNIO_SRC += $(JDK_TOPDIR)/src/macosx/native/sun/nio/ch
-	BUILD_LIBNIO_FILES += \
-		InheritedChannel.c \
-		NativeThread.c \
-	        PollArrayWrapper.c \
-		UnixAsynchronousServerSocketChannelImpl.c \
-		UnixAsynchronousSocketChannelImpl.c \
-		GnomeFileTypeDetector.c \
-		BsdNativeDispatcher.c \
-		UnixCopyFile.c \
-		UnixNativeDispatcher.c \
-		KQueue.c \
-		KQueuePort.c \
-		KQueueArrayWrapper.c
-endif
-
-ifeq ($(PLATFORM), solaris)
-	BUILD_LIBNIO_LDFLAGS_SUFFIX := $(LIBDL)
-	BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-solaris
-	BUILD_LIBNIO_FILES += \
-		DevPollArrayWrapper.c \
-		InheritedChannel.c \
-		NativeThread.c \
-		PollArrayWrapper.c \
-		SolarisEventPort.c \
-		UnixAsynchronousServerSocketChannelImpl.c \
-		UnixAsynchronousSocketChannelImpl.c \
-		GnomeFileTypeDetector.c \
-		SolarisNativeDispatcher.c \
-		SolarisWatchService.c \
-		UnixCopyFile.c \
-		UnixNativeDispatcher.c
-endif
-
-BUILD_LIBNIO_LDFLAGS :=
-ifeq ($(PLATFORM),windows)
-	BUILD_LIBNIO_LDFLAGS += \
-		java.lib net.lib advapi32.lib jvm.lib ws2_32.lib\
-		$(JDK_OUTPUTDIR)/objs/libjava/io_util.obj \
-		$(JDK_OUTPUTDIR)/objs/libjava/FileDescriptor_md.obj
-endif
-
-ifeq ($(PLATFORM), linux)
-	BUILD_LIBNIO_LDFLAGS_SUFFIX += -ljava -lnet -lpthread $(LIBDL)
-endif
-ifeq ($(PLATFORM), macosx)
-	BUILD_LIBNIO_LDFLAGS_SUFFIX += -ljava -lnet -pthread
-endif
-
-ifeq ($(PLATFORM), solaris)
-	BUILD_LIBNIO_LDFLAGS_SUFFIX += $(JVMLIB) $(LIBSOCKET) -lposix4 $(LIBDL) -lsendfile \
-				       -ljava -lnet
-endif # PLATFORM
-
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBNIO,\
-		SRC:=$(BUILD_LIBNIO_SRC),\
-		INCLUDE_FILES := $(BUILD_LIBNIO_FILES), \
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(SHARED_LIBRARY_FLAGS) \
-                        $(BUILD_LIBNIO_CFLAGS),\
-		MAPFILE := $(BUILD_LIBNIO_MAPFILE), \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(BUILD_LIBNIO_LDFLAGS) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(BUILD_LIBNIO_LDFLAGS_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libnio,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)net$(SHARED_LIBRARY_SUFFIX) $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-
-##########################################################################################
-
-LIBNET_SRC_DIRS := $(JDK_TOPDIR)/src/share/native/java/net \
-                   $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/net \
-                   $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/net/dns \
-                   $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/net/www/protocol/http/ntlm \
-                   $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/net/sdp \
-                   $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/net/spi
-
-LIBNET_CFLAGS := $(foreach dir,$(LIBNET_SRC_DIRS),-I$(dir))
-
-LIBNET_EXCLUDE_FILES:=
-ifneq ($(PLATFORM),linux)
-	LIBNET_EXCLUDE_FILES += linux_close.c
-endif
-
-ifneq ($(PLATFORM),macosx)
-	LIBNET_EXCLUDE_FILES += bsd_close.c
-endif
-
-ifeq ($(PLATFORM),windows)
-	LIBNET_EXCLUDE_FILES += PlainSocketImpl.c PlainDatagramSocketImpl.c SdpSupport.c
-else
-	LIBNET_EXCLUDE_FILES += TwoStacksPlainSocketImpl.c DualStackPlainSocketImpl.c \
-                                TwoStacksPlainDatagramSocketImpl.c DualStackPlainDatagramSocketImpl.c \
-				NTLMAuthSequence.c NetworkInterface_winXP.c
-endif
-
-LIBNET_LDFLAGS_SUFFIX :=
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBNET,\
-		SRC:=$(LIBNET_SRC_DIRS),\
-		EXCLUDE_FILES := $(LIBNET_EXCLUDE_FILES), \
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        $(LIBNET_CFLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libnet/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBNET_LDFLAGS_SUFFIX),\
-		LDFLAGS_SUFFIX_solaris := -lnsl -lsocket $(LIBDL) ,\
-		LDFLAGS_SUFFIX_linux := $(LIBDL) -lpthread ,\
-		LDFLAGS_SUFFIX_windows := ws2_32.lib $(JVMLIB) secur32.lib iphlpapi.lib \
-					  delayimp.lib java.lib jvm.lib advapi32.lib \
-                                          /DELAYLOAD:secur32.dll /DELAYLOAD:iphlpapi.dll, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libnet,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)net$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)net$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)net$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/lib/net.properties: $(JDK_TOPDIR)/src/share/lib/net.properties
-	$(ECHO) Copying $(@F)
-	$(MKDIR) -p $(@D)
-	$(CP) $< $@
-
-COPY_FILES += $(JDK_OUTPUTDIR)/lib/net.properties
-
-ifeq ($(PLATFORM), solaris)
-$(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${LEGACY_HOST_OS_API}/lib/sdp/sdp.conf.template
-	$(ECHO) Copying $(@F)
-	$(MKDIR) -p $(@D)
-	$(CP) $< $@
-
-COPY_FILES += $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template
-endif
-
-##########################################################################################
-
-LIBJAVA_SRC_DIRS := $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/lang \
-		$(JDK_TOPDIR)/src/share/native/java/lang \
-		$(JDK_TOPDIR)/src/share/native/java/lang/ref \
-		$(JDK_TOPDIR)/src/share/native/java/lang/reflect \
-		$(JDK_TOPDIR)/src/share/native/java/io \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/io \
-		$(JDK_TOPDIR)/src/share/native/java/nio \
-		$(JDK_TOPDIR)/src/share/native/java/security \
-		$(JDK_TOPDIR)/src/share/native/common \
-		$(JDK_TOPDIR)/src/share/native/sun/misc \
-		$(JDK_TOPDIR)/src/share/native/sun/reflect \
-		$(JDK_TOPDIR)/src/share/native/java/sql \
-		$(JDK_TOPDIR)/src/share/native/java/util \
-		$(JDK_TOPDIR)/src/share/native/java/util/concurrent/atomic \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/common \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/java/util \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/provider \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/io
-
-LIBJAVA_CFLAGS := $(foreach dir,$(LIBJAVA_SRC_DIRS),-I$(dir)) \
-		  -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \
-                  -DARCHPROPNAME='"$(ARCH)"'
-
-LIBJAVA_CFLAGS += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
-                  -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
-                  -DJDK_MICRO_VERSION='"$(JDK_MICRO_VERSION)"' \
-                  -DJDK_BUILD_NUMBER='"$(JDK_BUILD_NUMBER)"' 
-
-ifneq (,$(JDK_UPDATE_VERSION))
-	LIBJAVA_CFLAGS += -DJDK_UPDATE_VERSION='"$(JDK_UPDATE_VERSION)"'
-endif
-
-LIBJAVA_EXCLUDE_FILES:= check_code.c check_format.c
-
-ifneq ($(PLATFORM),macosx)
-	LIBJAVA_EXCLUDE_FILES += java_props_macosx.c
-else
-	BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c
-endif
-
-ifeq ($(PLATFORM),windows)
-        LIBJAVA_EXCLUDE_FILES += \
-		UNIXProcess_md.c \
-		UnixFileSystem_md.c \
-		FileSystemPreferences.c
-else
-	LIBJAVA_EXCLUDE_FILES += \
-		ProcessImpl_md.c \
-		Win32FileSystem_md.c \
-		WinNTFileSystem_md.c \
-		dirent_md.c \
-		WindowsPreferences.c \
-		sun/security/provider/WinCAPISeedGenerator.c \
-		sun/io/Win32ErrorMode.c
-endif
-
-ifeq ($(PLATFORM), solaris)
-    ifneq ($(ARCH), amd64)
-        LIBJAVA_REORDER := $(JDK_TOPDIR)/makefiles/mapfiles/libjava/reorder-$(ARCH)
-    endif
-endif
-
-LIBJAVA_FDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
-LIBJAVA_VERIFY := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)verify$(STATIC_LIBRARY_SUFFIX)
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJAVA,\
-		SRC:=$(LIBJAVA_SRC_DIRS),\
-		EXCLUDES := fdlibm/src zip, \
-		EXCLUDE_FILES := $(LIBJAVA_EXCLUDE_FILES), \
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(SHARED_LIBRARY_FLAGS) \
-                        $(LIBJAVA_CFLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjava/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_windows:=-export:winFileHandleOpen -export:handleLseek \
-				 $(LIBJAVA_FDLIBM) $(LIBJAVA_VERIFY) jvm.lib \
-				 shell32.lib delayimp.lib /DELAYLOAD:shell32.dll \
-				 advapi32.lib,\
-		LDFLAGS_SUFFIX_posix:=-ljvm -lverify, \
-		LDFLAGS_SUFFIX_solaris := -lnsl -lsocket -lscf $(LIBDL) $(LIBJAVA_FDLIBM) -lc,\
-		LDFLAGS_SUFFIX_linux := $(LIBDL) $(LIBJAVA_FDLIBM),\
-		LDFLAGS_SUFFIX_macosx := $(LIBJAVA_FDLIBM) \
-                                         -framework CoreFoundation \
-                                         -framework Security -framework SystemConfiguration, \
-		REORDER := $(LIBJAVA_REORDER), \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjava,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) : $(LIBJLI_BINARY)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)verify$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) : $(LIBJAVA_FDLIBM)
-
-##########################################################################################
-
-BUILD_LIBJLI_SRC_DIRS := $(JDK_TOPDIR)/src/share/bin $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/bin
-BUILD_LIBJLI_CFLAGS := $(foreach dir,$(BUILD_LIBJLI_SRC_DIRS),-I$(dir))
-
-BUILD_LIBJLI_FILES := \
-	java.c \
-	splashscreen_stubs.c \
-	parse_manifest.c \
-	version_comp.c \
-	wildcard.c \
-	jli_util.c
-
-ifeq ($(JVM_VARIANT_ZERO), true)
-	ERGO_FAMILY := zero
-else # !ZERO_BUILD
-	ifneq (,$(findstring $(ARCH), amd64 x86_64))
-		ERGO_FAMILY := i586
-	else # !X86 FAMILY
-		ERGO_FAMILY := $(ARCH)
-	endif #ARCH_FAMILY
-endif # ZERO_BUILD
-
-ifeq ($(PLATFORM), macosx)
-	BUILD_LIBJLI_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/bin
-	BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/bin
-	BUILD_LIBJLI_FILES += java_md_common.c java_md_macosx.c
-
-	BUILD_LIBJLI_java_md_macosx.c_CFLAGS := -x objective-c
-	BUILD_LIBJLI_A_java_md_macosx.c_CFLAGS := -x objective-c
-endif
-
-ifeq ($(PLATFORM), windows)
-	BUILD_LIBJLI_FILES += java_md.c
-else ifneq ($(PLATFORM), macosx)
-
-	BUILD_LIBJLI_FILES += java_md_common.c
-	BUILD_LIBJLI_FILES += java_md_solinux.c ergo.c 
-
-	ERGO_ARCH_FILE = ergo_$(ERGO_FAMILY).c
-
-        # if the architecture specific ergo file exists then
-        # use it, else use the generic definitions from ergo.c
-	ifneq ($(wildcard $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/bin/$(ERGO_ARCH_FILE)),)
-		BUILD_LIBJLI_FILES += $(ERGO_ARCH_FILE)
-	else # !ERGO_ARCH_FILE
-		BUILD_LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO
-	endif # ERGO_ARCH_FILE
-endif #WINDOWS
-
-# Names of arch directories
-BUILD_LIBJLI_CFLAGS += -DLIBARCHNAME='"$(LIBARCH)"'
-ifeq ($(PLATFORM), solaris)
-	ifneq (,$(findstring $(ARCH),sparc))
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH32NAME='"sparc"'
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH64NAME='"sparcv9"'
-	else
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH32NAME='"i386"'
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH64NAME='"amd64"'
-	endif
-endif # PLATFORM
-
-ifeq ($(PLATFORM), macosx)
-	BUILD_LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
-endif
-
-ifneq ($(USE_EXTERNAL_LIBZ),true)
-	BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
-	BUILD_LIBJLI_CFLAGS += $(LIBZ_INCLUDE)
-	BUILD_LIBJLI_FILES += \
-		inflate.c \
-		inftrees.c \
-		inffast.c \
-		zadler32.c \
-		zcrc32.c \
-		zutil.c
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJLI,\
-		SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
-		INCLUDE_FILES := $(BUILD_LIBJLI_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(SHARED_LIBRARY_FLAGS) $(BUILD_LIBJLI_CFLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjli/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX := $(LIBZ),\
-		LDFLAGS_SUFFIX_posix := $(LIBDL) -lc,\
-		LDFLAGS_SUFFIX_linux := -lpthread,\
-		LDFLAGS_SUFFIX_windows := \
-			-export:JLI_Launch \
-			-export:JLI_ManifestIterate \
-			-export:JLI_SetTraceLauncher \
-			-export:JLI_ReportErrorMessage \
-			-export:JLI_ReportErrorMessageSys \
-			-export:JLI_ReportMessage \
-			-export:JLI_ReportExceptionDescription \
-			advapi32.lib \
-			comctl32.lib \
-			user32.lib,\
-		LDFLAGS_SUFFIX_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjli,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)))
-
-ifeq ($(HOST_OS), windows)
-    LIBJLI_BINARY := $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)
-else
-    LIBJLI_BINARY := $(INSTALL_LIBRARIES_HERE)/jli/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)
-
-    $(LIBJLI_BINARY) : $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)
-	$(MKDIR) -p $(@D)
-	$(ECHO) Copying $(@F)
-	$(CP) $< $@
-endif
-BUILD_LIBRARIES += $(LIBJLI_BINARY)
-
-# On windows, the static library has the same suffix as the import library created by
-# with the shared library, so the static library is given a different name. No harm
-# in doing it for all platform to reduce complexity.
-ifneq ($(HOST_OS),macosx)
-    $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_STATIC,\
-		SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
-		INCLUDE_FILES := $(BUILD_LIBJLI_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(STATIC_LIBRARY_FLAGS) $(BUILD_LIBJLI_CFLAGS),\
-		ARFLAGS:=$(ARFLAGS),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjli_static,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX)))
-else
-    #
-    # On macosx they do partial (incremental) linking of fdlibm
-    #   code it here...rather than add support to NativeCompilation
-    #   as this is first time I see it
-    $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_A,\
-		SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
-		INCLUDE_FILES := $(BUILD_LIBJLI_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_HI) $(BUILD_LIBJLI_CFLAGS),\
-		LDFLAGS := -nostdlib -r,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjli_static,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX)))
-endif
-
-BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX)
-
-##########################################################################################
-
-ifndef OPENJDK
-ifndef JAVASE_EMBEDDED
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBJFR,\
-		SRC:=$(JDK_TOPDIR)/src/closed/share/native/oracle/jfr,\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        -I$(JDK_TOPDIR)/src/closed/share/javavm/export, \
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjfr/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjfr,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jfr$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jfr$(SHARED_LIBRARY_SUFFIX)
-
-endif
-endif
-
-##########################################################################################
-
-ifndef OPENJDK
-
-BUILD_LIBKCMS_EXCLUDE_FILES :=
-ifeq ($(PLATFORM),windows)
-	BUILD_LIBKCMS_EXCLUDE_FILES += ukcpmgr.c unixmem.c
-else
-	BUILD_LIBKCMS_EXCLUDE_FILES += cmmdll.c registry.c spxffile.c sysinfo.c winmem.c wkcpmgr.c
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBKCMS,\
-		SRC:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms,\
-		LANG:=C,\
-		EXCLUDE_FILES := $(BUILD_LIBKCMS_EXCLUDE_FILES),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST,\
-		CFLAGS_linux := -Wno-missing-field-initializers,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libkcms/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_linux := -lpthread,\
-		LDFLAGS_SUFFIX_windows := java.lib advapi32.lib user32.lib version.lib, \
-		LDFLAGS_SUFFIX:= -lm $(LDFLAGS_JDKLIB_SUFFIX),\
-		VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libkcms,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)kcms$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)kcms$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)kcms$(SHARED_LIBRARY_SUFFIX)
-
-endif
-
-##########################################################################################
-
-ifndef OPENJDK
-ifeq ($(PLATFORM), solaris)
-ifneq ($(ARCH), amd64)
-
-ifeq ($(shell if test "$(OS_VERSION_MAJOR)" -eq 5 -a "$(OS_VERSION_MINOR)" -le 10; then $(ECHO) ok; fi), ok)
-
-SUNWJDGA_MAPFILE :=
-ifneq (,$(findstring $(ARCH),sparc))
-	SUNWJDGA_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjdga/mapfile-vers
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBSUNWJDGA, \
-		SRC:=$(JDK_TOPDIR)/src/solaris/native/sun/jdga, \
-		LANG:=C, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-			-I$(JDK_TOPDIR)/src/share/javavm/export \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/javavm/export \
-			-I$(OPENWIN_HOME)/include, \
-		MAPFILE := $(SUNWJDGA_MAPFILE), \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX:= -L$(OPENWIN_LIB)$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR) -ldga -lX11 $(LIBDL) -lc, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libsunwjdga, \
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)sunwjdga$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)sunwjdga$(SHARED_LIBRARY_SUFFIX)
-
-endif
-endif
-endif
-endif
-
-##########################################################################################
-
-ifeq ($(BUILD_HEADLESS), true)
-ifneq ($(PLATFORM), windows)
-
 # TODO!!
-X11_PATH := /usr/X11R6
-
-LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/share/native/sun/font \
-                        $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
-			$(JDK_TOPDIR)/src/solaris/native/sun/font \
-			$(JDK_TOPDIR)/src/solaris/native/sun/awt \
-			$(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
-			$(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
-
-LIBAWT_HEADLESS_CFLAGS := -DHEADLESS=true \
-                          -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
-			  $(CUPS_CFLAGS) \
-			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-			  -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d \
-			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
-			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
-			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-			  -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/jdga \
-                          $(foreach dir,$(LIBAWT_HEADLESS_DIRS),-I$(dir))
-
-LIBAWT_HEADLESS_FILES := \
-	awt_Font.c \
-	HeadlessToolkit.c \
-	fontpath.c \
-	VDrawingArea.c \
-	X11Color.c \
-	X11Renderer.c \
-	X11PMBlitLoops.c \
-	X11SurfaceData.c \
-	X11FontScaler_md.c \
-	X11TextRenderer_md.c \
-        OGLBlitLoops.c \
-        OGLBufImgOps.c \
-        OGLContext.c \
-        OGLFuncs.c \
-        OGLMaskBlit.c \
-        OGLMaskFill.c \
-        OGLPaints.c \
-        OGLRenderQueue.c \
-        OGLRenderer.c \
-        OGLSurfaceData.c \
-        OGLTextRenderer.c \
-        OGLVertexCache.c \
-        GLXGraphicsConfig.c \
-        GLXSurfaceData.c \
-        AccelGlyphCache.c \
-	CUPSfuncs.c
-
-LIBAWT_HEADLESS_LDFLAGS_SUFFIX := $(LDFLAGS_JDKLIB_SUFFIX) -lawt -lm
-
-LIBAWT_HEADLESS_REORDER := 
-ifeq ($(PLATFORM), solaris)
-	ifneq ($(ARCH), amd64)
-		LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/reorder-$(ARCH)
-	endif
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS,\
-		SRC:=$(LIBAWT_HEADLESS_DIRS),\
-		INCLUDE_FILES := $(LIBAWT_HEADLESS_FILES),\
-		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) $(LIBAWT_HEADLESS_CFLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		REORDER := $(LIBAWT_HEADLESS_REORDER), \
-		LDFLAGS_SUFFIX := $(LIBAWT_HEADLESS_LDFLAGS_SUFFIX),\
-		LDFLAGS_SUFFIX_posix := $(LIBDL),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libawt_headless,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX) : \
-	$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX)
-
-endif
-endif
-
-##########################################################################################
-
-ifneq ($(PLATFORM), windows)
+# Even though this variable as a general name, it is
+# only used on macos, in fontpath.c, as prefix for where to find fonts.
+#
+# It's used for libawt_headless _and_ libawt_xawt
+#
+X11_PATH:=/usr/X11R6
+
+ifneq ($(OPENJDK_TARGET_OS), windows)
 ifndef BUILD_HEADLESS_ONLY
 
-LIBAWT_XAWT_DIRS := \
+LIBAWT_XAWT_DIRS:=\
 		$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
 		$(JDK_TOPDIR)/src/share/native/sun/awt/utility \
 		$(JDK_TOPDIR)/src/share/native/sun/font \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/font \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/font \
 		$(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/awt \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/opengl \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/x11 \
-		$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/xawt \
-
-LIBAWT_XAWT_CFLAGS := -DXAWT -DXAWT_HACK \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/opengl \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/x11 \
+		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/xawt \
+
+LIBAWT_XAWT_CFLAGS:=-DXAWT -DXAWT_HACK \
         -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
 	$(CUPS_CFLAGS) \
 	$(foreach dir,$(LIBAWT_XAWT_DIRS),-I$(dir)) \
 	-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-	-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d \
+	-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
 	-I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
 	-I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
 	-I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
 	-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
 	-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-	-I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/jdga
-
-ifeq ($(PLATFORM),solaris)
+	-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/jdga
+
+ifeq ($(OPENJDK_TARGET_OS),solaris)
 	LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15
 endif
 
@@ -1834,7 +756,7 @@
 	LIBAWT_XAWT_CFLAGS += -DINTERNAL_BUILD
 endif
 
-LIBAWT_XAWT_FILES := \
+LIBAWT_XAWT_FILES:=\
 	XlibWrapper.c \
 	XWindow.c \
 	XToolkit.c \
@@ -1891,40 +813,1505 @@
 	XRSurfaceData.c \
 	XRBackendNative.c
 
-LIBAWT_XAWT_LDFLAGS_SUFFIX := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi  -ljava -lverify -ljvm -lc
-
-ifeq ($(PLATFORM), linux)
+LIBAWT_XAWT_LDFLAGS_SUFFIX:=$(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi  -ljava -ljvm -lc
+
+ifeq ($(OPENJDK_TARGET_OS), linux)
 	LIBAWT_XAWT_LDFLAGS_SUFFIX += -lpthread
 endif
 
-ifeq ($(PLATFORM), macosx)
+ifeq ($(OPENJDK_TARGET_OS), macosx)
 	LIBAWT_XAWT_LDFLAGS_SUFFIX += -lpthread
 endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_XAWT,\
+		LIBRARY:=awt_xawt,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBAWT_XAWT_DIRS),\
-		INCLUDE_FILES := $(LIBAWT_XAWT_FILES),\
+		INCLUDE_FILES:=$(LIBAWT_XAWT_FILES),\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) $(LIBAWT_XAWT_CFLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) \
                         $(X_CFLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libawt_xawt/mapfile-vers, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_xawt/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN) \
 			 $(X_LIBS),\
-		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -L$(OPENWIN_LIB)$(ISA_DIR) \
-				 -R$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR) \
+		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -L$(OPENWIN_HOME)/lib$(ISA_DIR) \
+				 -R$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -R$(OPENWIN_HOME)/lib$(ISA_DIR) \
 				 -R/usr/dt/lib$(ISA_DIR),\
-		LDFLAGS_SUFFIX := $(LIBAWT_XAWT_LDFLAGS_SUFFIX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libawt_xawt,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX) : \
-	$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX) : \
-	$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX:=$(LIBAWT_XAWT_LDFLAGS_SUFFIX),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_xawt))
+
+$(BUILD_LIBAWT_XAWT) : $(BUILD_LIBJAVA)
+
+$(BUILD_LIBAWT_XAWT) : $(BUILD_LIBAWT)
+
+BUILD_LIBRARIES += $(BUILD_LIBAWT_XAWT)
+
+endif
+endif
+
+##########################################################################################
+
+BUILD_LIBZIP_FILES:=\
+        CRC32.c \
+	Adler32.c \
+	Deflater.c \
+	Inflater.c \
+	ZipFile.c \
+	zip_util.c
+
+ifeq ($(USE_EXTERNAL_LIBZ),true)
+	LIBZ:=-lz
+else
+BUILD_LIBZIP_FILES += \
+	compress.c \
+	deflate.c \
+	gzclose.c \
+	gzlib.c \
+	gzread.c \
+	gzwrite.c \
+	infback.c \
+	inffast.c \
+	inflate.c \
+	inftrees.c \
+	trees.c \
+	uncompr.c \
+	zadler32.c \
+	zcrc32.c \
+	zutil.c
+LIBZ_INCLUDE:=-I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
+endif
+
+BUILD_LIBZIP_REORDER:=
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+    ifneq ($(ARCH), amd64)
+        BUILD_LIBZIP_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libzip/reorder-$(ARCH)
+    endif
+endif
+
+ifeq ($(LIBZIP_CAN_USE_MMAP), true)
+     BUILD_LIBZIP_MMAP:=-DUSE_MMAP
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBZIP,\
+                LIBRARY:=zip,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/java/util/zip \
+                     $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5,\
+		INCLUDE_FILES:=$(BUILD_LIBZIP_FILES), \
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        $(LIBZ_INCLUDE) \
+		        -I$(JDK_TOPDIR)/src/share/native/java/io \
+                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/io,\
+		CFLAGS_posix:=$(BUILD_LIBZIP_MMAP) -UDEBUG,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libzip/mapfile-vers, \
+		REORDER:=$(BUILD_LIBZIP_REORDER), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(EXPORT_ZIP_FUNCS), \
+		LDFLAGS_winapi:=-export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \
+                                -export:ZIP_ReadEntry -export:ZIP_GetNextEntry jvm.lib \
+                                $(WIN_JAVA_LIB),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBZ),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libzip))
+
+$(BUILD_LIBZIP) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBZIP)
+
+##########################################################################################
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK,\
+		LIBRARY:=unpack, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/java/util/jar/pack,\
+		EXCLUDE_FILES:=main.cpp,\
+		LANG:=C++,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CXXFLAGS_JDKLIB) \
+			 -DNO_ZLIB -DUNPACK_JNI -DFULL,\
+		CFLAGS_release:=-DPRODUCT,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libunpack/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB)\
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_winapi:=-map:$(JDK_OUTPUTDIR)/objs/unpack.map /debug \
+				jvm.lib $(WIN_JAVA_LIB),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX_posix:=$(LIBCXX),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libunpack,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=unpack.dll" \
+			  /D "JDK_INTERNAL_NAME=unpack" \
+			  /D "JDK_FTYPE=0x2L"))
+
+$(BUILD_LIBUNPACK) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBUNPACK)
+
+ifeq ($(OPENJDK_TARGET_OS_API),winapi)
+    $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.map: $(BUILD_LIBUNPACK)
+	$(ECHO) Copying $(@F)
+	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX),%.map,$<) $@
+
+    $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.pdb: $(BUILD_LIBUNPACK)
+	$(ECHO) Copying $(@F)
+	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX),%.pdb,$<) $@
+endif
+
+##########################################################################################
+
+LIBATTACH_EXCLUDE_FILES:=
+ifneq ($(OPENJDK_TARGET_OS),solaris)
+    LIBATTACH_EXCLUDE_FILES+=SolarisVirtualMachine.c
+endif
+ifneq ($(OPENJDK_TARGET_OS),linux)
+    LIBATTACH_EXCLUDE_FILES+=LinuxVirtualMachine.c
+endif
+ifneq ($(OPENJDK_TARGET_OS),macosx)
+    LIBATTACH_EXCLUDE_FILES+=BsdVirtualMachine.c
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\
+		LIBRARY:=attach, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/tools/attach,\
+		EXCLUDE_FILES:=$(LIBATTACH_EXCLUDE_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_solaris:=-ldoor,\
+		LDFLAGS_winapi:=psapi.lib advapi32.lib $(WIN_JAVA_LIB) jvm.lib,\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libattach,\
+		DEBUG_SYMBOLS:=true))
+
+$(BUILD_LIBATTACH) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBATTACH)
+
+##########################################################################################
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBDT_SOCKET,\
+		LIBRARY:=dt_socket,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/transport/socket \
+			$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/socket,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) -DUSE_MMAP \
+                        -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
+                        -I$(JDK_TOPDIR)/src/share/transport/socket \
+		        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/socket \
+                        -I$(JDK_TOPDIR)/src/share/back/export \
+                        -I$(JDK_TOPDIR)/src/share/back,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libdt_socket/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB), \
+		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX) -lpthread,\
+		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket,\
+		LDFLAGS_SUFFIX_winapi:=$(LDFLAGS_JDKLIB_SUFFIX) -export:jdwpTransport_OnLoad ws2_32.lib,\
+		LDFLAGS_SUFFIX:=,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_socket,\
+		DEBUG_SYMBOLS:=true))
+
+$(BUILD_LIBDT_SOCKET) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBDT_SOCKET)
+
+##########################################################################################
+
+ifeq ($(OPENJDK_TARGET_OS_API),winapi)
+
+  $(eval $(call SetupNativeCompilation,BUILD_LIBDT_SHMEM,\
+		LIBRARY:=dt_shmem,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/tools/jdi \
+			$(JDK_TOPDIR)/src/share/transport/shmem \
+			$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/shmem,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) -DUSE_MMAP\
+                        -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
+                        -I$(JDK_TOPDIR)/src/share/transport/shmem \
+		        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/shmem \
+                        -I$(JDK_TOPDIR)/src/share/back/export, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB),\
+		LDFLAGS_winapi:=-export:jdwpTransport_OnLoad,\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_shmem))
+
+  BUILD_LIBRARIES += $(BUILD_LIBDT_SHMEM)
+
+endif # OPENJDK_TARGET_OS
+
+##########################################################################################
+# JDWP_LOGGING causes log messages to be compiled into the library. These reference the 
+# __FILE__ macro which here expands to the absolute path of the file while the old build 
+# system used a relative path. This causes the binaries to differ in size.
+$(eval $(call SetupNativeCompilation,BUILD_LIBJDWP,\
+		LIBRARY:=jdwp, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/back,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) -DJDWP_LOGGING\
+		 -I$(JDK_TOPDIR)/src/share/transport/export \
+                 -I$(JDK_TOPDIR)/src/share/back/export \
+                 -I$(JDK_TOPDIR)/src/share/npt \
+                 -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt \
+                 -I$(JDK_TOPDIR)/src/share/back \
+                 -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/back \
+		 -I$(JDK_OUTPUTDIR)/gensrc_jdwp_headers,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjdwp/mapfile-vers, \
+		LDFLAGS:=$(filter-out -ljava,$(LDFLAGS_JDKLIB)), \
+		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBDL),\
+		LDFLAGS_SUFFIX_solaris:=$(LIBDL),\
+		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX:=,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjdwp))
+
+$(BUILD_LIBJDWP) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJDWP)
+
+##########################################################################################
+
+LIBJAAS_MAPFILE:=
+ifneq ($(OPENJDK_TARGET_OS),solaris)
+   LIBJAAS_EXCLUDE_FILES:=Solaris.c
+else
+   # only on solaris...wonder why
+   LIBJAAS_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjaas/mapfile-vers
+endif
+
+LIBJAAS_NAME:=jaas_unix
+ifeq ($(OPENJDK_TARGET_OS), windows)
+     LIBJAAS_NAME:=jaas_nt
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJAAS,\
+		LIBRARY:=$(LIBJAAS_NAME),\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/com/sun/security/auth/module,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB),\
+		MAPFILE:=$(LIBJAAS_MAPFILE),\
+		LDFLAGS:=$(filter-out -ljava,$(LDFLAGS_JDKLIB)) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_winapi:=netapi32.lib user32.lib mpr.lib advapi32.lib,\
+		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX:=,\
+		EXCLUDE_FILES:=$(LIBJAAS_EXCLUDE_FILES),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjaas))
+
+$(BUILD_LIBJAAS) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJAAS)
+
+##########################################################################################
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJSDT,\
+		LIBRARY:=jsdt,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace\
+			$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/tracing/dtrace,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB)\
+			-I$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsdt/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX)  $(LIBDL),\
+		LDFLAGS_SUFFIX_winapi:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBDL),\
+		LDFLAGS_SUFFIX_macosx:=                         $(LIBDL),\
+		LDFLAGS_SUFFIX:=,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsdt, \
+                DEBUG_SYMBOLS:= yes))
+
+$(BUILD_LIBJSDT) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJSDT)
+
+##########################################################################################
+
+ifdef OPENJDK
+    # TODO: Update awt lib path when awt is converted
+    $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS,\
+                LIBRARY:=lcms,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms \
+		     $(JDK_TOPDIR)/src/share/native/sun/java2d/,\
+		INCLUDE_FILES:=cmscam02.c cmscgats.c cmscnvrt.c cmserr.c \
+			       cmsgamma.c cmsgmt.c cmsintrp.c cmsio0.c \
+			       cmsio1.c cmslut.c cmsmd5.c cmsmtrx.c \
+			       cmsnamed.c cmsopt.c cmspack.c cmspcs.c \
+			       cmsplugin.c cmsps2.c cmssamp.c cmssm.c \
+			       cmstypes.c cmsvirt.c cmswtpnt.c cmsxform.c \
+			       LCMS.c,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(filter-out -xc99=%none,$(CFLAGS_JDKLIB)) \
+			$(SHARED_LIBRARY_FLAGS) \
+			-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
+			-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug,\
+		CFLAGS_solaris:=-xc99=no_lib,\
+		CFLAGS_winapi:=-DCMS_IS_WINDOWS_,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/liblcms/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB), \
+		LDFLAGS_solaris:=/usr/lib$(ISA_DIR)/libm.so.2,\
+		LDFLAGS_winapi:=$(WIN_AWT_LIB) $(WIN_JAVA_LIB),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX_posix:=-lawt,\
+		LDFLAGS_SUFFIX_linux:=-lm,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/liblcms))
+
+    BUILD_LIBRARIES += $(BUILD_LIBLCMS)
+
+    $(BUILD_LIBLCMS) : $(BUILD_LIBAWT)
+endif
+
+##########################################################################################
+
+ifdef OPENJDK
+    BUILD_LIBJPEG_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/mapfile-vers
+else
+    BUILD_LIBJPEG_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/mapfile-vers-closed
+    BUILD_LIBJPEG_CLOSED_SRC:=$(JDK_TOPDIR)/src/closed/share/native/sun/awt/image/jpeg
+    BUILD_LIBJPEG_CLOSED_INCLUDES:=-I$(BUILD_LIBJPEG_CLOSED_SRC)
+endif
+
+BUILD_LIBJPEG_REORDER:=
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+    ifneq ($(ARCH), amd64)
+        BUILD_LIBJPEG_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/reorder-$(ARCH)
+    endif
+endif
+
+# Suppress gcc warnings like "variable might be clobbered by 'longjmp'
+# or 'vfork'": this warning indicates that some variable is placed to
+# a register by optimized compiler and it's value might be lost on longjmp().
+# Recommended way to avoid such warning is to declare the variable as
+# volatile to prevent the optimization. However, this approach does not
+# work because we have to declare all variables as volatile in result.
+#ifndef CROSS_COMPILE_ARCH
+#    CC_43_OR_NEWER:=\
+#        $(shell $(EXPR) $(CC_MAJORVER) \> 4 \| \
+#              \( $(CC_MAJORVER) = 4 \& $(CC_MINORVER) \>= 3 \) )
+#    ifeq ($(CC_43_OR_NEWER),1)
+#        BUILD_LIBJPEG_CFLAGS_linux += -Wno-clobbered
+#    endif
+#endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJPEG,\
+                LIBRARY:=jpeg, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(BUILD_LIBJPEG_CLOSED_SRC) \
+		     $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg,\
+		LANG:=C,\
+		OPTIMIZATION:=HIGHEST, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+			$(BUILD_LIBJPEG_CLOSED_INCLUDES) \
+			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg,\
+		MAPFILE:=$(BUILD_LIBJPEG_MAPFILE), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_linux:=$(LIBDL),\
+		LDFLAGS_winapi:=$(WIN_JAVA_LIB) jvm.lib,\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		REORDER:=$(BUILD_LIBJPEG_REORDER),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjpeg))
+
+$(BUILD_LIBJPEG) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJPEG)
+
+##########################################################################################
+
+ifndef OPENJDK
+    FONT_HEADERS:=-I$(CLOSED_SRC)/share/native/$(PKGDIR)/t2k
+    BUILD_LIBFONTMANAGER_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libfontmanager/mapfile-vers
+    LIBFONTMANAGER_EXCLUDE_FILES += freetypeScaler.c
+else
+    FONT_HEADERS:=$(FREETYPE2_CFLAGS)
+    BUILD_LIBFONTMANAGER_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libfontmanager/mapfile-vers.openjdk
+    BUILD_LIBFONTMANAGER_FONTLIB:=$(FREETYPE2_LIBS)
+endif
+
+LIBFONTMANAGER_OPTIMIZATION:=HIGH
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+    LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
+				    X11TextRenderer.c
+    LIBFONTMANAGER_OPTIMIZATION:=LOW
+else
+    LIBFONTMANAGER_EXCLUDE_FILES += fontpath.c \
+				    lcdglyph.c
+endif
+
+BUILD_LIBFONTMANAGER_CFLAGS_COMMON:=\
+			$(X_CFLAGS) \
+			-DLE_STANDALONE -DHEADLESS \
+			$(FONT_HEADERS) \
+			-I$(JDK_TOPDIR)/src/share/native/sun/font \
+			-I$(JDK_TOPDIR)/src/share/native/sun/font/layout \
+			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+			-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+			-I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
+			-I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+			-I$(JDK_TOPDIR)/src/share/native/sun/java2d
+
+# Turn off aliasing with GCC for ExtensionSubtables.cpp
+ifeq ($(OPENJDK_TARGET_OS), linux)
+    BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS:=-fno-strict-aliasing
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER,\
+		LIBRARY:=fontmanager, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/share/native/sun/font\
+		     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/font,\
+		EXCLUDE_FILES:=$(LIBFONTMANAGER_EXCLUDE_FILES) \
+			       AccelGlyphCache.c,\
+		LANG:=C++,\
+		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBFONTMANAGER_CFLAGS_COMMON),\
+		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(BUILD_LIBFONTMANAGER_CFLAGS_COMMON),\
+		OPTIMIZATION:=$(LIBFONTMANAGER_OPTIMIZATION), \
+		CFLAGS_windows= -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows \
+				-DCC_NOEX, \
+		MAPFILE:=$(BUILD_LIBFONTMANAGER_MAPFILE), \
+		LDFLAGS:=$(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_windows:=advapi32.lib user32.lib gdi32.lib $(WIN_AWT_LIB) $(WIN_JAVA_LIB),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) \
+				$(BUILD_LIBFONTMANAGER_FONTLIB),\
+		LDFLAGS_SUFFIX_linux:=-lawt $(LIBM) $(LIBCXX),\
+		LDFLAGS_SUFFIX_solaris:=-lawt -lawt_xawt -lc $(LIBM) $(LIBCXX),\
+		LDFLAGS_SUFFIX_macosx:=-lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfontmanager))
+
+$(BUILD_LIBFONTMANAGER) : $(BUILD_LIBAWT)
+
+ifneq (,$(findstring $(OPENJDK_TARGET_OS),solaris macosx))
+$(BUILD_LIBFONTMANAGER) : $(BUILD_LIBAWT_XAWT)
+endif
+
+BUILD_LIBRARIES += $(BUILD_LIBFONTMANAGER)
+
+##########################################################################################
+
+ifndef OPENJDK
+
+#    ifeq ($(OPENJDK_TARGET_OS), linux)
+#        ifeq ("$(CC_VER_MAJOR)", "3")
+#            OTHER_LDLIBS  += -Wl,-Bstatic -lgcc_eh -Wl,-Bdynamic
+#        endif                           
+#    endif
+#
+# The resulting size of the t2k lib file is (at least on linux) dependant on the order of 
+# the input .o files. Because of this the new build will differ in size to the old build.
+    BUILD_LIBT2K_CFLAGS_COMMON:=-I$(JDK_TOPDIR)/src/share/native/sun/font \
+		            -I$(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k \
+		            -I$(JDK_TOPDIR)/src/closed/share/native/sun/font \
+		            -I$(JDK_TOPDIR)/src/share/share/native/sun/font \
+		            -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/font \
+		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
+		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
+		            -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d
+
+    $(eval $(call SetupNativeCompilation,BUILD_LIBT2K,\
+                LIBRARY:=t2k, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/closed/share/native/sun/font \
+		     $(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k \
+		     $(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k/ttHints,\
+		EXCLUDE_FILES:=orion.c,\
+		LANG:=C++,\
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBT2K_CFLAGS_COMMON),\
+		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(BUILD_LIBT2K_CFLAGS_COMMON),\
+		CFLAGS_windows=-DCC_NOEX, \
+		CXXFLAGS_windows=-DCC_NOEX, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libt2k/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_windows:=user32.lib $(JDK_OUTPUTDIR)/objs/libfontmanager/fontmanager.lib,\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX_macosx:=$(LIBCXX) $(LIBM) -lfontmanager,\
+		LDFLAGS_SUFFIX_linux:=$(LIBCXX) $(LIBM) -lfontmanager,\
+		LDFLAGS_SUFFIX_solaris:=$(LIBCXX) $(LIBM) -lfontmanager -lawt \
+					-lawt_xawt,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libt2k))
+
+    # t2k is linked against fontmanager
+    $(BUILD_LIBT2K) : $(BUILD_LIBFONTMANAGER)
+
+    BUILD_LIBRARIES += $(BUILD_LIBT2K)
+endif
+
+##########################################################################################
+
+#
+# TODO replace with X_FLAGS / X_LIBS
+#   and add them to configure
+#
+OPENWIN_LIB:=$(OPENWIN_HOME)/lib
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+    ifeq ($(ARCH_DATA_MODEL), 32)
+        KERNEL32_LIB:=kernel32.lib
+    endif
+    $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT,\
+                LIBRARY:=jawt, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows,\
+		INCLUDE_FILES:=jawt.cpp,\
+		LANG:=C++,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CXXFLAGS_JDKLIB) \
+			-EHsc -DUNICODE -D_UNICODE \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows \
+		        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+		        -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
+			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/windows, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(KERNEL32_LIB) \
+			 advapi32.lib $(WIN_AWT_LIB),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt))
+
+$(BUILD_LIBJAWT) : $(BUILD_LIBAWT)
+
+$(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX): $(BUILD_LIBJAWT)
+	$(ECHO) Copying $(@F)
+	$(CP) $< $@
+
+BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX)
+
+else # OPENJDK_TARGET_OS not windows
+
+    JAWT_LIBS:=
+    ifneq ($(OPENJDK_TARGET_OS), solaris)
+        JAWT_LIBS += -lawt
+    endif
+
+    ifndef BUILD_HEADLESS_ONLY
+        JAWT_LIBS += -lawt_xawt
+    else
+        JAWT_LIBS += -lawt_headless
+        HEADLESS_CFLAG += -DHEADLESS
+    endif
+
+    JAWT_FILES:=jawt.c
+    ifeq ($(OPENJDK_TARGET_OS), macosx)
+	JAWT_FILES:=jawt.m
+	JAWT_LIBS:=-lawt_lwawt
+    endif
+
+    $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT,\
+                LIBRARY:=jawt, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+                     $(JDK_TOPDIR)/src/macosx/native/sun/awt,\
+		INCLUDE_FILES:=$(JAWT_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB), \
+		CFLAGS_linux:=$(HEADLESS_CFLAG),\
+		CFLAGS_macosx:=-I$(JDK_TOPDIR)/src/solaris/native/sun/awt ,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjawt/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -L$(OPENWIN_LIB)$(ISA_DIR),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(JAWT_LIBS),\
+		LDFLAGS_SUFFIX_solaris:=-lXrender,\
+		LDFLAGS_SUFFIX_macosx:=-framework Cocoa, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt))
+
+ifndef BUILD_HEADLESS_ONLY
+$(BUILD_LIBJAWT) : $(BUILD_LIBAWT_XAWT)
+else
+$(BUILD_LIBJAWT) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX)
+endif
+
+ifeq ($(OPENJDK_TARGET_OS),macosx)
+$(BUILD_LIBJAWT) : $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX)
+endif
+
+endif # OPENJDK_TARGET_OS
+
+BUILD_LIBRARIES += $(BUILD_LIBJAWT)
+
+##########################################################################################
+
+ifndef OPENJDK
+ifneq ($(OPENJDK_TARGET_OS), macosx)
+
+LIBJDBCODBC_DIR   :=$(JDK_OUTPUTDIR)/objs/libjdbcodbc
+LIBJDBCODBC_NAME  :=$(LIBRARY_PREFIX)JdbcOdbc$(SHARED_LIBRARY_SUFFIX)
+LIBJDBCODBC_CFLAGS:=
+LIBJDBCODBC_LIBS   :=
+LIBJDBCODBC_LDFLAGS:=
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+	LIBJDBCODBC_LDFLAGS:=$(LDFLAGS_JDKLIB)
+	LIBJDBCODBC_LIBS += odbc32.lib odbccp32.lib $(WIN_JAVA_LIB) advapi32.lib
+else
+	LIBJDBCODBC_CFLAGS:=-DUNIX
+
+#
+# This mimics "current" build system exactly. Link against fake -lodbcinst -lodbc
+#   but...those are linked with the -soname, causing the dependency to be dropped on linux (gnu ld)
+#   but kept with other linker (solaris)
+#
+# IMO very weird behaviour...very weird
+#
+	LIBJDBCODBC_LDFLAGS:=$(patsubst defs,nodefs,$(LDFLAGS_JDKLIB)) \
+				      -Xlinker -z -Xlinker nodefs
+	LIBJDBCODBC_LIBS += -L$(LIBJDBCODBC_DIR) -lodbcinst -lodbc
+	LIBJDBCODBC_SONAME:=$(call SET_SHARED_LIBRARY_NAME,$(LIBJDBCODBC_NAME))
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJDBCODBC,\
+		LIBRARY:=JdbcOdbc,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/closed/share/classes/sun/jdbc/odbc,\
+		EXCLUDE_FILES:=dummyodbc.c,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(LIBJDBCODBC_CFLAGS) $(CFLAGS_JDKLIB) \
+			$(SHARED_LIBRARY_FLAGS),\
+		LDFLAGS:=$(LIBJDBCODBC_LDFLAGS) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN) $(LIBJDBCODBC_LIBS),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBJDBCODBC_SONAME),\
+		OBJECT_DIR:=$(LIBJDBCODBC_DIR)))
+
+$(BUILD_LIBJDBCODBC) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJDBCODBC)
+
+ifneq ($(OPENJDK_TARGET_OS), windows)
+
+$(eval $(call SetupNativeCompilation,BUILD_FAKEODBCINST,\
+		LIBRARY:=odbcinst,\
+                OUTPUT_DIR:=$(LIBJDBCODBC_DIR),\
+		SRC:=$(JDK_OUTPUTDIR)/gensrc_c/libjdbcodbc,\
+		INCLUDE_FILES:=dummyodbc1.c,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB),\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN) $(LIBJDBCODBC_LDFLAGS),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBJDBCODBC_SONAME),\
+		OBJECT_DIR:=$(LIBJDBCODBC_DIR)))
+
+$(eval $(call SetupNativeCompilation,BUILD_FAKEODBC,\
+		LIBRARY:=odbc,\
+                OUTPUT_DIR:=$(LIBJDBCODBC_DIR),\
+		SRC:=$(JDK_OUTPUTDIR)/gensrc_c/libjdbcodbc,\
+		INCLUDE_FILES:=dummyodbc2.c,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(LIBJDBCODBC_CFLAGS) $(CFLAGS_JDKLIB),\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN) $(LIBJDBCODBC_LDFLAGS),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBJDBCODBC_SONAME),\
+		OBJECT_DIR:=$(LIBJDBCODBC_DIR)))
+
+$(BUILD_FAKEODBCINST) $(BUILD_FAKEODBC) : \
+  $(BUILD_LIBJAVA)
+
+$(BUILD_LIBJDBCODBC) : $(BUILD_FAKEODBCINST) $(BUILD_FAKEODBC)
+
+endif
+
+endif
+endif
+
+##########################################################################################
+
+BUILD_LIBINSTRUMENT_SRC   :=$(JDK_TOPDIR)/src/share/instrument \
+                               $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/io \
+                               $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/instrument
+
+BUILD_LIBINSTRUMENT_FILES :=\
+	EncodingSupport.c \
+	EncodingSupport_md.c \
+	FileSystemSupport_md.c \
+	InstrumentationImplNativeMethods.c \
+	InvocationAdapter.c \
+	JarFacade.c \
+	JPLISAgent.c \
+	JPLISAssert.c \
+	JavaExceptions.c \
+	PathCharsValidator.c \
+	Reentrancy.c \
+	Utilities.c \
+	canonicalize_md.c
+
+BUILD_LIBINSTRUMENT_DIR   :=$(JDK_OUTPUTDIR)/objs/libinstrument
+BUILD_LIBINSTRUMENT_CFLAGS:=-I$(JDK_TOPDIR)/src/share/instrument \
+                               -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/instrument \
+                               -I$(JDK_TOPDIR)/src/share/bin
+
+BUILD_LIBINSTRUMENT_LDFLAGS:=
+BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX:=
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  BUILD_LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/jli_static.lib $(WIN_JAVA_LIB) \
+				 -export:Agent_OnAttach
+  # equivalent of strcasecmp is stricmp on Windows
+  BUILD_LIBINSTRUMENT_CFLAGS += -Dstrcasecmp=stricmp
+else ifneq (,$(findstring $(OPENJDK_TARGET_OS), macosx))
+	ifneq ($(ARCH), universal)
+		BUILD_LIBINSTRUMENT_LDFLAGS += -Wl,-all_load
+	endif
+
+	BUILD_LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/libjli_static.a
+	BUILD_LIBINSTRUMENT_LDFLAGS += -liconv
+	BUILD_LIBINSTRUMENT_LDFLAGS += -framework Cocoa -framework Security -framework ApplicationServices
+	BUILD_LIBINSTRUMENT_LDFLAGS += $(LIBZ)
+else
+	BUILD_LIBINSTRUMENT_LDFLAGS += -L $(INSTALL_LIBRARIES_HERE)/jli
+	BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX += -ljli $(LIBDL)
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT,\
+		LIBRARY:=instrument, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(BUILD_LIBINSTRUMENT_SRC),\
+		INCLUDE_FILES:=$(BUILD_LIBINSTRUMENT_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        $(BUILD_LIBINSTRUMENT_CFLAGS),\
+		CFLAGS_debug:=-DJPLIS_LOGGING,\
+		CFLAGS_release:=-DNO_JPLIS_LOGGING,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libinstrument/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN)\
+			 $(call SET_SHARED_LIBRARY_ORIGIN,jli) \
+                         $(BUILD_LIBINSTRUMENT_LDFLAGS),\
+		LDFLAGS_SUFFIX:=$(LIBZ) $(BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX),\
+		OBJECT_DIR:=$(BUILD_LIBINSTRUMENT_DIR),\
+		DEBUG_SYMBOLS:=true))
+
+ifneq (,$(findstring $(OPENJDK_TARGET_OS), macosx windows))
+$(BUILD_LIBINSTRUMENT) : $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX)
+else
+$(BUILD_LIBINSTRUMENT) : $(INSTALL_LIBRARIES_HERE)/jli/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)
+endif
+$(BUILD_LIBINSTRUMENT) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBINSTRUMENT)
+
+##########################################################################################
+
+BUILD_LIBMANAGEMENT_SRC:=$(JDK_TOPDIR)/src/share/native/sun/management \
+                           $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/management \
+                           $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/com/sun/management
+
+BUILD_LIBMANAGEMENT_EXCLUDES:=
+
+BUILD_LIBMANAGEMENT_CFLAGS:=-I$(JDK_TOPDIR)/src/share/native/sun/management
+
+ifneq ($(OPENJDK_TARGET_OS), windows)
+	BUILD_LIBMANAGEMENT_EXCLUDES += OperatingSystem_md.c
+else
+	BUILD_LIBMANAGEMENT_EXCLUDES += UnixOperatingSystem_md.c
+endif
+
+ifneq ($(OPENJDK_TARGET_OS),solaris)
+	BUILD_LIBMANAGEMENT_EXCLUDES += SolarisOperatingSystem.c
+endif
+
+ifneq ($(OPENJDK_TARGET_OS),linux)
+	BUILD_LIBMANAGEMENT_EXCLUDES += LinuxOperatingSystem.c
+endif
+
+ifneq ($(OPENJDK_TARGET_OS),macosx)
+	BUILD_LIBMANAGEMENT_EXCLUDES += MacosxOperatingSystem.c
+endif
+
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT,\
+		LIBRARY:=management,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(BUILD_LIBMANAGEMENT_SRC),\
+		EXCLUDE_FILES:=$(BUILD_LIBMANAGEMENT_EXCLUDES),\
+		LANG:=C,\
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBMANAGEMENT_CFLAGS),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libmanagement/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_windows:=$(WIN_JAVA_LIB) jvm.lib advapi32.lib psapi.lib,\
+		LDFLAGS_solaris:=-lkstat,\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmanagement,\
+		DEBUG_SYMBOLS:=true))
+
+$(BUILD_LIBMANAGEMENT) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBMANAGEMENT)
+
+##########################################################################################
+
+BUILD_LIBHPROF_SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/hprof $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/demo/jvmti/hprof
+BUILD_LIBHPROF_CFLAGS:=-I$(JDK_TOPDIR)/src/share/demo/jvmti/hprof \
+                         -I$(JDK_TOPDIR)/src/share/npt \
+                         -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt \
+                         -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo
+
+BUILD_LIBHPROF_LDFLAGS:=
+
+ifeq ($(OPENJDK_TARGET_OS),solaris)
+     BUILD_LIBHPROF_LDFLAGS += -lsocket -lnsl
+endif
+
+ifneq ($(OPENJDK_TARGET_OS),windows)
+     BUILD_LIBHPROF_LDFLAGS += $(LIBDL)
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBHPROF,\
+		LIBRARY:=hprof, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(BUILD_LIBHPROF_SRC),\
+		LANG:=C,\
+		OPTIMIZATION:=HIGHEST, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                         $(BUILD_LIBHPROF_CFLAGS),\
+		CFLAGS_debug:=-DHPROF_LOGGING,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libhprof/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_windows:=wsock32.lib winmm.lib advapi32.lib,\
+		LDFLAGS_SUFFIX:=$(BUILD_LIBHPROF_LDFLAGS),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libhprof_jvmti,\
+		DEBUG_SYMBOLS:=true))
+
+BUILD_LIBRARIES += $(BUILD_LIBHPROF)
+
+##########################################################################################
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJAVA_CRW_DEMO,\
+		LIBRARY:=java_crw_demo, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjava_crw_demo/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX:=,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava_crw_demo,\
+		DEBUG_SYMBOLS:=true))
+
+BUILD_LIBRARIES += $(BUILD_LIBJAVA_CRW_DEMO)
+
+##########################################################################################
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBNPT,\
+		LIBRARY:=npt, \
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/share/npt $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        -I$(JDK_TOPDIR)/src/share/npt \
+                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnpt/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_macosx:=-liconv,\
+		LDFLAGS_SUFFIX_windows:=-export:nptInitialize -export:nptTerminate,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnpt,\
+		DEBUG_SYMBOLS:=true))
+
+BUILD_LIBRARIES += $(BUILD_LIBNPT)
+
+##########################################################################################
+
+LIBNET_SRC_DIRS:=$(JDK_TOPDIR)/src/share/native/java/net \
+                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/net \
+                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/dns \
+                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/www/protocol/http/ntlm \
+                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/sdp \
+                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/spi
+
+LIBNET_CFLAGS:=$(foreach dir,$(LIBNET_SRC_DIRS),-I$(dir))
+
+LIBNET_EXCLUDE_FILES:=
+ifneq ($(OPENJDK_TARGET_OS),linux)
+	LIBNET_EXCLUDE_FILES += linux_close.c
+endif
+
+ifneq ($(OPENJDK_TARGET_OS),macosx)
+	LIBNET_EXCLUDE_FILES += bsd_close.c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+	LIBNET_EXCLUDE_FILES += PlainSocketImpl.c PlainDatagramSocketImpl.c SdpSupport.c
+else
+	LIBNET_EXCLUDE_FILES += TwoStacksPlainSocketImpl.c DualStackPlainSocketImpl.c \
+                                TwoStacksPlainDatagramSocketImpl.c DualStackPlainDatagramSocketImpl.c \
+				NTLMAuthSequence.c NetworkInterface_winXP.c
+endif
+
+LIBNET_LDFLAGS_SUFFIX:=
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBNET,\
+		LIBRARY:=net,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(LIBNET_SRC_DIRS),\
+		EXCLUDE_FILES:=$(LIBNET_EXCLUDE_FILES), \
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        $(LIBNET_CFLAGS),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnet/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBNET_LDFLAGS_SUFFIX),\
+		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket $(LIBDL) ,\
+		LDFLAGS_SUFFIX_linux:=$(LIBDL) -lpthread ,\
+		LDFLAGS_SUFFIX_windows:=ws2_32.lib $(JVMLIB) secur32.lib iphlpapi.lib \
+					  delayimp.lib $(WIN_JAVA_LIB) jvm.lib advapi32.lib \
+                                          /DELAYLOAD:secur32.dll /DELAYLOAD:iphlpapi.dll, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnet))
+
+$(BUILD_LIBNET) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBNET)
+
+$(JDK_OUTPUTDIR)/lib/net.properties: $(JDK_TOPDIR)/src/share/lib/net.properties
+	$(ECHO) Copying $(@F)
+	$(MKDIR) -p $(@D)
+	$(CP) $< $@
+
+COPY_FILES += $(JDK_OUTPUTDIR)/lib/net.properties
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+$(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${LEGACY_OPENJDK_TARGET_OS_API}/lib/sdp/sdp.conf.template
+	$(ECHO) Copying $(@F)
+	$(MKDIR) -p $(@D)
+	$(CP) $< $@
+
+COPY_FILES += $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template
+endif
+
+##########################################################################################
+
+BUILD_LIBNIO_SRC:=\
+        $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/nio \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/ch \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/fs
+
+BUILD_LIBNIO_CFLAGS:=\
+	-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch \
+	-I$(JDK_TOPDIR)/src/share/native/java/io \
+	-I$(JDK_TOPDIR)/src/share/native/java/net \
+        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/net
+
+BUILD_LIBNIO_FILES:=\
+        DatagramChannelImpl.c \
+        DatagramDispatcher.c \
+	FileChannelImpl.c \
+	FileDispatcherImpl.c \
+	FileKey.c \
+	IOUtil.c \
+        MappedByteBuffer.c \
+	Net.c \
+	ServerSocketChannelImpl.c \
+	SocketChannelImpl.c \
+	SocketDispatcher.c
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+	BUILD_LIBNIO_FILES += \
+		Iocp.c \
+		RegistryFileTypeDetector.c \
+		WindowsAsynchronousFileChannelImpl.c \
+		WindowsAsynchronousServerSocketChannelImpl.c \
+		WindowsAsynchronousSocketChannelImpl.c \
+		WindowsNativeDispatcher.c \
+	        WindowsSelectorImpl.c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), linux)
+	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-linux
+	BUILD_LIBNIO_FILES += \
+		EPoll.c \
+		EPollArrayWrapper.c \
+		EPollPort.c \
+		InheritedChannel.c \
+		NativeThread.c \
+	        PollArrayWrapper.c \
+		UnixAsynchronousServerSocketChannelImpl.c \
+		UnixAsynchronousSocketChannelImpl.c \
+		GnomeFileTypeDetector.c \
+		LinuxNativeDispatcher.c \
+		LinuxWatchService.c \
+		UnixCopyFile.c \
+		UnixNativeDispatcher.c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-bsd
+	BUILD_LIBNIO_SRC += $(JDK_TOPDIR)/src/macosx/native/sun/nio/ch
+	BUILD_LIBNIO_FILES += \
+		InheritedChannel.c \
+		NativeThread.c \
+	        PollArrayWrapper.c \
+		UnixAsynchronousServerSocketChannelImpl.c \
+		UnixAsynchronousSocketChannelImpl.c \
+		GnomeFileTypeDetector.c \
+		BsdNativeDispatcher.c \
+		UnixCopyFile.c \
+		UnixNativeDispatcher.c \
+		KQueue.c \
+		KQueuePort.c \
+		KQueueArrayWrapper.c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-solaris
+	BUILD_LIBNIO_FILES += \
+		DevPollArrayWrapper.c \
+		InheritedChannel.c \
+		NativeThread.c \
+		PollArrayWrapper.c \
+		SolarisEventPort.c \
+		UnixAsynchronousServerSocketChannelImpl.c \
+		UnixAsynchronousSocketChannelImpl.c \
+		GnomeFileTypeDetector.c \
+		SolarisNativeDispatcher.c \
+		SolarisWatchService.c \
+		UnixCopyFile.c \
+		UnixNativeDispatcher.c
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBNIO,\
+		LIBRARY:=nio,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(BUILD_LIBNIO_SRC),\
+		INCLUDE_FILES:=$(BUILD_LIBNIO_FILES), \
+		LANG:=C,\
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        $(BUILD_LIBNIO_CFLAGS),\
+		MAPFILE:=$(BUILD_LIBNIO_MAPFILE), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(BUILD_LIBNIO_LDFLAGS) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX_linux:=-ljava -lnet -lpthread $(LIBDL),\
+		LDFLAGS_SUFFIX_solaris:=$(LDFLAGS_JDKLIB_SUFFIX) \
+                                        $(JVMLIB) -lsocket -lposix4 $(LIBDL) -lsendfile \
+		                        -ljava -lnet,\
+		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX) \
+                                        $(WIN_JAVA_LIB) $(JDK_OUTPUTDIR)/objs/libnet/net.lib \
+					advapi32.lib jvm.lib ws2_32.lib\
+                                        $(JDK_OUTPUTDIR)/objs/libjava/io_util.obj \
+		                        $(JDK_OUTPUTDIR)/objs/libjava/FileDescriptor_md.obj ,\
+		LDFLAGS_SUFFIX_macosx:=-ljava -lnet -pthread,\
+		LDFLAGS_SUFFIX:=,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnio))
+
+BUILD_LIBRARIES += $(BUILD_LIBNIO)
+
+$(BUILD_LIBNIO) : $(BUILD_LIBNET)
+
+##########################################################################################
+
+ifeq ($(OPENJDK_TARGET_OS_API),posix)
+  # TODO make this work on macosx
+  ifneq ($(OPENJDK_TARGET_OS),macosx)
+
+    SCTP_WERROR := -Werror
+    ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc)
+      SCTP_WERROR :=
+    endif
+
+    $(eval $(call SetupNativeCompilation,BUILD_LIBSCTP,\
+                LIBRARY:=sctp,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/ch/sctp,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB)\
+			-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch \
+			-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch/sctp \
+			-I$(JDK_TOPDIR)/src/share/native/java/net \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/ch \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/net,\
+		CFLAGS_linux:=$(SCTP_WERROR),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsctp/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX_linux:=$(LIBDL) -lpthread,\
+		LDFLAGS_SUFFIX_posix:=-lnio -lnet,\
+		LDFLAGS_SUFFIX_solaris:=-lsocket,\
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		INCLUDE_FILES:=SctpNet.c SctpChannelImpl.c SctpServerChannelImpl.c,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp))
+
+    BUILD_LIBRARIES += $(BUILD_LIBSCTP)
+
+    $(BUILD_LIBSCTP) : $(BUILD_LIBNIO)
+  endif
+endif
+
+##########################################################################################
+
+BUILD_LIBJLI_SRC_DIRS:=$(JDK_TOPDIR)/src/share/bin $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin
+BUILD_LIBJLI_CFLAGS:=$(foreach dir,$(BUILD_LIBJLI_SRC_DIRS),-I$(dir))
+
+BUILD_LIBJLI_FILES:=\
+	java.c \
+	splashscreen_stubs.c \
+	parse_manifest.c \
+	version_comp.c \
+	wildcard.c \
+	jli_util.c
+
+ifeq ($(JVM_VARIANT_ZERO), true)
+	ERGO_FAMILY:=zero
+else # !ZERO_BUILD
+	ifneq (,$(findstring $(ARCH), amd64 x86_64))
+		ERGO_FAMILY:=i586
+	else # !X86 FAMILY
+		ERGO_FAMILY:=$(ARCH)
+	endif #ARCH_FAMILY
+endif # ZERO_BUILD
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+	BUILD_LIBJLI_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/bin
+	BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/bin
+	BUILD_LIBJLI_FILES += java_md_common.c java_md_macosx.c
+
+	BUILD_LIBJLI_java_md_macosx.c_CFLAGS:=-x objective-c
+	BUILD_LIBJLI_STATIC_java_md_macosx.c_CFLAGS:=-x objective-c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+	BUILD_LIBJLI_FILES += java_md.c
+else ifneq ($(OPENJDK_TARGET_OS), macosx)
+
+	BUILD_LIBJLI_FILES += java_md_common.c
+	BUILD_LIBJLI_FILES += java_md_solinux.c ergo.c 
+
+	ERGO_ARCH_FILE = ergo_$(ERGO_FAMILY).c
+
+        # if the architecture specific ergo file exists then
+        # use it, else use the generic definitions from ergo.c
+	ifneq ($(wildcard $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin/$(ERGO_ARCH_FILE)),)
+		BUILD_LIBJLI_FILES += $(ERGO_ARCH_FILE)
+	else # !ERGO_ARCH_FILE
+		BUILD_LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO
+	endif # ERGO_ARCH_FILE
+endif #WINDOWS
+
+# Names of arch directories
+ifneq ($(OPENJDK_TARGET_OS), macosx)
+	BUILD_LIBJLI_CFLAGS += -DLIBARCHNAME='"$(LIBARCH)"'
+else
+	BUILD_LIBJLI_CFLAGS += -DLIBARCHNAME='"$(ARCH)"'
+endif
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+	ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
+		BUILD_LIBJLI_CFLAGS += -DLIBARCH32NAME='"sparc"'
+		BUILD_LIBJLI_CFLAGS += -DLIBARCH64NAME='"sparcv9"'
+	else
+		BUILD_LIBJLI_CFLAGS += -DLIBARCH32NAME='"i386"'
+		BUILD_LIBJLI_CFLAGS += -DLIBARCH64NAME='"amd64"'
+	endif
+endif # OPENJDK_TARGET_OS
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+	BUILD_LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
+endif
+
+ifneq ($(USE_EXTERNAL_LIBZ),true)
+	BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
+	BUILD_LIBJLI_CFLAGS += $(LIBZ_INCLUDE)
+	BUILD_LIBJLI_FILES += \
+		inflate.c \
+		inftrees.c \
+		inffast.c \
+		zadler32.c \
+		zcrc32.c \
+		zutil.c
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+    LIBJLI_OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE)
+else
+    LIBJLI_OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE)/jli
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJLI,\
+		LIBRARY:=jli,\
+                OUTPUT_DIR:=$(LIBJLI_OUTPUT_DIR),\
+		SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
+		INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBJLI_CFLAGS),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjli/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX:=$(LIBZ),\
+		LDFLAGS_SUFFIX_posix:=$(LIBDL) -lc,\
+		LDFLAGS_SUFFIX_linux:=-lpthread,\
+		LDFLAGS_SUFFIX_windows:=\
+			-export:JLI_Launch \
+			-export:JLI_ManifestIterate \
+			-export:JLI_SetTraceLauncher \
+			-export:JLI_ReportErrorMessage \
+			-export:JLI_ReportErrorMessageSys \
+			-export:JLI_ReportMessage \
+			-export:JLI_ReportExceptionDescription \
+			advapi32.lib \
+			comctl32.lib \
+			user32.lib,\
+		LDFLAGS_SUFFIX_macosx:=-framework Cocoa -framework Security -framework ApplicationServices, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli))
+
+BUILD_LIBRARIES += $(BUILD_LIBJLI)
+
+# On windows, the static library has the same suffix as the import library created by
+# with the shared library, so the static library is given a different name. No harm
+# in doing it for all platform to reduce complexity.
+ifeq ($(OPENJDK_TARGET_OS), windows)
+    $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_STATIC,\
+		STATIC_LIBRARY:=jli_static,\
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs,\
+		SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
+		INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(STATIC_LIBRARY_FLAGS) $(BUILD_LIBJLI_CFLAGS),\
+		ARFLAGS:=$(ARFLAGS),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
+
+BUILD_LIBRARIES += $(BUILD_LIBJLI_STATIC)
+
+else ifeq ($(OPENJDK_TARGET_OS),macosx)
+    #
+    # On macosx they do partial (incremental) linking of libjli_static.a
+    #   code it here...rather than add support to NativeCompilation
+    #   as this is first time I see it
+    $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_STATIC,\
+		LIBRARY:=jli_static, \
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs,\
+		SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
+		INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=HIGH, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBJLI_CFLAGS),\
+		LDFLAGS:=-nostdlib -r,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
+
+$(JDK_OUTPUTDIR)/objs/libjli_static.a : $(BUILD_LIBJLI_STATIC)
+	$(CP) -a $< $@
+
+BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a
+endif
+
+##########################################################################################
+
+ifeq ($(ENABLE_JFR), true)
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJFR,\
+		LIBRARY:=jfr,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/closed/share/native/oracle/jfr,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+                        -I$(JDK_TOPDIR)/src/closed/share/javavm/export, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjfr/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjfr))
+
+BUILD_LIBRARIES += $(BUILD_LIBJFR)
+
+endif
+
+##########################################################################################
+
+ifndef OPENJDK
+
+BUILD_LIBKCMS_EXCLUDE_FILES:=
+ifeq ($(OPENJDK_TARGET_OS),windows)
+	BUILD_LIBKCMS_EXCLUDE_FILES += ukcpmgr.c unixmem.c
+else
+	BUILD_LIBKCMS_EXCLUDE_FILES += cmmdll.c registry.c spxffile.c sysinfo.c winmem.c wkcpmgr.c
+endif
+
+BUILD_LIBKCMS_FLAGS:=$(CFLAGS_JDKLIB)
+
+ifeq ($(OPENJDK_TARGET_OS),solaris)
+     # This particular library uses a feature called PIC_CODE_SMALL (on solaris)
+     #   implement it like this...since it's only used here
+     BUILD_LIBKCMS_FLAGS:=$(patsubst -KPIC,-Kpic,$(BUILD_LIBKCMS_FLAGS))
+else ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc)
+     BUILD_LIBKCMS_FLAGS:=$(patsubst -fPIC,-fpic,$(BUILD_LIBKCMS_FLAGS))
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBKCMS,\
+		LIBRARY:=kcms,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms,\
+		LANG:=C,\
+		EXCLUDE_FILES:=$(BUILD_LIBKCMS_EXCLUDE_FILES),\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(BUILD_LIBKCMS_FLAGS) \
+                        -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST,\
+		CFLAGS_linux:=-Wno-missing-field-initializers,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libkcms/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX_linux:=-lpthread,\
+		LDFLAGS_SUFFIX_windows:=$(WIN_JAVA_LIB) advapi32.lib user32.lib version.lib, \
+		LDFLAGS_SUFFIX:=-lm $(LDFLAGS_JDKLIB_SUFFIX),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkcms))
+
+$(BUILD_LIBKCMS) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBKCMS)
+
+endif
+
+##########################################################################################
+
+ifndef OPENJDK
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+ifneq ($(ARCH), amd64)
+
+ifeq ($(shell if test "$(OS_VERSION_MAJOR)" -eq 5 -a "$(OS_VERSION_MINOR)" -le 10; then $(ECHO) ok; fi), ok)
+
+SUNWJDGA_MAPFILE:=
+ifneq (,$(findstring $(ARCH),sparc))
+	SUNWJDGA_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjdga/mapfile-vers
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBSUNWJDGA, \
+		LIBRARY:=sunwjdga,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/solaris/native/sun/jdga, \
+		LANG:=C, \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+			-I$(JDK_TOPDIR)/src/share/javavm/export \
+			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/javavm/export \
+			-I$(OPENWIN_HOME)/include, \
+		MAPFILE:=$(SUNWJDGA_MAPFILE), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS_SUFFIX:=-L$(OPENWIN_LIB)$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR) -ldga -lX11 $(LIBDL) -lc, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunwjdga))
+
+BUILD_LIBRARIES += $(BUILD_LIBSUNWJDGA)
+
+endif
+endif
+endif
+endif
+
+##########################################################################################
+
+ifeq ($(BUILD_HEADLESS), true)
+ifneq ($(OPENJDK_TARGET_OS), windows)
+
+LIBAWT_HEADLESS_DIRS:=$(JDK_TOPDIR)/src/share/native/sun/font \
+                        $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
+			$(JDK_TOPDIR)/src/solaris/native/sun/font \
+			$(JDK_TOPDIR)/src/solaris/native/sun/awt \
+			$(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
+			$(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
+
+LIBAWT_HEADLESS_CFLAGS:=-DHEADLESS=true \
+                          -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
+			  $(CUPS_CFLAGS) \
+			  $(X_CFLAGS) \
+			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
+			  -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
+			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
+			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
+			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
+			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+			  -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/jdga \
+                          $(foreach dir,$(LIBAWT_HEADLESS_DIRS),-I$(dir))
+
+LIBAWT_HEADLESS_FILES:=\
+	awt_Font.c \
+	HeadlessToolkit.c \
+	fontpath.c \
+	VDrawingArea.c \
+	X11Color.c \
+	X11Renderer.c \
+	X11PMBlitLoops.c \
+	X11SurfaceData.c \
+	X11FontScaler_md.c \
+	X11TextRenderer_md.c \
+        OGLBlitLoops.c \
+        OGLBufImgOps.c \
+        OGLContext.c \
+        OGLFuncs.c \
+        OGLMaskBlit.c \
+        OGLMaskFill.c \
+        OGLPaints.c \
+        OGLRenderQueue.c \
+        OGLRenderer.c \
+        OGLSurfaceData.c \
+        OGLTextRenderer.c \
+        OGLVertexCache.c \
+        GLXGraphicsConfig.c \
+        GLXSurfaceData.c \
+        AccelGlyphCache.c \
+	CUPSfuncs.c
+
+LIBAWT_HEADLESS_LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) -lawt -lm
+
+LIBAWT_HEADLESS_REORDER:=
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+	ifneq ($(ARCH), amd64)
+		LIBAWT_HEADLESS_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/reorder-$(ARCH)
+	endif
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS,\
+		LIBRARY:=awt_headless,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(LIBAWT_HEADLESS_DIRS),\
+		INCLUDE_FILES:=$(LIBAWT_HEADLESS_FILES),\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBAWT_HEADLESS_CFLAGS),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		REORDER:=$(LIBAWT_HEADLESS_REORDER), \
+		LDFLAGS_SUFFIX:=$(LIBAWT_HEADLESS_LDFLAGS_SUFFIX),\
+		LDFLAGS_SUFFIX_posix:=$(LIBDL),\
+		LDFLAGS_SUFFIX_macosx:=$(LIBCXX), \
+		LDFLAGS_SUFFIX_solaris:=$(LIBCXX), \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless))
+
+$(BUILD_LIBAWT_HEADLESS) : $(BUILD_LIBAWT)
+
+BUILD_LIBRARIES += $(BUILD_LIBAWT_HEADLESS)
 
 endif
 endif
@@ -1932,38 +2319,38 @@
 ##########################################################################################
 
 ifndef BUILD_HEADLESS_ONLY
-LIBSPLASHSCREEN_DIRS := \
+LIBSPLASHSCREEN_DIRS:=\
 	$(JDK_TOPDIR)/src/share/native/sun/awt/giflib \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/libpng \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen \
-        $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/awt/splashscreen
-
-LIBSPLASHSCREEN_CFLAGS := -DSPLASHSCREEN -DPNG_NO_MMX_CODE \
+        $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt/splashscreen
+
+LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \
 	$(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir))
 
-ifeq ($(PLATFORM), macosx)
-	LIBSPLASHSCREEN_CFLAGS := -I$(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen \
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+	LIBSPLASHSCREEN_CFLAGS:=-I$(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen \
                                   $(LIBSPLASHSCREEN_CFLAGS) \
                                   -F/System/Library/Frameworks/JavaVM.framework/Frameworks
 	LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX
 	LIBSPLASHSCREEN_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp
 
-	LIBSPLASHSCREEN_java_awt_SplashScreen.c_CFLAGS := -x objective-c -O0
-	LIBSPLASHSCREEN_splashscreen_gfx_impl.c_CFLAGS := -x objective-c -O0
-	LIBSPLASHSCREEN_splashscreen_gif.c_CFLAGS := -x objective-c -O0
-	LIBSPLASHSCREEN_splashscreen_impl.c_CFLAGS := -x objective-c -O0
-	LIBSPLASHSCREEN_splashscreen_jpeg.c_CFLAGS := -x objective-c -O0
-	LIBSPLASHSCREEN_splashscreen_png.c_CFLAGS := -x objective-c -O0
-	LIBSPLASHSCREEN_splashscreen_sys.m_CFLAGS := -O0
-
-else ifneq ($(PLATFORM), windows)
+	LIBSPLASHSCREEN_java_awt_SplashScreen.c_CFLAGS:=-x objective-c -O0
+	LIBSPLASHSCREEN_splashscreen_gfx_impl.c_CFLAGS:=-x objective-c -O0
+	LIBSPLASHSCREEN_splashscreen_gif.c_CFLAGS:=-x objective-c -O0
+	LIBSPLASHSCREEN_splashscreen_impl.c_CFLAGS:=-x objective-c -O0
+	LIBSPLASHSCREEN_splashscreen_jpeg.c_CFLAGS:=-x objective-c -O0
+	LIBSPLASHSCREEN_splashscreen_png.c_CFLAGS:=-x objective-c -O0
+	LIBSPLASHSCREEN_splashscreen_sys.m_CFLAGS:=-O0
+
+else ifneq ($(OPENJDK_TARGET_OS), windows)
 	LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
 else
 	LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32
 endif
 
-LIBSPLASHSCREEN_FILES := \
+LIBSPLASHSCREEN_FILES:=\
 	java_awt_SplashScreen.c \
 	splashscreen_gfx_impl.c \
 	splashscreen_gif.c \
@@ -2033,14 +2420,14 @@
 	jfdctfst.c \
 	jfdctint.c
 
-ifneq ($(PLATFORM), macosx)
+ifneq ($(OPENJDK_TARGET_OS), macosx)
 LIBSPLASHSCREEN_FILES += splashscreen_sys.c
 else
 LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen
 LIBSPLASHSCREEN_FILES += splashscreen_sys.m
 endif
 
-LIBSPLASHSCREEN_LDFLAGS_SUFFIX :=
+LIBSPLASHSCREEN_LDFLAGS_SUFFIX:=
 
 ifneq ($(USE_EXTERNAL_LIBZ),true)
 	LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
@@ -2063,422 +2450,205 @@
 		zutil.c
 endif
 
-ifeq ($(PLATFORM), macosx)
+ifeq ($(OPENJDK_TARGET_OS), macosx)
 	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += $(LIBM) -lpthread -liconv -losxapp \
 				  -framework ApplicationServices \
 				  -framework Foundation \
 				  -framework Cocoa \
                                   -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
 				  -framework JavaNativeFoundation
-else ifneq ($(PLATFORM), windows)
-	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(ISA_DIR) -lX11 -lXext $(LIBM) -lpthread $(LIBDL)
-else # PLATFORM
+else ifneq ($(OPENJDK_TARGET_OS), windows)
+	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(ISA_DIR) -lX11 -lXext $(LIBM) -lpthread
+else # OPENJDK_TARGET_OS
 	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
-endif # PLATFORM
+endif # OPENJDK_TARGET_OS
 
 $(eval $(call SetupNativeCompilation,LIBSPLASHSCREEN,\
+		LIBRARY:=splashscreen,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBSPLASHSCREEN_DIRS),\
-		INCLUDE_FILES := $(LIBSPLASHSCREEN_FILES),\
+		INCLUDE_FILES:=$(LIBSPLASHSCREEN_FILES),\
 		LANG:=C,\
-		CFLAGS:= $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libsplashscreen/mapfile-vers, \
-		LDFLAGS:= $(LDFLAGS_JDKLIB) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsplashscreen/mapfile-vers, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX := $(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libsplashscreen,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)splashscreen$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)splashscreen$(SHARED_LIBRARY_SUFFIX)
-
-ifeq ($(PLATFORM),macosx)
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)splashscreen$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX) 
+		LDFLAGS_SUFFIX_linux:=$(LIBDL), \
+		LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ),\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsplashscreen))
+
+BUILD_LIBRARIES += $(LIBSPLASHSCREEN)
+
+ifeq ($(OPENJDK_TARGET_OS),macosx)
+$(LIBSPLASHSCREEN) :  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX) 
 endif
 
 endif
 
 ##########################################################################################
 
-LIBAWT_DIRS := \
-	$(JDK_TOPDIR)/src/share/native/sun/awt \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/awt \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/image \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/image/gif \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/shell \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/medialib \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/utility \
-	$(JDK_TOPDIR)/src/share/native/sun/java2d \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d \
-	$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
-	$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-	$(JDK_TOPDIR)/src/share/native/sun/awt/image \
-	$(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/opengl \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/x11 \
-	$(JDK_TOPDIR)/src/share/native/sun/font \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/windows \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/windows \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/java2d/d3d
-
-
-LIBAWT_CFLAGS := -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES \
-	$(foreach dir,$(LIBAWT_DIRS),-I$(dir))
-
-LIBAWT_FILES := \
-	gifdecoder.c \
-	imageInitIDs.c \
-	img_globals.c \
-	SurfaceData.c \
-	Region.c \
-	BufImgSurfaceData.c \
-	Disposer.c \
-	Trace.c \
-	GraphicsPrimitiveMgr.c \
-	Blit.c \
-	BlitBg.c \
-	ScaledBlit.c \
-	FillRect.c \
-	FillSpans.c \
-	FillParallelogram.c \
-	DrawParallelogram.c \
-	DrawLine.c \
-	DrawRect.c \
-	DrawPolygons.c \
-	DrawPath.c \
-	FillPath.c \
-	ProcessPath.c \
-	MaskBlit.c \
-	MaskFill.c \
-	TransformHelper.c \
-	AlphaMath.c \
-	AlphaMacros.c \
-	AnyByte.c \
-	ByteBinary1Bit.c \
-	ByteBinary2Bit.c \
-	ByteBinary4Bit.c \
-	ByteIndexed.c \
-	ByteGray.c \
-	Index8Gray.c \
-	Index12Gray.c \
-	AnyShort.c \
-	Ushort555Rgb.c \
-	Ushort565Rgb.c \
-	Ushort4444Argb.c \
-	Ushort555Rgbx.c \
-	UshortGray.c \
-	UshortIndexed.c \
-	Any3Byte.c \
-	ThreeByteBgr.c \
-	AnyInt.c \
-	IntArgb.c \
-	IntArgbPre.c \
-	IntArgbBm.c \
-	IntRgb.c \
-	IntBgr.c \
-	IntRgbx.c \
-	Any4Byte.c \
-	FourByteAbgr.c \
-	FourByteAbgrPre.c \
-	BufferedMaskBlit.c \
-	BufferedRenderPipe.c \
-	ShapeSpanIterator.c \
-	SpanClipRenderer.c \
-	awt_ImageRep.c \
-	awt_ImagingLib.c \
-	awt_Mlib.c \
-	awt_parseImage.c \
-	DataBufferNative.c \
-	dither.c \
-	debug_assert.c \
-	debug_mem.c \
-	debug_trace.c \
-	debug_util.c
-
-ifneq (,$(filter $(PLATFORM), solaris linux))
-	LIBAWT_FILES += awt_LoadLibrary.c initIDs.c img_colors.c
-endif
-
-ifeq ($(PLATFORM),macosx)
-	LIBAWT_DIRS += $(JDK_TOPDIR)/src/macosx/native/com/apple/resources
-	LIBAWT_FILES += awt_LoadLibrary.c MacOSXResourceBundle.m
-	LIBAWT_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks
-
-	LIBAWT_MacOSXResourceBundle.m_CFLAGS := -O0
-endif
-
-ifeq ($(PLATFORM)-$(ARCH_FAMILY), solaris-sparc)
-#
-# TODO...
-#
-
-#	FILES_c += $(FILES_2D_vis)
-#	ASFLAGS += -P
-#	FILES_s += mlib_v_ImageCopy_blk.s
-#	INLINE_VIS = $(PLATFORM_SRC)/native/sun/awt/medialib/vis_$(ARCH_DATA_MODEL).il
-#	CFLAGS_sparcv9 = -DMLIB_OS64BIT
-#	CFLAGS += $(CFLAGS_$(ARCH)) -DMLIB_ADD_SUFF $(INLINE_VIS)
-else
-	LIBAWT_FILES += MapAccelFunc.c
-endif
-
-ifneq ($(PLATFORM),solaris)
-	LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH
-endif
-
-LIBAWT_LANG := C
-
-ifeq ($(PLATFORM),windows)
-	LIBAWT_FILES += AccelGlyphCache.c \
-			ShaderList.c \
-			CmdIDList.cpp \
-			Hashtable.cpp \
-			GDIHashtable.cpp \
-			Devices.cpp \
-			ObjectList.cpp \
-			GDIBlitLoops.cpp \
-			GDIRenderer.cpp \
-			GDIWindowSurfaceData.cpp \
-			WindowsFlags.cpp \
-			WPrinterJob.cpp \
-			awt_%.cpp \
-			D3DBlitLoops.cpp \
-			D3DBufImgOps.cpp \
-			D3DContext.cpp \
-			D3DGlyphCache.cpp \
-			D3DGraphicsDevice.cpp \
-			D3DMaskBlit.cpp \
-			D3DMaskCache.cpp \
-			D3DMaskFill.cpp \
-			D3DPipelineManager.cpp \
-			D3DPaints.cpp \
-			D3DRenderer.cpp \
-			D3DRenderQueue.cpp \
-			D3DResourceManager.cpp \
-			D3DSurfaceData.cpp \
-			D3DTextRenderer.cpp \
-			D3DVertexCacher.cpp \
-			ShellFolder2.cpp \
-			ThemeReader.cpp \
-			ComCtl32Util.cpp \
-			DllUtil.cpp \
-			initIDs.cpp \
-			MouseInfo.cpp \
-			rect.c
-	LIBAWT_LANG := C++
-	LIBAWT_CFLAGS += $(GX_OPTION) -DUNICODE -D_UNICODE
-	ifeq ($(ARCH_DATA_MODEL), 64)
-		LIBAWT_CFLAGS += -DMLIB_OS64BIT
-	endif
-
-	ifdef OPENJDK
-		LIBAWT_RC_FLAGS := -i "$(JDK_TOPDIR)/src/windows/resource/icons"
-	else
-		LIBAWT_RC_FLAGS := -i "$(JDK_TOPDIR)/src/closed/windows/native/sun/windows"
-	endif
-	LIBAWT_VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/native/sun/windows/awt.rc
-endif
-
-ifeq ($(MILESTONE), internal)
-	LIBAWT_CFLAGS += -DINTERNAL_BUILD
-endif
-
-LIBAWT_MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libawt/mapfile-vers
-ifeq ($(PLATFORM),linux)
-	LIBAWT_MAPFILE :=
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBAWT,\
-		SRC:=$(LIBAWT_DIRS),\
-		INCLUDE_FILES := $(LIBAWT_FILES),\
-		LANG:=$(LIBAWT_LANG),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) $(LIBAWT_CFLAGS),\
-		MAPFILE := $(LIBAWT_MAPFILE), \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_windows:=advapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
-				 imm32.lib ole32.lib uuid.lib shell32.lib \
-				 comdlg32.lib winmm.lib comctl32.lib \
-				 shlwapi.lib delayimp.lib java.lib jvm.lib \
-				 /DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
-				 /DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
-				 /DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
-				 /DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
-				 /DELAYLOAD:comctl32.dll /DELAYLOAD:shlwapi.dll,\
-		LDFLAGS_macosx :=-framework Cocoa \
-				 -framework OpenGL \
-				 -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-				 -framework JavaNativeFoundation \
-				 -framework JavaRuntimeSupport \
-				 -framework ApplicationServices \
-				 -framework AudioToolbox,\
-		LDFLAGS_solaris := -R/usr/dt/lib$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR),\
-		LDFLAGS_SUFFIX_posix := -ljvm $(LIBM) -ljava $(LIBDL),\
-		VERSIONINFO_RESOURCE := $(LIBAWT_VERSIONINFO_RESOURCE),\
-		RC_FLAGS := $(RC_FLAGS) $(LIBAWT_RC_FLAGS) \
-			  /D "JDK_FNAME=awt.dll" \
-			  /D "JDK_INTERNAL_NAME=awt" \
-			  /D "JDK_FTYPE=0x2L",\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libawt,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX)
-
-##########################################################################################
-
 ifndef OPENJDK
 
-LIBDCPR_SRC_DIRS := \
+LIBDCPR_SRC_DIRS:=\
 	$(JDK_TOPDIR)/src/closed/share/native/sun/dc/doe \
 	$(JDK_TOPDIR)/src/closed/share/native/sun/dc/path \
 	$(JDK_TOPDIR)/src/closed/share/native/sun/dc/pr \
 	$(JDK_TOPDIR)/src/closed/share/native/sun/dc/util
 
-LIBDCPR_CFLAGS := $(foreach dir,$(LIBDCPR_SRC_DIRS),-I$(dir)) \
+LIBDCPR_CFLAGS:=$(foreach dir,$(LIBDCPR_SRC_DIRS),-I$(dir)) \
 	          -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBDCPR,\
+		LIBRARY:=dcpr,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBDCPR_SRC_DIRS),\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			$(LIBDCPR_CFLAGS), \
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libdcpr/mapfile-vers, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libdcpr/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LIBM)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_posix := $(LIBDL) -lm,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libdcpr,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)dcpr$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)dcpr$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)dcpr$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX_posix:=-lm,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdcpr))
+
+$(BUILD_LIBDCPR) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBDCPR)
 
 endif
 
 ##########################################################################################
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PCSC,\
+		LIBRARY:=j2pcsc,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \
-                     $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/smartcardio,\
+                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio,\
 		LANG:=C,\
-		CFLAGS_posix:= -D__sun_jdk,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		CFLAGS_posix:=-D__sun_jdk,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
                      -I$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \
-                     -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/smartcardio\
-                     -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/smartcardio/MUSCLE,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libj2pcsc/mapfile-vers, \
+                     -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio\
+                     -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio/MUSCLE,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2pcsc/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_posix := $(LIBDL), \
-		LDFLAGS_SUFFIX_windows := winscard.lib,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libj2pcsc,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)j2pcsc$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)j2pcsc$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX_posix:=$(LIBDL), \
+		LDFLAGS_SUFFIX_windows:=winscard.lib,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pcsc))
+
+BUILD_LIBRARIES += $(BUILD_LIBJ2PCSC)
 
 ##########################################################################################
 
-ifneq ($(PLATFORM), windows)
+ifneq ($(OPENJDK_TARGET_OS), windows)
 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2GSS,\
+		LIBRARY:=j2gss,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/jgss/wrapper \
-                     $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/jgss/wrapper,\
+                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/jgss/wrapper,\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
                      -I$(JDK_TOPDIR)/src/share/native/sun/security/jgss/wrapper \
-                     -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/jgss/wrapper,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libj2gss/mapfile-vers, \
+                     -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/jgss/wrapper,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2gss/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX := $(LIBDL), \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libj2gss,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)j2gss$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)j2gss$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX:=$(LIBDL), \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2gss))
+
+BUILD_LIBRARIES += $(BUILD_LIBJ2GSS)
 endif
 
 ##########################################################################################
 
-BUILD_LIBKRB5_NAME :=
-ifeq ($(PLATFORM), windows)
-     BUILD_LIBKRB5_NAME := w2k_lsa_auth
-     BUILD_LIBKRB5_FILES := NativeCreds.c WindowsDirectory.c
-     BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/krb5
-     BUILD_LIBKRB5_LIBS := Secur32.lib netapi32.lib \
+BUILD_LIBKRB5_NAME:=
+ifeq ($(OPENJDK_TARGET_OS), windows)
+     BUILD_LIBKRB5_NAME:=w2k_lsa_auth
+     BUILD_LIBKRB5_FILES:=NativeCreds.c WindowsDirectory.c
+     BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/krb5
+     BUILD_LIBKRB5_LIBS:=Secur32.lib netapi32.lib \
 	kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib \
 	advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib \
 	odbccp32.lib wsock32.lib
-else ifeq ($(PLATFORM), macosx)
-     BUILD_LIBKRB5_NAME := osxkrb5
-     BUILD_LIBKRB5_FILES := nativeccache.c
-     BUILD_LIBKRB5_LIBS := -framework Kerberos
+else ifeq ($(OPENJDK_TARGET_OS), macosx)
+     BUILD_LIBKRB5_NAME:=osxkrb5
+     BUILD_LIBKRB5_FILES:=nativeccache.c
+     BUILD_LIBKRB5_LIBS:=-framework Kerberos
 endif
 
 ifneq ($(BUILD_LIBKRB5_NAME),)
 $(eval $(call SetupNativeCompilation,BUILD_LIBKRB5,\
+		LIBRARY:=$(BUILD_LIBKRB5_NAME),\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/krb5 \
                      $(BUILD_LIBKRB5_SRC) ,\
-		INCLUDE_FILES := $(BUILD_LIBKRB5_FILES),\
+		INCLUDE_FILES:=$(BUILD_LIBKRB5_FILES),\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5 \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/krb5 ,\
+                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/krb5 ,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX := $(BUILD_LIBKRB5_LIBS) ,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libkrb5,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)$(BUILD_LIBKRB5_NAME)$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)$(BUILD_LIBKRB5_NAME)$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX:=$(BUILD_LIBKRB5_LIBS) ,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5))
+
+BUILD_LIBRARIES += $(BUILD_LIBKRB5)
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), windows)
+ifeq ($(OPENJDK_TARGET_OS), windows)
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBSUNMSCAPI,\
+		LIBRARY:=sunmscapi,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/mscapi \
-		     $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/mscapi,\
-		INCLUDE_FILES := security.cpp, \
+		     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/mscapi,\
+		INCLUDE_FILES:=security.cpp, \
 		LANG:=C++,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/mscapi \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/mscapi ,\
+                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/mscapi ,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX := Crypt32.Lib advapi32.lib,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libsunmscapi,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)sunmscapi$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)sunmscapi$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX:=Crypt32.Lib advapi32.lib,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunmscapi))
+
+BUILD_LIBRARIES += $(BUILD_LIBSUNMSCAPI)
 endif
 
 ##########################################################################################
 
-ifneq ($(PLATFORM)-$(ARCH_DATA_MODEL), windows-64)
+ifneq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL), windows-64)
 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11,\
+		LIBRARY:=j2pkcs11,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/pkcs11 \
-                     $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/pkcs11 \
+                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11 \
                      $(JDK_TOPDIR)/src/share/native/sun/security/pkcs11/wrapper \
-                     $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/pkcs11/wrapper,\
+                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11/wrapper,\
 		LANG:=C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/pkcs11 \
-		        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/pkcs11 \
+		        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11 \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/pkcs11/wrapper \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/sun/security/pkcs11/wrapper,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libj2pkcs11/mapfile-vers, \
+                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11/wrapper,\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2pkcs11/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_posix := $(LIBDL), \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)j2pkcs11$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)j2pkcs11$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX_posix:=$(LIBDL), \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11))
+
+BUILD_LIBRARIES += $(BUILD_LIBJ2PKCS11)
 endif
 
 ##########################################################################################
@@ -2488,40 +2658,56 @@
 # TODO Set DISABLE_INTREE_EC in configure if src/share/native/sun/security/ec/impl
 #      is not present
 #
-BUILD_LIBSUNEC_FLAGS := -DMP_API_COMPATIBLE -DNSS_ECC_MORE_THAN_SUITE_B \
-                        -I$(JDK_TOPDIR)/src/share/native/sun/security/ec \
-                        -I$(JDK_TOPDIR)/src/share/native/sun/security/ec/impl
+BUILD_LIBSUNEC_FLAGS:= -I$(JDK_TOPDIR)/src/share/native/sun/security/ec \
+                       -I$(JDK_TOPDIR)/src/share/native/sun/security/ec/impl
+
+#
+# On sol-sparc...all libraries are compiled with -xregs=no%appl
+#   (set in CFLAGS_REQUIRED_sparc)
+#
+# except!!! libsunec.so
+#
+ECC_JNI_SOLSPARC_FILTER:=
+ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
+     ECC_JNI_SOLSPARC_FILTER:=-xregs=no%appl
+endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBSUNEC,\
+		LIBRARY:=sunec,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/ec \
                      $(JDK_TOPDIR)/src/share/native/sun/security/ec/impl, \
-		LANG := C++, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) $(BUILD_LIBSUNEC_FLAGS),\
-		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(CXX_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) $(BUILD_LIBSUNEC_FLAGS),\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libsunec/mapfile-vers, \
+		LANG:=C++, \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(filter-out $(ECC_JNI_SOLSPARC_FILTER), $(CFLAGS_JDKLIB))\
+                        $(BUILD_LIBSUNEC_FLAGS) \
+                        -DMP_API_COMPATIBLE -DNSS_ECC_MORE_THAN_SUITE_B,\
+		CXXFLAGS:=$(filter-out $(ECC_JNI_SOLSPARC_FILTER), $(CXXFLAGS_JDKLIB)) \
+                          $(BUILD_LIBSUNEC_FLAGS),\
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsunec/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX := $(LIBCXX),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libsunec,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)sunec$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)sunec$(SHARED_LIBRARY_SUFFIX)
+		LDFLAGS_SUFFIX:=$(LIBCXX),\
+                LDFLAGS_SUFFIX_solaris:=-lc ,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunec))
+
+BUILD_LIBRARIES += $(BUILD_LIBSUNEC)
 endif
 
 ##########################################################################################
 
-LIBJSOUND_SRC_DIRS := \
+LIBJSOUND_SRC_DIRS:=\
 	$(JDK_TOPDIR)/src/share/native/com/sun/media/sound \
-	$(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/native/com/sun/media/sound
-
-LIBJSOUND_SRC_FILES := Utilities.c Platform.c
-
-LIBJSOUND_LANG := C
-LIBJSOUND_CFLAGS := $(foreach dir,$(LIBJSOUND_SRC_DIRS),-I$(dir))
-
-EXTRA_SOUND_JNI_LIBS := 
-
-LIBJSOUND_MIDIFILES := \
+	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/com/sun/media/sound
+
+LIBJSOUND_SRC_FILES:=Utilities.c Platform.c
+
+LIBJSOUND_LANG:=C
+LIBJSOUND_CFLAGS:=$(foreach dir,$(LIBJSOUND_SRC_DIRS),-I$(dir))
+
+EXTRA_SOUND_JNI_LIBS:=
+
+LIBJSOUND_MIDIFILES:=\
 	MidiInDevice.c \
 	MidiInDeviceProvider.c \
 	MidiOutDevice.c \
@@ -2529,16 +2715,16 @@
 	PlatformMidi.c
 
 # files needed for ports
-LIBJSOUND_PORTFILES := \
+LIBJSOUND_PORTFILES:=\
 	PortMixerProvider.c \
 	PortMixer.c
 
 # files needed for direct audio
-LIBJSOUND_DAUDIOFILES := \
+LIBJSOUND_DAUDIOFILES:=\
 	DirectAudioDeviceProvider.c \
 	DirectAudioDevice.c
 
-ifeq ($(PLATFORM), windows)
+ifeq ($(OPENJDK_TARGET_OS), windows)
 	EXTRA_SOUND_JNI_LIBS += jsoundds
 	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_WINDOWS \
                             -DUSE_PLATFORM_MIDI_OUT=TRUE \
@@ -2551,15 +2737,15 @@
 		PLATFORM_API_WinOS_Ports.c
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
-endif # PLATFORM windows
-
-ifeq ($(PLATFORM), linux)
+endif # OPENJDK_TARGET_OS windows
+
+ifeq ($(OPENJDK_TARGET_OS), linux)
 	EXTRA_SOUND_JNI_LIBS += jsoundalsa
 	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_LINUX
-endif # PLATFORM linux
-
-ifeq ($(PLATFORM), macosx)
-	LIBJSOUND_LANG := C++
+endif # OPENJDK_TARGET_OS linux
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+	LIBJSOUND_LANG:=C++
 	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_MACOSX \
                             -DUSE_PORTS=TRUE \
                             -DUSE_DAUDIO=TRUE \
@@ -2576,9 +2762,9 @@
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
-endif # PLATFORM macosx
-
-ifeq ($(PLATFORM), solaris)
+endif # OPENJDK_TARGET_OS macosx
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
 	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_SOLARIS \
                             -DUSE_PORTS=TRUE \
                             -DUSE_DAUDIO=TRUE
@@ -2589,7 +2775,7 @@
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
 	LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
-endif # PLATFORM solaris
+endif # OPENJDK_TARGET_OS solaris
 
 
 ifeq ($(JVM_VARIANT_ZERO), true)
@@ -2623,37 +2809,38 @@
 LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND,\
+		LIBRARY:=jsound,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBJSOUND_SRC_DIRS),\
-		INCLUDE_FILES := $(LIBJSOUND_SRC_FILES),\
+		INCLUDE_FILES:=$(LIBJSOUND_SRC_FILES),\
 		LANG:=$(LIBJSOUND_LANG),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-			$(LIBJSOUND_CFLAGS), \
-		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(CXX_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-			$(LIBJSOUND_CFLAGS), \
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjsound/mapfile-vers, \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
+		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsound/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_windows:=java.lib advapi32.lib winmm.lib,\
+		LDFLAGS_windows:=$(WIN_JAVA_LIB) advapi32.lib winmm.lib,\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
 		LDFLAGS_SUFFIX_solaris:=-lc ,\
-		LDFLAGS_SUFFIX_macosx := -framework CoreAudio -framework CoreFoundation \
+		LDFLAGS_SUFFIX_macosx:=-framework CoreAudio -framework CoreFoundation \
              -framework CoreServices -framework AudioUnit $(LIBCXX) \
              -framework CoreMIDI -framework AudioToolbox ,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjsound,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsound$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsound$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jsound$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsound))
+
+$(BUILD_LIBJSOUND) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJSOUND)
 
 ##########################################################################################
 
 ifneq ($(filter jsoundalsa, $(EXTRA_SOUND_JNI_LIBS)),)
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDALSA,\
+		LIBRARY:=jsoundalsa,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBJSOUND_SRC_DIRS),\
-		INCLUDE_FILES := Utilities.c $(LIBJSOUND_MIDIFILES) $(LIBJSOUND_PORTFILES) \
+		INCLUDE_FILES:=Utilities.c $(LIBJSOUND_MIDIFILES) $(LIBJSOUND_PORTFILES) \
                                 $(LIBJSOUND_DAUDIOFILES) \
 				PLATFORM_API_LinuxOS_ALSA_CommonUtils.c   \
 				PLATFORM_API_LinuxOS_ALSA_PCM.c     \
@@ -2662,24 +2849,23 @@
 				PLATFORM_API_LinuxOS_ALSA_MidiOut.c \
 				PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
 				PLATFORM_API_LinuxOS_ALSA_Ports.c,\
-		LANG := C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			$(LIBJSOUND_CFLAGS) \
 			-DUSE_DAUDIO=TRUE \
 			-DUSE_PORTS=TRUE  \
 			-DUSE_PLATFORM_MIDI_OUT=TRUE \
 			-DUSE_PLATFORM_MIDI_IN=TRUE, \
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libjsoundalsa/mapfile-vers, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsoundalsa/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) -lasound,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsoundalsa$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsoundalsa$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jsoundalsa$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa))
+
+$(BUILD_LIBJSOUNDALSA) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJSOUNDALSA)
 
 endif
 
@@ -2688,104 +2874,113 @@
 ifneq ($(filter jsoundds, $(EXTRA_SOUND_JNI_LIBS)),)
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDDS,\
+		LIBRARY:=jsoundds,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBJSOUND_SRC_DIRS),\
-		INCLUDE_FILES := Utilities.c $(LIBJSOUND_DAUDIOFILES) \
+		INCLUDE_FILES:=Utilities.c $(LIBJSOUND_DAUDIOFILES) \
 				PLATFORM_API_WinOS_DirectSound.cpp, \
-		LANG := C++,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		LANG:=C++,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			$(LIBJSOUND_CFLAGS) \
 			-DUSE_DAUDIO=TRUE, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) dsound.lib winmm.lib user32.lib ole32.lib,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libjsoundds,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsoundds$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jsoundds$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)jsoundds$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundds))
+
+$(BUILD_LIBJSOUNDDS) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJSOUNDDS)
 
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), solaris)
+ifeq ($(OPENJDK_TARGET_OS), solaris)
 ifndef OPENJDK
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2UCRYPTO,\
+		LIBRARY:=j2ucrypto,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/closed/solaris/native/com/oracle/security/ucrypto,\
-		LANG := C,\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/closed/solaris/native/com/oracle/security/ucrypto ,\
-		MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/libj2ucrypto/mapfile-vers, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2ucrypto/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
 		LDFLAGS_SUFFIX:=$(LIBDL),\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)j2ucrypto$(SHARED_LIBRARY_SUFFIX)))
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)j2ucrypto$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)j2ucrypto$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto))
+
+$(BUILD_LIBJ2UCRYPTO) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBJ2UCRYPTO)
 
 endif
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), macosx)
-
-LIBAPPLESCRIPTENGINE_FILES := \
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+
+LIBAPPLESCRIPTENGINE_FILES:=\
 	AppleScriptEngine.m \
         AppleScriptExecutionContext.m \
         AS_NS_ConversionUtils.m \
         NS_Java_ConversionUtils.m
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBAPPLESCRIPTENGINE,\
+		LIBRARY:=AppleScriptEngine,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/macosx/native/apple/applescript,\
-		LANG := C,\
+		LANG:=C,\
 		INCLUDE_FILES:=$(LIBAPPLESCRIPTENGINE_FILES),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/macosx/native/apple/applescript \
 			-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                         -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX:= \
+		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) \
     -framework Cocoa \
     -framework Carbon \
     -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
     -framework JavaNativeFoundation, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)AppleScriptEngine$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)AppleScriptEngine$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine))
+
+$(BUILD_LIBAPPLESCRIPTENGINE) : $(BUILD_LIBJAVA)
+
+BUILD_LIBRARIES += $(BUILD_LIBAPPLESCRIPTENGINE)
 
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), macosx)
-
-LIBOSXAPP_FILES := \
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+
+LIBOSXAPP_FILES:=\
 	NSApplicationAWT.m \
 	QueuingApplicationDelegate.m \
 	PropertiesUtilities.m \
 	ThreadUtilities.m
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBOSXAPP,\
+		LIBRARY:=osxapp,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/macosx/native/sun/osxapp,\
-		LANG := C,\
+		LANG:=C,\
 		INCLUDE_FILES:=$(LIBOSXAPP_FILES),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \
                         -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                         -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_macosx := \
+		LDFLAGS_SUFFIX_macosx:=\
 	-framework Accelerate \
 	-framework ApplicationServices \
 	-framework AudioToolbox \
@@ -2799,18 +2994,17 @@
 	-framework OpenGL \
 	-framework IOSurface \
 	-framework QuartzCore, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libosxapp,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxapp))
+
+BUILD_LIBRARIES += $(BUILD_LIBOSXAPP)
 
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), macosx)
-
-LIBOSX_FILES := \
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+
+LIBOSX_FILES:=\
     Dispatch.m \
     CFileManager.m \
     KeystoreImpl.m \
@@ -2818,7 +3012,7 @@
     MacOSXPreferencesFile.m \
     SCDynamicStoreConfig.m
 
-LIBOSX_DIRS := \
+LIBOSX_DIRS:=\
   $(JDK_TOPDIR)/src/macosx/native/com/apple/concurrent \
   $(JDK_TOPDIR)/src/macosx/native/java/util \
   $(JDK_TOPDIR)/src/macosx/native/com/apple/eio \
@@ -2826,17 +3020,20 @@
   $(JDK_TOPDIR)/src/macosx/native/apple/launcher
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBOSX,\
+		LIBRARY:=osx,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBOSX_DIRS),\
-		LANG := C,\
+		LANG:=C,\
 		INCLUDE_FILES:=$(LIBOSX_FILES),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
                         $(foreach dir,$(LIBOSX_DIRS),-I$(dir)) \
                         -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \
                         -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                         -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_macosx := \
+		LDFLAGS_SUFFIX_macosx:=\
     -losxapp \
     -framework Cocoa \
     -framework ApplicationServices \
@@ -2846,24 +3043,21 @@
     -framework Security \
     -framework SystemConfiguration \
     $(LDFLAGS_JDKLIB_SUFFIX), \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libosx,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osx$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osx$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osx$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX) 
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osx$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosx))
+
+BUILD_LIBRARIES += $(BUILD_LIBOSX)
+
+$(BUILD_LIBOSX) : $(BUILD_LIBOSXAPP)
+
+$(BUILD_LIBOSX) : $(BUILD_LIBJAVA)
 
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), macosx)
-
-LIBAWT_LWAWT_FILES := \
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+
+LIBAWT_LWAWT_FILES:=\
         awt.m \
         ApplicationDelegate.m \
         CFRetainedResource.m \
@@ -2938,7 +3132,7 @@
         CUPSfuncs.c
 
 
-LIBAWT_LWAWT_DIRS := \
+LIBAWT_LWAWT_DIRS:=\
   $(JDK_TOPDIR)/src/macosx/native/sun/awt \
   $(JDK_TOPDIR)/src/macosx/native/sun/font \
   $(JDK_TOPDIR)/src/macosx/native/sun/java2d/opengl \
@@ -2947,10 +3141,13 @@
   $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_LWAWT,\
+		LIBRARY:=awt_lwawt,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(LIBAWT_LWAWT_DIRS),\
-		LANG := C,\
+		LANG:=C,\
 		INCLUDE_FILES:=$(LIBAWT_LWAWT_FILES),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
                         $(foreach dir,$(LIBAWT_LWAWT_DIRS),-I$(dir)) \
                         -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \
                         -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
@@ -2964,7 +3161,7 @@
                         -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_macosx := \
+		LDFLAGS_SUFFIX_macosx:=\
 	-lawt -lmlib_image -losxapp $(LDFLAGS_JDKLIB_SUFFIX) $(LIBM) \
 	-framework Accelerate \
 	-framework ApplicationServices \
@@ -2978,30 +3175,25 @@
 	-framework JavaRuntimeSupport \
 	-framework OpenGL \
         -framework QuartzCore ,\
-		BIN:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) 
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX) 
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX) 
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt))
+
+BUILD_LIBRARIES += $(BUILD_LIBAWT_LWAWT)
+
+$(BUILD_LIBAWT_LWAWT) : $(BUILD_LIBAWT) 
+
+$(BUILD_LIBAWT_LWAWT) : $(BUILD_LIBMLIB_IMAGE)
+
+$(BUILD_LIBAWT_LWAWT) : $(BUILD_LIBOSXAPP)
+
+$(BUILD_LIBAWT_LWAWT) : $(BUILD_LIBJAVA)
 
 endif
 
 ##########################################################################################
 
-ifeq ($(PLATFORM), macosx)
-
-LIBOSXUI_FILES := \
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+
+LIBOSXUI_FILES:=\
         AquaFileView.m \
         AquaLookAndFeel.m \
         AquaNativeResources.m \
@@ -3012,17 +3204,21 @@
         ScreenMenu.m
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBOSXUI,\
+		LIBRARY:=osxui,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/macosx/native/com/apple/laf,\
-		LANG := C,\
+		LANG:=C,\
 		INCLUDE_FILES:=$(LIBOSXUI_FILES),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
                         -I$(JDK_TOPDIR)/src/macosx/native/com/apple/laf \
 			-I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \
 			-I$(JDK_TOPDIR)/src/macosx/native/sun/awt \
                         -F/System/Library/Frameworks/JavaVM.framework/Frameworks, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_macosx := \
+		LDFLAGS_SUFFIX_macosx:=\
+    $(LDFLAGS_JDKLIB_SUFFIX) \
     -lawt -losxapp -lawt_lwawt \
     -framework Cocoa \
     -framework Carbon \
@@ -3030,22 +3226,49 @@
     -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
     -framework JavaNativeFoundation \
     -framework JavaRuntimeSupport, \
-		BIN:=$(JDK_OUTPUTDIR)/objs/libosxui,\
-		LIB:=$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osxui$(SHARED_LIBRARY_SUFFIX)))
-
-BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxui$(SHARED_LIBRARY_SUFFIX)
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osxui$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) 
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osxui$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)osxapp$(SHARED_LIBRARY_SUFFIX) 
-
-$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osxui$(SHARED_LIBRARY_SUFFIX) : \
-  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_lwawt$(SHARED_LIBRARY_SUFFIX) 
-
-#$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)osxui$(SHARED_LIBRARY_SUFFIX) : \
-#  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) 
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxui))
+
+BUILD_LIBRARIES += $(BUILD_LIBOSXUI)
+
+$(BUILD_LIBOSXUI) : $(BUILD_LIBAWT) 
+
+$(BUILD_LIBOSXUI) : $(BUILD_LIBOSXAPP)
+
+$(BUILD_LIBOSXUI) : $(BUILD_LIBAWT_LWAWT)
+
+#$(BUILD_LIBOSXUI) : $(BUILD_LIBJAVA)
+
+endif
+
+##########################################################################################
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC,\
+		LIBRARY:=JObjC,\
+                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+		SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/native \
+                     $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/native ,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=-fpascal-strings \
+                        -fobjc-gc \
+                        -gdwarf-2 \
+                        $(CFLAGS_JDKLIB) \
+                        -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+			, \
+		LDFLAGS:=-fpascal-strings \
+                         -fobjc-gc \
+                         -gdwarf-2 \
+                         $(LDFLAGS_JDKLIB)\
+			 $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS_SUFFIX:=-framework Foundation -framework JavaVM \
+                                  -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+                                  -framework JavaNativeFoundation \
+                                  -lffi, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc))
+
+BUILD_LIBRARIES += $(BUILD_LIBJOBJC)
 
 endif