jdk/makefiles/CompileNativeLibraries.gmk
author amurillo
Wed, 15 Aug 2012 16:49:38 -0700
changeset 13465 d3fc5d192448
parent 13164 72c5d01a857d
child 13702 efd6a05935b2
permissions -rw-r--r--
7191765: make jdk8 the default jprt release for hs24 Reviewed-by: jcoomes

#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

defalt: all

include $(SPEC)
include MakeBase.gmk
include NativeCompilation.gmk

# Setup the java compilers for the JDK build.
include Setup.gmk

# 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 target apis.
ifeq ($(OPENJDK_TARGET_OS_API),posix)
    ifneq ($(OPENJDK_TARGET_OS),macosx)
        INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib/$(LIBARCH)
        LIBARCHDIR=$(LIBARCH)/
    else
        INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib
        LIBARCHDIR=/
    endif
else
    INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/bin
endif

BUILD_LIBRARIES=

# 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_LIBFDLIBM_OPTIMIZATION:=HIGH

ifneq ($(OPENJDK_TARGET_OS), solaris)
      BUILD_LIBFDLIBM_OPTIMIZATION:=NONE
endif

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,\
		OPTIMIZATION:=$(BUILD_LIBFDLIBM_OPTIMIZATION), \
		CFLAGS:=$(CFLAGS_JDKLIB) \
			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
		CFLAGS_winapi_debug:=-DLOGGING,\
		ARFLAGS:=$(ARFLAGS),\
		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) \
			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
		LDFLAGS:=-nostdlib -r,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))

$(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) : $(BUILD_LIBFDLIBM)
	$(CP) -a $< $@

BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
endif

##########################################################################################

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,\
		OPTIMIZATION:=HIGH, \
		CFLAGS:=$(CFLAGS_JDKLIB),\
		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),\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libverify,\
		DEBUG_SYMBOLS:=true))

BUILD_LIBRARIES += $(BUILD_LIBVERIFY)

##########################################################################################

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,\
		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)

##########################################################################################

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_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

ifeq ($(ARCH_DATA_MODEL), 64)
	BUILD_LIBMLIB_CFLAGS += -DMLIB_OS64BIT
endif

ifneq ($(OPENJDK_TARGET_OS), windows)
	BUILD_LIBMLIB_LDLIBS += $(LIBM) $(LIBDL)
endif

$(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE,\
		LIBRARY:=mlib_image,\
                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
                SRC:=$(BUILD_LIBMLIB_SRC),\
		EXCLUDE_FILES:=awt_ImagingLib.c mlib_c_ImageBlendTable.c,\
		LANG:=C,\
		OPTIMIZATION:=HIGHEST, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
                        $(BUILD_LIBMLIB_CFLAGS),\
		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,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image))

$(BUILD_LIBMLIB_IMAGE) : $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBMLIB_IMAGE)

##########################################################################################

ifeq ($(OPENJDK_TARGET_OS),solaris)
ifeq ($(ARCH),sparc)
	BUILD_LIBMLIB_IMAGE_V:=1
else ifeq ($(ARCH), sparcv9)
	BUILD_LIBMLIB_IMAGE_V:=1
endif
endif

ifeq ($(BUILD_LIBMLIB_IMAGE_V), 1)

BUILD_LIBMLIB_IMAGE_V_FILES:=\
        mlib_v_ImageLookUp.c \
        mlib_ImageCreate.c \
        mlib_ImageAffine.c \
        mlib_ImageConvMxN.c \
        mlib_ImageConvKernelConvert.c \
        mlib_sys.c \
        mlib_ImageLookUp_64.c \
        mlib_ImageLookUp_Bit.c \
        mlib_ImageColorTrue2Index.c \
        mlib_c_ImageThresh1_U8.c \
        mlib_v_ImageLookUpS16S16Func.c \
        mlib_v_ImageLookUpS16S32Func.c \
        mlib_v_ImageLookUpS16U16Func.c \
        mlib_v_ImageLookUpS16U8Func.c \
        mlib_v_ImageLookUpS32S16Func.c \
        mlib_v_ImageLookUpS32S32Func.c \
        mlib_v_ImageLookUpS32U16Func.c \
        mlib_v_ImageLookUpS32U8Func.c \
        mlib_v_ImageLookUpSIS16S16Func.c \
        mlib_v_ImageLookUpSIS16S32Func.c \
        mlib_v_ImageLookUpSIS16U16Func.c \
        mlib_v_ImageLookUpSIS16U8Func.c \
        mlib_v_ImageLookUpSIS32S16Func.c \
        mlib_v_ImageLookUpSIS32S32Func.c \
        mlib_v_ImageLookUpSIS32U16Func.c \
        mlib_v_ImageLookUpSIS32U8Func.c \
        mlib_v_ImageLookUpSIU16S16Func.c \
        mlib_v_ImageLookUpSIU16S32Func.c \
        mlib_v_ImageLookUpSIU16U16Func.c \
        mlib_v_ImageLookUpSIU16U8Func.c \
        mlib_v_ImageLookUpSIU8S16Func.c \
        mlib_v_ImageLookUpSIU8S32Func.c \
        mlib_v_ImageLookUpSIU8U16Func.c \
        mlib_v_ImageLookUpSIU8U8Func.c \
        mlib_v_ImageLookUpU16S16Func.c \
        mlib_v_ImageLookUpU16S32Func.c \
        mlib_v_ImageLookUpU16U16Func.c \
        mlib_v_ImageLookUpU16U8Func.c \
        mlib_v_ImageLookUpU8S16Func.c \
        mlib_v_ImageLookUpU8S32Func.c \
        mlib_v_ImageLookUpU8U16Func.c \
        mlib_v_ImageLookUpU8U8Func.c \
        mlib_v_ImageAffineIndex_BC.c \
        mlib_v_ImageAffine_BC.c \
        mlib_v_ImageAffine_BC_S16.c \
        mlib_v_ImageAffine_BC_U16.c \
        mlib_v_ImageAffine_BL.c \
        mlib_v_ImageAffine_BL_S16.c \
        mlib_v_ImageAffine_BL_U16.c \
        mlib_v_ImageAffine_NN.c \
        mlib_v_ImageFilters.c \
        mlib_ImageAffineEdge.c \
        mlib_ImageAffine_BC_D64.c \
        mlib_ImageAffine_BC_F32.c \
        mlib_ImageAffine_BC_S32.c \
        mlib_ImageAffine_BL_D64.c \
        mlib_ImageAffine_BL_F32.c \
        mlib_ImageAffine_BL_S32.c \
        mlib_ImageAffine_NN.c \
        mlib_ImageAffine_NN_Bit.c \
        mlib_ImageFilters.c \
        mlib_ImageScanPoly.c \
        mlib_ImageConv_8nw.c \
        mlib_ImageConv_8ext.c \
        mlib_ImageConv_16nw.c \
        mlib_ImageConv_16ext.c \
        mlib_ImageConv_u16nw.c \
        mlib_ImageConv_u16ext.c \
        mlib_ImageConv_32nw.c \
        mlib_ImageConv_F32nw.c \
        mlib_ImageConvMxN_Fp.c \
        mlib_ImageConvMxN_ext.c \
        mlib_ImageConv_D64nw.c \
        mlib_ImageClipping.c \
        mlib_ImageConvCopyEdge_Bit.c \
        mlib_ImageConvClearEdge_Bit.c \
        mlib_ImageConv2x2_f.c \
        mlib_ImageConvClearEdge_Fp.c \
        mlib_v_ImageConvMxN_8.c \
        mlib_v_ImageConvClearEdge.c \
        mlib_v_ImageConvCopyEdge.c \
        mlib_v_ImageConvMxN_8ext.c \
        mlib_v_ImageConvVersion.c \
        mlib_v_ImageConv_8nw.c \
        mlib_ImageConvCopyEdge_Fp.c \
        mlib_v_ImageChannelInsert_1.c \
        mlib_v_ImageChannelExtract_43.c \
        mlib_v_ImageChannelExtract_1.c \
        mlib_ImageCopy_Bit.c \
        mlib_v_ImageCopy_f.c \
        mlib_ImageUtils.c \
        mlib_ImageDivTables.c

BUILD_LIBMLIB_V_CFLAGS := $(filter-out -DMLIB_NO_LIBSUNMATH,$(BUILD_LIBMLIB_CFLAGS))

$(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE_V,\
		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),\
		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),\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v))

BUILD_LIBRARIES += $(BUILD_LIBMLIB_IMAGE_V)

endif

##########################################################################################

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

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

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
else
	LIBAWT_FILES += MapAccelFunc.c
endif

ifneq ($(OPENJDK_TARGET_OS),solaris)
	LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH
endif

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

ifeq ($(MILESTONE), internal)
	LIBAWT_CFLAGS += -DINTERNAL_BUILD
endif

LIBAWT_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt/mapfile-vers
ifeq ($(OPENJDK_TARGET_OS),linux)
	LIBAWT_MAPFILE:=
endif

$(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)

##########################################################################################

# TODO!!
# 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:=\
		$(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_OPENJDK_TARGET_OS_API)/native/sun/font \
		$(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
		$(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_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

ifeq ($(OPENJDK_TARGET_OS),solaris)
	LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15
endif

ifeq ($(MILESTONE),internal)
	LIBAWT_XAWT_CFLAGS += -DINTERNAL_BUILD
endif

LIBAWT_XAWT_FILES:=\
	XlibWrapper.c \
	XWindow.c \
	XToolkit.c \
	X11Color.c \
	X11SurfaceData.c \
	awt_GraphicsEnv.c \
	awt_InputMethod.c \
	robot_common.c \
	awt_Robot.c \
        list.c \
        multiVis.c \
	initIDs.c \
	awt_util.c \
	awt_Desktop.c \
	awt_UNIXToolkit.c \
	X11FontScaler_md.c \
	X11TextRenderer_md.c \
	fontpath.c \
	awt_Insets.c \
	awt_Event.c \
	X11Renderer.c \
	X11PMBlitLoops.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 \
	awt_Font.c \
	multi_font.c \
	awt_AWTEvent.c \
	awt_DrawingSurface.c \
	jawt.c \
	CUPSfuncs.c \
	debug_assert.c \
	debug_mem.c \
	debug_trace.c \
	debug_util.c \
	awt_Plugin.c \
	gtk2_interface.c \
        swing_GTKEngine.c \
        swing_GTKStyle.c \
        rect.c \
	sun_awt_X11_GtkFileDialogPeer.c \
	XRSurfaceData.c \
	XRBackendNative.c

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 ($(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),\
		LANG:=C,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) \
                        $(X_CFLAGS),\
		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_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),\
		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

##########################################################################################

ifndef BUILD_HEADLESS_ONLY
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_OPENJDK_TARGET_OS_API)/native/sun/awt/splashscreen

LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \
	$(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir))

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 ($(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:=\
	java_awt_SplashScreen.c \
	splashscreen_gfx_impl.c \
	splashscreen_gif.c \
	splashscreen_impl.c \
	splashscreen_jpeg.c \
	splashscreen_png.c \
	png.c \
	pngerror.c \
	pngget.c \
	pngmem.c  \
	pngpread.c \
	pngread.c \
	pngrio.c \
	pngrtran.c \
	pngrutil.c \
	pngset.c \
	pngtrans.c \
	pngwio.c \
	pngwrite.c \
	pngwtran.c \
	pngwutil.c \
	dgif_lib.c \
	gif_err.c \
	gifalloc.c \
	jcomapi.c \
	jdapimin.c \
	jdapistd.c \
	jdcoefct.c \
	jdcolor.c \
	jddctmgr.c \
	jdhuff.c \
	jdinput.c \
	jdmainct.c \
	jdmarker.c \
	jdmaster.c \
	jdmerge.c \
	jdphuff.c \
	jdpostct.c \
	jdsample.c \
	jerror.c \
	jidctflt.c \
	jidctfst.c \
	jidctint.c \
	jidctred.c \
	jmemmgr.c \
	jmemnobs.c \
	jquant1.c \
	jquant2.c \
	jutils.c \
	jcapimin.c \
	jcapistd.c \
	jccoefct.c \
	jccolor.c \
	jcdctmgr.c \
	jchuff.c \
	jcinit.c \
	jcmainct.c \
	jcmarker.c \
	jcmaster.c \
	jcparam.c \
	jcphuff.c \
	jcprepct.c \
	jcsample.c \
	jctrans.c \
	jdtrans.c \
	jfdctflt.c \
	jfdctfst.c \
	jfdctint.c

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:=

ifneq ($(USE_EXTERNAL_LIBZ),true)
	LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
	LIBSPLASHSCREEN_CFLAGS += $(LIBZ_INCLUDE)
	LIBSPLASHSCREEN_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
endif

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 ($(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 # OPENJDK_TARGET_OS

$(eval $(call SetupNativeCompilation,LIBSPLASHSCREEN,\
		LIBRARY:=splashscreen,\
                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
		SRC:=$(LIBSPLASHSCREEN_DIRS),\
		INCLUDE_FILES:=$(LIBSPLASHSCREEN_FILES),\
		LANG:=C,\
		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_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

##########################################################################################

ifndef OPENJDK

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)) \
	          -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,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
			$(LIBDCPR_CFLAGS), \
		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:=-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_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio,\
		LANG:=C,\
		CFLAGS_posix:=-D__sun_jdk,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
                     -I$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \
                     -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,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pcsc))

BUILD_LIBRARIES += $(BUILD_LIBJ2PCSC)

##########################################################################################

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_OPENJDK_TARGET_OS_API)/native/sun/security/jgss/wrapper,\
		LANG:=C,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
                     -I$(JDK_TOPDIR)/src/share/native/sun/security/jgss/wrapper \
                     -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), \
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2gss))

BUILD_LIBRARIES += $(BUILD_LIBJ2GSS)
endif

##########################################################################################

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 ($(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),\
		LANG:=C,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
		        -I$(JDK_TOPDIR)/src/share/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) ,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5))

BUILD_LIBRARIES += $(BUILD_LIBKRB5)
endif

##########################################################################################

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_OPENJDK_TARGET_OS_API)/native/sun/security/mscapi,\
		INCLUDE_FILES:=security.cpp, \
		LANG:=C++,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
		        -I$(JDK_TOPDIR)/src/share/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,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunmscapi))

BUILD_LIBRARIES += $(BUILD_LIBSUNMSCAPI)
endif

##########################################################################################

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_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11 \
                     $(JDK_TOPDIR)/src/share/native/sun/security/pkcs11/wrapper \
                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11/wrapper,\
		LANG:=C,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
		        -I$(JDK_TOPDIR)/src/share/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_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), \
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11))

BUILD_LIBRARIES += $(BUILD_LIBJ2PKCS11)
endif

##########################################################################################

ifndef DISABLE_INTREE_EC
#
# TODO Set DISABLE_INTREE_EC in configure if src/share/native/sun/security/ec/impl
#      is not present
#
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++, \
		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),\
                LDFLAGS_SUFFIX_solaris:=-lc ,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunec))

BUILD_LIBRARIES += $(BUILD_LIBSUNEC)
endif

##########################################################################################

LIBJSOUND_SRC_DIRS:=\
	$(JDK_TOPDIR)/src/share/native/com/sun/media/sound \
	$(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 \
	MidiOutDeviceProvider.c \
	PlatformMidi.c

# files needed for ports
LIBJSOUND_PORTFILES:=\
	PortMixerProvider.c \
	PortMixer.c

# files needed for direct audio
LIBJSOUND_DAUDIOFILES:=\
	DirectAudioDeviceProvider.c \
	DirectAudioDevice.c

ifeq ($(OPENJDK_TARGET_OS), windows)
	EXTRA_SOUND_JNI_LIBS += jsoundds
	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_WINDOWS \
                            -DUSE_PLATFORM_MIDI_OUT=TRUE \
                            -DUSE_PLATFORM_MIDI_IN=TRUE \
                            -DUSE_PORTS=TRUE
	LIBJSOUND_SRC_FILES += \
		PLATFORM_API_WinOS_MidiIn.cpp \
		PLATFORM_API_WinOS_MidiOut.c \
		PLATFORM_API_WinOS_Util.c \
		PLATFORM_API_WinOS_Ports.c
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
endif # OPENJDK_TARGET_OS windows

ifeq ($(OPENJDK_TARGET_OS), linux)
	EXTRA_SOUND_JNI_LIBS += jsoundalsa
	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_LINUX
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 \
                            -DUSE_PLATFORM_MIDI_OUT=TRUE \
                            -DUSE_PLATFORM_MIDI_IN=TRUE
	LIBJSOUND_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/com/sun/media/sound
	LIBJSOUND_SRC_FILES += \
		PLATFORM_API_MacOSX_Utils.cpp \
		PLATFORM_API_MacOSX_PCM.cpp \
		PLATFORM_API_MacOSX_Ports.cpp \
                PLATFORM_API_MacOSX_MidiIn.c \
                PLATFORM_API_MacOSX_MidiOut.c \
                PLATFORM_API_MacOSX_MidiUtils.c
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
endif # OPENJDK_TARGET_OS macosx

ifeq ($(OPENJDK_TARGET_OS), solaris)
	LIBJSOUND_CFLAGS += -DX_PLATFORM=X_SOLARIS \
                            -DUSE_PORTS=TRUE \
                            -DUSE_DAUDIO=TRUE
	LIBJSOUND_SRC_FILES += \
		PLATFORM_API_SolarisOS_Utils.c \
		PLATFORM_API_SolarisOS_Ports.c \
		PLATFORM_API_SolarisOS_PCM.c
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
	LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
endif # OPENJDK_TARGET_OS solaris


ifeq ($(JVM_VARIANT_ZERO), true)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_ZERO
else
  ifeq ($(ARCH), i586)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_I586
  endif # ARCH i586

  ifeq ($(ARCH), sparc)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARC
  endif # ARCH sparc

  ifeq ($(ARCH), sparcv9)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARCV9
  endif # ARCH sparcv9

  ifeq ($(ARCH), amd64)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_AMD64
  endif # ARCH amd64

  ifeq ($(ARCH), arm)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_ARM
  endif # ARCH arm

  ifeq ($(ARCH), ppc)
	LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC
  endif # ARCH ppc
endif

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),\
		LANG:=$(LIBJSOUND_LANG),\
		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:=$(WIN_JAVA_LIB) advapi32.lib winmm.lib,\
		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
		LDFLAGS_SUFFIX_solaris:=-lc ,\
		LDFLAGS_SUFFIX_macosx:=-framework CoreAudio -framework CoreFoundation \
             -framework CoreServices -framework AudioUnit $(LIBCXX) \
             -framework CoreMIDI -framework AudioToolbox ,\
		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) \
                                $(LIBJSOUND_DAUDIOFILES) \
				PLATFORM_API_LinuxOS_ALSA_CommonUtils.c   \
				PLATFORM_API_LinuxOS_ALSA_PCM.c     \
				PLATFORM_API_LinuxOS_ALSA_PCMUtils.c   \
				PLATFORM_API_LinuxOS_ALSA_MidiIn.c  \
				PLATFORM_API_LinuxOS_ALSA_MidiOut.c \
				PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
				PLATFORM_API_LinuxOS_ALSA_Ports.c,\
		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, \
		LDFLAGS:=$(LDFLAGS_JDKLIB)\
			 $(call SET_SHARED_LIBRARY_ORIGIN),\
		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) -lasound,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa))

$(BUILD_LIBJSOUNDALSA) : $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBJSOUNDALSA)

endif

##########################################################################################

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) \
				PLATFORM_API_WinOS_DirectSound.cpp, \
		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,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundds))

$(BUILD_LIBJSOUNDDS) : $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBJSOUNDDS)

endif

##########################################################################################

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,\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(CFLAGS_JDKLIB) \
			-I$(JDK_TOPDIR)/src/closed/solaris/native/com/oracle/security/ucrypto ,\
		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2ucrypto/mapfile-vers, \
		LDFLAGS:=$(LDFLAGS_JDKLIB)\
			 $(call SET_SHARED_LIBRARY_ORIGIN), \
		LDFLAGS_SUFFIX:=$(LIBDL),\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto))

$(BUILD_LIBJ2UCRYPTO) : $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBJ2UCRYPTO)

endif
endif

##########################################################################################

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,\
		INCLUDE_FILES:=$(LIBAPPLESCRIPTENGINE_FILES),\
		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_JDKLIB_SUFFIX) \
    -framework Cocoa \
    -framework Carbon \
    -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
    -framework JavaNativeFoundation, \
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine))

$(BUILD_LIBAPPLESCRIPTENGINE) : $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBAPPLESCRIPTENGINE)

endif

##########################################################################################

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,\
		INCLUDE_FILES:=$(LIBOSXAPP_FILES),\
		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:=\
	-framework Accelerate \
	-framework ApplicationServices \
	-framework AudioToolbox \
	-framework Carbon \
	-framework Cocoa \
	-framework Security \
	-framework ExceptionHandling \
        -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
	-framework JavaNativeFoundation \
	-framework JavaRuntimeSupport \
	-framework OpenGL \
	-framework IOSurface \
	-framework QuartzCore, \
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxapp))

BUILD_LIBRARIES += $(BUILD_LIBOSXAPP)

endif

##########################################################################################

ifeq ($(OPENJDK_TARGET_OS), macosx)

LIBOSX_FILES:=\
    Dispatch.m \
    CFileManager.m \
    KeystoreImpl.m \
    JavaAppLauncher.m \
    MacOSXPreferencesFile.m \
    SCDynamicStoreConfig.m

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 \
  $(JDK_TOPDIR)/src/macosx/native/apple/security \
  $(JDK_TOPDIR)/src/macosx/native/apple/launcher

$(eval $(call SetupNativeCompilation,BUILD_LIBOSX,\
		LIBRARY:=osx,\
                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
		SRC:=$(LIBOSX_DIRS),\
		LANG:=C,\
		INCLUDE_FILES:=$(LIBOSX_FILES),\
		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:=\
    -losxapp \
    -framework Cocoa \
    -framework ApplicationServices \
    -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
    -framework JavaNativeFoundation \
    -framework JavaRuntimeSupport \
    -framework Security \
    -framework SystemConfiguration \
    $(LDFLAGS_JDKLIB_SUFFIX), \
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosx))

BUILD_LIBRARIES += $(BUILD_LIBOSX)

$(BUILD_LIBOSX) : $(BUILD_LIBOSXAPP)

$(BUILD_LIBOSX) : $(BUILD_LIBJAVA)

endif

##########################################################################################

ifeq ($(OPENJDK_TARGET_OS), macosx)

LIBAWT_LWAWT_FILES:=\
        awt.m \
        ApplicationDelegate.m \
        CFRetainedResource.m \
        CGLGraphicsConfig.m \
        CGLSurfaceData.m \
        CGLLayer.m \
        CGraphicsConfig.m \
        CGraphicsDevice.m \
        CGraphicsEnv.m \
        CCharToGlyphMapper.m \
        CSystemColors.m \
        AWTFont.m \
        CGGlyphOutlines.m \
        CGGlyphImages.m \
        CoreTextSupport.m \
        AWTStrike.m \
        InitIDs.m \
        AWTEvent.m \
        AWTView.m \
        AWTWindow.m \
        AWTSurfaceLayers.m \
        CCursorManager.m \
        CClipboard.m \
        CDataTransferer.m \
        CDragSource.m \
        CDragSourceContextPeer.m \
        CDropTarget.m \
        CDropTargetContextPeer.m \
        CInputMethod.m \
        CDesktopPeer.m \
        OSVersion.m \
        DnDUtilities.m \
        CFileDialog.m \
        CImage.m \
        CMenu.m \
        CMenuBar.m \
        CMenuComponent.m \
        CMenuItem.m \
        CPopupMenu.m \
        CRobot.m \
        CTrayIcon.m \
        CWrapper.m \
        JavaAccessibilityAction.m \
        JavaAccessibilityUtilities.m \
        JavaComponentAccessibility.m \
        JavaTextAccessibility.m \
        LWCToolkit.m \
        GeomUtilities.m \
        CPrinterJob.m \
        PrintModel.m \
        PrinterSurfaceData.m \
        PrinterView.m \
        QuartzSurfaceData.m \
        QuartzRenderer.m \
        CTextPipe.m \
        ImageSurfaceData.m \
        awt_DrawingSurface.m \
        \
        OGLBlitLoops.c \
        OGLBufImgOps.c \
        OGLContext.c \
        OGLFuncs.c \
        OGLMaskBlit.c \
        OGLMaskFill.c \
        OGLPaints.c \
        OGLRenderQueue.c \
        OGLRenderer.c \
        OGLSurfaceData.c \
        OGLTextRenderer.c \
        OGLVertexCache.c \
        AccelGlyphCache.c \
        CUPSfuncs.c


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 \
  $(JDK_TOPDIR)/src/solaris/native/sun/awt \
  $(JDK_TOPDIR)/src/share/native/sun/font \
  $(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,\
		INCLUDE_FILES:=$(LIBAWT_LWAWT_FILES),\
		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 \
                        -I$(JDK_TOPDIR)/src/solaris/native/sun/java2d \
                        -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/java2d/loops \
                        -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
                        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
                        -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:=\
	-lawt -lmlib_image -losxapp $(LDFLAGS_JDKLIB_SUFFIX) $(LIBM) \
	-framework Accelerate \
	-framework ApplicationServices \
	-framework AudioToolbox \
	-framework Carbon \
	-framework Cocoa \
	-framework Security \
	-framework ExceptionHandling \
        -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
	-framework JavaNativeFoundation \
	-framework JavaRuntimeSupport \
	-framework OpenGL \
        -framework QuartzCore ,\
		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 ($(OPENJDK_TARGET_OS), macosx)

LIBOSXUI_FILES:=\
        AquaFileView.m \
        AquaLookAndFeel.m \
        AquaNativeResources.m \
        JRSUIConstantSync.m \
        JRSUIController.m \
        JRSUIFocus.m \
        ScreenPopupFactory.m \
        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,\
		INCLUDE_FILES:=$(LIBOSXUI_FILES),\
		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_JDKLIB_SUFFIX) \
    -lawt -losxapp -lawt_lwawt \
    -framework Cocoa \
    -framework Carbon \
    -framework ApplicationServices \
    -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
    -framework JavaNativeFoundation \
    -framework JavaRuntimeSupport, \
		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

##########################################################################################

all: $(COPY_FILES) $(BUILD_LIBRARIES)

.PHONY: all