jdk/makefiles/CompileLaunchers.gmk
author ihse
Tue, 01 Oct 2013 11:08:23 +0200
changeset 20203 2e0b3aab117a
parent 19399 e2e5122cd62e
child 20547 453837141fac
child 20851 9f284cf7836b
permissions -rw-r--r--
8019219: Fix typo in jdk/makefiles "default" targets Reviewed-by: erikj

#
# 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.
#

default: all

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

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

# Prepare the find cache. Only used on windows.
$(eval $(call FillCacheFind,$(JDK_TOPDIR)/src/share/bin))

# Build tools
include Tools.gmk

BUILD_LAUNCHERS=

# When building a legacy overlay image (on solaris 64 bit), the launchers
# need to be built with a different rpath and a different output dir.
ifeq ($(OVERLAY_IMAGES),true)
    ORIGIN_ROOT:=/../..
    OUTPUT_SUBDIR:=$(OPENJDK_TARGET_CPU_ISADIR)
else
    ORIGIN_ROOT:=/..
endif

ifeq ($(OPENJDK_TARGET_OS), macosx)
    ORIGIN_ARG:=$(call SET_EXECUTABLE_ORIGIN)
else
    ORIGIN_ARG:=$(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli) \
                $(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli)
endif

#
# Applications expect to be able to link against libjawt without invoking
# System.loadLibrary("jawt") first. This was the behaviour described in the
# devloper documentation of JAWT and what worked with OpenJDK6.
#
ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris),)
    ORIGIN_ARG+=$(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/lib$(OPENJDK_TARGET_CPU_LIBDIR)) \
                $(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR))
endif

define SetupLauncher
    # TODO: Fix mapfile on solaris. Won't work with ld as linker.
    # Parameter 1 is the name of the launcher (java,javac,jar...)
    # Parameter 2 is extra CFLAGS
    # Parameter 3 is extra LDFLAGS
    # Parameter 4 is extra LDFLAGS_SUFFIX_posix
    # Parameter 5 is extra LDFLAGS_SUFFIX_windows
    # Parameter 6 is optional Windows JLI library (full path)
    # Parameter 7 is optional Windows resource (RC) flags
    # Parameter 8 is optional Windows version resource file (.rc)
    # Parameter 9  is different output dir
    # Parameter 10 if set, link statically with c runtime on windows.
    # Parameter 11 if set, override plist file on macosx.

    $1_WINDOWS_JLI_LIB:=$(JDK_OUTPUTDIR)/objs/libjli/jli.lib
    ifneq ($6,)
        $1_WINDOWS_JLI_LIB:=$6
    endif
    $1_VERSION_INFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc
    ifneq ($8,)
        $1_VERSION_INFO_RESOURCE:=$8
    endif

    $1_LDFLAGS := $3
    $1_LDFLAGS_SUFFIX :=
    ifeq ($(OPENJDK_TARGET_OS), macosx)
        $1_PLIST_FILE:=Info-cmdline.plist
        ifneq ($(11),)
            $1_PLIST_FILE:=$(11)
            ifneq ($$(findstring privileged,$$($1_PLIST_FILE)),)
                $1_CODESIGN:=true
            endif
        endif

        $1_LDFLAGS += -Wl,-all_load $(JDK_OUTPUTDIR)/objs/libjli_static.a \
                      -framework Cocoa -framework Security -framework ApplicationServices \
                      -sectcreate __TEXT __info_plist $(JDK_TOPDIR)/src/macosx/lib/$$($1_PLIST_FILE)
        $1_LDFLAGS_SUFFIX += -pthread
    endif

    ifeq ($(USE_EXTERNAL_LIBZ), true)
        $1_LDFLAGS_SUFFIX += -lz
    endif

    $1_OUTPUT_DIR_ARG:=$9
    ifeq (,$$($1_OUTPUT_DIR_ARG))
        $1_OUTPUT_DIR_ARG:=$(JDK_OUTPUTDIR)/bin
    endif

    # TODO: maybe it's better to move this if-statement out of this function
    ifeq ($1,java)
        $1_OPTIMIZATION_ARG:=HIGH
	$1_LDFLAGS_solaris:=-R$(OPENWIN_HOME)/lib$(OPENJDK_TARGET_CPU_ISADIR)
    else
        $1_OPTIMIZATION_ARG:=LOW
    endif

    $1_CFLAGS:=$(CFLAGS_JDKEXE)
    ifeq ($(10),true)
        $1_CFLAGS:=$(filter-out -MD,$(CFLAGS_JDKEXE))
    endif

    ifneq ($(wildcard $(JDK_TOPDIR)/makefiles/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU)),)
        $1_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU)
    else
        $1_MAPFILE:=
    endif

    $(call SetupNativeCompilation,BUILD_LAUNCHER_$1,\
	SRC:=$(JDK_TOPDIR)/src/share/bin,\
	INCLUDE_FILES:=main.c,\
	LANG:=C,\
	OPTIMIZATION:=$$($1_OPTIMIZATION_ARG), \
	CFLAGS:=$$($1_CFLAGS) \
		-I$(JDK_TOPDIR)/src/share/bin \
		-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin \
		-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/bin \
                -DFULL_VERSION='"$(FULL_VERSION)"' \
                -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
                -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
		-DLIBARCHNAME='"$(OPENJDK_TARGET_CPU_LEGACY)"' \
		-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
		-DPROGNAME='"$1"' $(DPACKAGEPATH) \
		$2,\
	CFLAGS_linux:=-fPIC,\
        CFLAGS_solaris:=-KPIC -DHAVE_GETHRTIME,\
	LDFLAGS:=$(LDFLAGS_JDKEXE) \
                 $(ORIGIN_ARG) \
		 $$($1_LDFLAGS),\
	LDFLAGS_macosx:=$(call SET_SHARED_LIBRARY_NAME,$1),\
	LDFLAGS_linux:=-lpthread \
                       $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)),\
	LDFLAGS_solaris:=$$($1_LDFLAGS_solaris) \
                       $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)),\
	MAPFILE := $$($1_MAPFILE), \
        LDFLAGS_SUFFIX:=$(LDFLAGS_JDKEXE_SUFFIX) $$($1_LDFLAGS_SUFFIX),\
	LDFLAGS_SUFFIX_posix:=$4,\
	LDFLAGS_SUFFIX_windows:=$$($1_WINDOWS_JLI_LIB) \
			       $(JDK_OUTPUTDIR)/objs/libjava/java.lib advapi32.lib $5,\
	LDFLAGS_SUFFIX_linux:=-L$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli -ljli $(LIBDL) -lc, \
	LDFLAGS_SUFFIX_solaris:=-L$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli -ljli -lthread $(LIBDL) -lc, \
	OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/$1_objs$(OUTPUT_SUBDIR),\
	OUTPUT_DIR:=$$($1_OUTPUT_DIR_ARG)$(OUTPUT_SUBDIR),\
	PROGRAM:=$1,\
	DEBUG_SYMBOLS:=true,\
	VERSIONINFO_RESOURCE:=$$($1_VERSION_INFO_RESOURCE),\
	RC_FLAGS:=$(RC_FLAGS)\
		  -D "JDK_FNAME=$1$(EXE_SUFFIX)" \
		  -D "JDK_INTERNAL_NAME=$1" \
		  -D "JDK_FTYPE=0x1L" \
		  $7,\
	MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/java.manifest,\
	CODESIGN:=$$($1_CODESIGN))

    BUILD_LAUNCHERS += $$(BUILD_LAUNCHER_$1)

    ifeq ($(OPENJDK_TARGET_OS),macosx)
        $$(BUILD_LAUNCHER_$1) : $(JDK_OUTPUTDIR)/objs/libjli_static.a
    endif

    ifeq ($(OPENJDK_TARGET_OS),windows)
        $$(BUILD_LAUNCHER_$1) : $(JDK_OUTPUTDIR)/objs/libjava/java.lib \
				$$($1_WINDOWS_JLI_LIB)
    endif
endef

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

XLIBS:=$(X_LIBS) -lX11
ifeq ($(OPENJDK_TARGET_OS),macosx)
    DPACKAGEPATH:=-DPACKAGE_PATH='"$(PACKAGE_PATH)"'
    XLIBS:=
endif

ifdef OPENJDK
    JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/windows/resource/icons"
else
    JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/closed/windows/native/sun/windows"
endif

# On windows, the debuginfo files get the same name as for java.dll. Build
# into another dir and copy selectively so debuginfo for java.dll isn't
# overwritten.
$(eval $(call SetupLauncher,java,\
    -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib,\
    $(JDK_OUTPUTDIR)/objs/jli_static.lib,$(JAVA_RC_FLAGS),\
    $(JDK_TOPDIR)/src/windows/resource/java.rc,$(JDK_OUTPUTDIR)/objs/java_objs,true))

$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/java$(EXE_SUFFIX): $(BUILD_LAUNCHER_java)
	$(MKDIR) -p $(@D)
	$(RM) $@
	$(CP) $(JDK_OUTPUTDIR)/objs/java_objs$(OUTPUT_SUBDIR)/java$(EXE_SUFFIX) $@

BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/java$(EXE_SUFFIX)

ifeq ($(OPENJDK_TARGET_OS),windows)
    $(eval $(call SetupLauncher,javaw,\
        -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib,\
        $(JDK_OUTPUTDIR)/objs/jli_static.lib,$(JAVA_RC_FLAGS),\
        $(JDK_TOPDIR)/src/windows/resource/java.rc,,true))
endif


ifndef BUILD_HEADLESS_ONLY
$(eval $(call SetupLauncher,appletviewer,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.applet.Main"$(COMMA) }',,\
    $(XLIBS)))
endif

$(eval $(call SetupLauncher,extcheck,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.extcheck.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,idlj,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.corba.se.idl.toJavaPortable.Compile"$(COMMA) }'))

$(eval $(call SetupLauncher,jar,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jar.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,jarsigner,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.jarsigner.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,javac,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javac.Main"$(COMMA) }'))

ifeq ($(ENABLE_SJAVAC),yes)
$(eval $(call SetupLauncher,sjavac,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.sjavac.Main"$(COMMA) }'))
endif

$(eval $(call SetupLauncher,javadoc,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javadoc.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,javah,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javah.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,javap,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javap.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,jdeps,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.jdeps.Main"$(COMMA) }'))

BUILD_LAUNCHER_jconsole_CFLAGS_windows:=-DJAVAW
BUILD_LAUNCHER_jconsole_LDFLAGS_windows:=user32.lib

$(eval $(call SetupLauncher,jconsole,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "-J-Djconsole.showOutputViewer"$(COMMA) "sun.tools.jconsole.JConsole"$(COMMA) }' \
    -DAPP_CLASSPATH='{ "/lib/jconsole.jar"$(COMMA) "/lib/tools.jar"$(COMMA) "/classes" }'))

$(eval $(call SetupLauncher,jdb,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.example.debug.tty.TTY"$(COMMA) }' \
    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))

$(eval $(call SetupLauncher,jhat,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.hat.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,jinfo,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
		   "sun.tools.jinfo.JInfo"$(COMMA) }' \
    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
    ,,,,,,,,,Info-privileged.plist))

$(eval $(call SetupLauncher,jmap,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
		   "sun.tools.jmap.JMap"$(COMMA) }' \
    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
    ,,,,,,,,,Info-privileged.plist))

$(eval $(call SetupLauncher,jps,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jps.Jps"$(COMMA) }'))

$(eval $(call SetupLauncher,jrunscript,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.script.shell.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,jjs,\
    -DJAVA_ARGS='{  "-J-ms8m"$(COMMA) "jdk.nashorn.tools.Shell"$(COMMA) }'))

$(eval $(call SetupLauncher,jsadebugd,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.jvm.hotspot.jdi.SADebugServer"$(COMMA) }' \
    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
    ,,,,,,,,,Info-privileged.plist))

$(eval $(call SetupLauncher,jstack,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
		   "sun.tools.jstack.JStack"$(COMMA) }' \
    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
    ,,,,,,,,,Info-privileged.plist))

$(eval $(call SetupLauncher,jstat,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstat.Jstat"$(COMMA) }'))

$(eval $(call SetupLauncher,jstatd,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstatd.Jstatd"$(COMMA) }'))

$(eval $(call SetupLauncher,keytool,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.keytool.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,native2ascii,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.native2ascii.Main"$(COMMA) }'))

ifndef BUILD_HEADLESS_ONLY
$(eval $(call SetupLauncher,policytool,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.policytool.PolicyTool"$(COMMA) }',,\
    $(XLIBS)))
endif

$(eval $(call SetupLauncher,rmic,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.rmi.rmic.Main"$(COMMA) }'))

$(eval $(call SetupLauncher,schemagen,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.jxc.SchemaGenerator"$(COMMA) }'))

$(eval $(call SetupLauncher,serialver,\
    -DEXPAND_CLASSPATH_WILDCARDS \
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.serialver.SerialVer"$(COMMA) }'))

$(eval $(call SetupLauncher,xjc,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.xjc.Driver"$(COMMA) }'))

$(eval $(call SetupLauncher,wsgen,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.ws.WsGen"$(COMMA) }'))

$(eval $(call SetupLauncher,wsimport,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.ws.WsImport"$(COMMA) }'))

$(eval $(call SetupLauncher,orbd,\
    -DJAVA_ARGS='{ 	"-J-ms8m"$(COMMA) \
			"-J-Dcom.sun.CORBA.activation.DbDir=./orb.db"$(COMMA) \
			"-J-Dcom.sun.CORBA.activation.Port=1049"$(COMMA) \
			"-J-Dcom.sun.CORBA.POA.ORBServerId=1"$(COMMA) \
			"com.sun.corba.se.impl.activation.ORBD"$(COMMA) }'))

$(eval $(call SetupLauncher,servertool,\
    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.corba.se.impl.activation.ServerTool"$(COMMA) }'))

$(eval $(call SetupLauncher,tnameserv,\
    -DJAVA_ARGS='{ 	"-J-ms8m"$(COMMA) \
			"-J-Dcom.sun.CORBA.activation.DbDir=./orb.db"$(COMMA) \
			"-J-Djava.util.logging.LoggingPermission=contol"$(COMMA) \
			"-J-Dcom.sun.CORBA.POA.ORBServerId=1"$(COMMA) \
			"com.sun.corba.se.impl.naming.cosnaming.TransientNameServer"$(COMMA) }'))

$(eval $(call SetupLauncher,pack200,\
    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "com.sun.java.util.jar.pack.Driver"$(COMMA) "--pack" }'))

$(eval $(call SetupLauncher,rmid,\
    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.rmi.server.Activation"$(COMMA) }'))

$(eval $(call SetupLauncher,rmiregistry,\
    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.rmi.registry.RegistryImpl"$(COMMA) }'))

$(eval $(call SetupLauncher,jcmd,\
    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.tools.jcmd.JCmd"$(COMMA) }'))

ifeq ($(OPENJDK_TARGET_OS),windows)
    $(eval $(call SetupLauncher,kinit,\
        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Kinit"$(COMMA) }'))

    $(eval $(call SetupLauncher,klist,\
        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Klist"$(COMMA) }'))

    $(eval $(call SetupLauncher,ktab,\
        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Ktab"$(COMMA) }'))
endif

##########################################################################################
# The order of the object files on the link command line affects the size of the resulting
# binary (at least on linux) which causes the size to differ between old and new build.
ifeq ($(USE_EXTERNAL_LIBZ), true)
UNPACKEXE_CFLAGS := -DSYSTEM_ZLIB
UNPACKEXE_ZIPOBJS := -lz
else
UNPACKEXE_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
UNPACKEXE_ZIPOBJS := 	$(JDK_OUTPUTDIR)/objs/libzip/zcrc32$(OBJ_SUFFIX) \
		     	$(JDK_OUTPUTDIR)/objs/libzip/deflate$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/trees$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/zadler32$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/compress$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/zutil$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/inflate$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/infback$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/inftrees$(OBJ_SUFFIX) \
			$(JDK_OUTPUTDIR)/objs/libzip/inffast$(OBJ_SUFFIX)

endif

ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
    UNPACKEXE_CFLAGS += -xregs=no%appl
    UNPACKEXE_LDFLAGS_solaris += -xmemalign=4s
endif

UNPACKEXE_LANG:=C
ifeq ($(OPENJDK_TARGET_OS),solaris)
    UNPACKEXE_LANG:=C++
endif
# On windows, unpack200 is linked completely differently to all other
# executables, using the compiler with the compiler arguments.
# It's also linked incrementally, producing a .ilk file that needs to
# be kept away.
ifeq ($(OPENJDK_TARGET_OS),windows)
    BUILD_UNPACKEXE_LDEXE:=$(CC)
    EXE_OUT_OPTION_save:=$(EXE_OUT_OPTION)
    EXE_OUT_OPTION:=-Fe
endif
$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE,\
                SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/java/util/jar/pack,\
		EXCLUDE_FILES:=jni.cpp,\
		LANG:=$(UNPACKEXE_LANG),\
		OPTIMIZATION:=LOW, \
		CFLAGS:=$(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE)\
                        -DFULL, \
		CFLAGS_release:=-DPRODUCT,\
		CFLAGS_linux:=-fPIC,\
		CFLAGS_solaris:=-KPIC, \
		CFLAGS_macosx:=-fPIC, \
		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libunpack/mapfile-vers-unpack200,\
		LDFLAGS:=$(UNPACKEXE_ZIPOBJS),\
		LDFLAGS_windows:=$(CXXFLAGS_JDKEXE),\
		LDFLAGS_posix:=$(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
			 $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \
			 $(call SET_SHARED_LIBRARY_ORIGIN),\
		LDFLAGS_linux:=-lc,\
		LDFLAGS_solaris:=$(UNPACKEXE_LDFLAGS_solaris) -lc,\
		LDFLAGS_SUFFIX:=$(LIBCXX),\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/unpackexe$(OUTPUT_SUBDIR),\
		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs/unpackexe$(OUTPUT_SUBDIR),\
		PROGRAM:=unpack200,\
		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
		RC_FLAGS:=$(RC_FLAGS)\
			  -D "JDK_FNAME=unpack200.exe" \
			  -D "JDK_INTERNAL_NAME=unpack200" \
			  -D "JDK_FTYPE=0x1L",\
	        DEBUG_SYMBOLS:=true,\
		MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest))

ifeq ($(OPENJDK_TARGET_OS),windows)
    EXE_OUT_OPTION:=$(EXE_OUT_OPTION_save)
endif

ifneq ($(USE_EXTERNAL_LIBZ), true)

$(BUILD_UNPACKEXE) : $(UNPACKEXE_ZIPOBJS)

endif

# Build into object dir and copy executable afterwards to avoid .ilk file in
# image. The real fix would be clean up linking of unpack200 using
# -link -incremental:no
# like all other launchers.
$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX): $(BUILD_UNPACKEXE)
	$(call install-file)

BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX)

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


BUILD_JEXEC :=
BUILD_JEXEC_SRC :=
BUILD_JEXEC_INC :=
BUILD_JEXEC_DST_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)

#
# UNHANDLED:
# - COMPILE_APPROACH = normal
#

#
# jdk/make/java/Makefile
#
ifeq ($(OPENJDK_TARGET_OS), solaris)
	ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
		BUILD_JEXEC := 1
	endif
endif

ifeq ($(OPENJDK_TARGET_OS), linux)
	BUILD_JEXEC := 1
endif # OPENJDK_TARGET_OS

#
# jdk/make/java/jexec/Makefile
#
ifeq ($(BUILD_JEXEC), 1)

	ifeq ($(OPENJDK_TARGET_OS),windows)
	else ifeq ($(OPENJDK_TARGET_OS),macosx)
		BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/macosx/bin
	else
		BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/solaris/bin
	endif

	ifeq ($(OPENJDK_TARGET_OS), linux)
                BUILD_JEXEC_DST_DIR := $(JDK_OUTPUTDIR)/lib
		BUILD_JEXEC_INC += -I$(JDK_TOPDIR)/src/share/bin
	endif
endif

#
# Note that the two Makefile's seems to contradict each other,
#   and that src/macosx/bin/jexec.c seems unused
#
ifneq ($(BUILD_JEXEC_SRC),)
        $(eval $(call SetupNativeCompilation,BUILD_JEXEC,\
		SRC:=$(BUILD_JEXEC_SRC),\
		INCLUDE_FILES:=jexec.c,\
		LANG:=C,\
		OPTIMIZATION := LOW, \
		CFLAGS:=$(CFLAGS_JDKEXE)\
                        $(BUILD_JEXEC_INC), \
		CFLAGS_linux:=-fPIC,\
		CFLAGS_solaris:=-KPIC,\
		LDFLAGS:=$(LDFLAGS_JDKEXE) \
			 $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)), \
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jexec_obj,\
		OUTPUT_DIR:=$(BUILD_JEXEC_DST_DIR),\
		DEBUG_SYMBOLS:=true,\
		PROGRAM:=jexec))

	BUILD_LAUNCHERS += $(BUILD_JEXEC)
endif

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

#
# The java-rmi.cgi script in bin/ only gets delivered in certain situations
#
JAVA_RMI_CGI:=$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/java-rmi.cgi
ifeq ($(OPENJDK_TARGET_OS), linux)
  BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
endif
ifeq ($(OPENJDK_TARGET_OS), solaris)
  ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
    BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
  endif
endif

# TODO:
# On windows java-rmi.cgi shouldn't be bundled since Java 1.2, but has been built all
# this time anyway. Since jdk6, it has been built from the wrong source and resulted
# in a (almost) copy of the standard java launcher named "java-rmi.exe" ending up in
# the final images bin dir. This weird behavior is mimicked here in the converted
# makefiles for now. Should probably just be deleted.
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6512052
ifeq ($(OPENJDK_TARGET_OS),windows)
    $(eval $(call SetupLauncher,java-rmi,,\
        $(call SET_SHARED_LIBRARY_MAPFILE,$(JDK_TOPDIR)/makefiles/java/main/java/mapfile-$(OPENJDK_TARGET_CPU))))
else
    $(JAVA_RMI_CGI): $(JDK_TOPDIR)/src/solaris/bin/java-rmi.cgi.sh
	$(call install-file)
	$(CHMOD) a+x $@
endif

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

BUILD_JSPAWNHELPER :=
BUILD_JSPAWNHELPER_SRC := $(JDK_TOPDIR)/src/solaris/native/java/lang
BUILD_JSPAWNHELPER_DST_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
LINK_JSPAWNHELPER_OBJECTS := $(JDK_OUTPUTDIR)/objs/libjava/childproc.o
LINK_JSPAWNHELPER_FLAGS :=

ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris),)
    BUILD_JSPAWNHELPER := 1
endif

ifeq ($(OPENJDK_TARGET_OS), macosx)
    BUILD_JSPAWNHELPER_DST_DIR := $(JDK_OUTPUTDIR)/lib
endif

ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
    LINK_JSPAWNHELPER_FLAGS += -m64
endif

ifeq ($(BUILD_JSPAWNHELPER), 1)
    $(eval $(call SetupNativeCompilation,BUILD_JSPAWNHELPER,\
        SRC:=$(BUILD_JSPAWNHELPER_SRC),\
        INCLUDE_FILES:=jspawnhelper.c,\
        LANG:=C,\
        OPTIMIZATION := LOW, \
        CFLAGS:=$(CFLAGS_JDKEXE), \
        LDFLAGS:=$(LDFLAGS_JDKEXE) $(LINK_JSPAWNHELPER_FLAGS), \
        LDFLAGS_SUFFIX:= $(LINK_JSPAWNHELPER_OBJECTS), \
        OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jspawnhelper,\
        OUTPUT_DIR:=$(BUILD_JSPAWNHELPER_DST_DIR),\
        PROGRAM:=jspawnhelper))

    $(BUILD_JSPAWNHELPER): $(LINK_JSPAWNHELPER_OBJECTS)

    BUILD_LAUNCHERS += $(BUILD_JSPAWNHELPER)
endif

##########################################################################################
# jabswitch

ifndef OPENJDK
ifeq ($(OPENJDK_TARGET_OS),windows)

    $(eval $(call SetupNativeCompilation,BUILD_JABSWITCH,\
		SRC:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge,\
		INCLUDE_FILES:=jabswitch.cpp,\
		LANG:=C++,\
		CFLAGS:=$(filter-out -Zc:wchar_t-,$(CFLAGS_JDKEXE)) -Zc:wchar_t \
			-analyze- -Od -Gd -D_WINDOWS \
			-D_UNICODE -DUNICODE -RTC1 -EHsc,\
		LDFLAGS:=$(LDFLAGS_JDKEXE) \
			 Advapi32.lib Version.lib User32.lib,\
		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jabswitch,\
		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/bin,\
		PROGRAM:=jabswitch,\
		DEBUG_SYMBOLS:=true,\
		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/AccessBridgeStatusWindow.rc,\
		RC_FLAGS:=$(RC_FLAGS),\
		MANIFEST:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/jabswitch.manifest))

    BUILD_LAUNCHERS += $(BUILD_JABSWITCH)

endif
endif

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

$(BUILD_LAUNCHERS) : $(JDK_TOPDIR)/makefiles/CompileLaunchers.gmk

all: $(BUILD_LAUNCHERS)

.PHONY: all