1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
#
# Copyright (c) 2011, 2020, 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.
#
include JdkNativeCompilation.gmk
include TextFileProcessing.gmk
ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/jli)
# 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,/../lib)
endif
# Tell the compiler not to export any functions unless declared so in
# the source code. On Windows, this is the default and cannot be changed.
# On Mac, we have always exported all symbols, probably due to oversight
# and/or misunderstanding. To emulate this, don't hide any symbols
# by default.
# On AIX/xlc we need at least xlc 13.1 for the symbol hiding (see JDK-8214063)
# Also provide an override for non-conformant libraries.
ifeq ($(TOOLCHAIN_TYPE), gcc)
LAUNCHER_CFLAGS += -fvisibility=hidden
LDFLAGS_JDKEXE += -Wl,--exclude-libs,ALL
else ifeq ($(TOOLCHAIN_TYPE), clang)
ifneq ($(OPENJDK_TARGET_OS), macosx)
LAUNCHER_CFLAGS += -fvisibility=hidden
endif
else ifeq ($(TOOLCHAIN_TYPE), solstudio)
LAUNCHER_CFLAGS += -xldscope=hidden
endif
LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher
LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \
-I$(TOPDIR)/src/java.base/share/native/libjli \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \
#
GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc
JAVA_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/launcher/java.rc
MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher
JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest
################################################################################
# Build standard launcher.
# Setup make rules for building a standard launcher.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name. It is also
# used as the name of the executable.
#
# Remaining parameters are named arguments. These include:
# MAIN_MODULE The module of the main class to launch if different from the
# current module
# MAIN_CLASS The Java main class to launch
# JAVA_ARGS Processed into a -DJAVA_ARGS and added to CFLAGS
# EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended
# before JAVA_ARGS to CFLAGS, primarily to allow long string literal
# compile time defines exceeding Visual Studio 2013 limitations.
# CFLAGS Additional CFLAGS
# CFLAGS_windows Additional CFLAGS_windows
# LIBS_unix Additional LIBS_unix
# LIBS_windows Additional LIBS_windows
# LDFLAGS_solaris Additional LDFLAGS_solaris
# RC_FLAGS Additional RC_FLAGS
# MACOSX_PRIVILEGED On macosx, allow to access other processes
# OPTIMIZATION Override default optimization level (LOW)
# OUTPUT_DIR Override default output directory
# VERSION_INFO_RESOURCE Override default Windows resource file
SetupBuildLauncher = $(NamedParamsMacroTemplate)
define SetupBuildLauncherBody
# Setup default values (unless overridden)
ifeq ($$($1_OPTIMIZATION), )
$1_OPTIMIZATION := LOW
endif
ifeq ($$($1_MAIN_MODULE), )
$1_MAIN_MODULE := $(MODULE)
endif
$1_JAVA_ARGS += -ms8m
ifneq ($$($1_MAIN_CLASS), )
$1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
endif
ifneq ($$($1_EXTRA_JAVA_ARGS), )
$1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
$$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
$1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
endif
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
$$(addprefix -J, $$($1_JAVA_ARGS)) $$($1_LAUNCHER_CLASS), "$$a"$(COMMA) )) }'
$1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
$1_LIBS :=
ifeq ($(OPENJDK_TARGET_OS), macosx)
ifeq ($$($1_MACOSX_PRIVILEGED), true)
$1_PLIST_EXTRA := <key>SecTaskAccess</key><string>allowed</string>
endif
$1_CFLAGS += -DPACKAGE_PATH='"$(PACKAGE_PATH)"'
$1_PLIST_FILE := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$1/Info.plist
$$(eval $$(call SetupTextFileProcessing, BUILD_PLIST_$1, \
SOURCE_FILES := $(TOPDIR)/make/data/bundle/cmdline-Info.plist, \
OUTPUT_FILE := $$($1_PLIST_FILE), \
REPLACEMENTS := \
@@ID@@ => $(MACOSX_BUNDLE_ID_BASE).$1 ; \
@@VERSION@@ => $(VERSION_NUMBER) ; \
@@BUILD_VERSION@@ => $(MACOSX_BUNDLE_BUILD_VERSION) ; \
@@EXTRA@@ => $$($1_PLIST_EXTRA), \
))
$1_LDFLAGS += -Wl,-all_load -sectcreate __TEXT __info_plist $$($1_PLIST_FILE)
ifeq ($(STATIC_BUILD), true)
$1_LDFLAGS += -exported_symbols_list \
$(SUPPORT_OUTPUTDIR)/build-static/exported.symbols
$1_LIBS += \
$$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \
$(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) \
-framework CoreFoundation \
-framework Foundation \
-framework SystemConfiguration \
-lstdc++ -liconv
endif
$1_LIBS += -framework Cocoa -framework Security \
-framework ApplicationServices
endif
ifeq ($(OPENJDK_TARGET_OS), aix)
$1_LDFLAGS += -L$(SUPPORT_OUTPUTDIR)/native/java.base
$1_LIBS += -ljli_static
endif
ifeq ($(USE_EXTERNAL_LIBZ), true)
$1_LIBS += -lz
endif
$1_WINDOWS_JLI_LIB := $(call FindStaticLib, java.base, jli, /libjli)
$$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
NAME := $1, \
EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
OPTIMIZATION := $$($1_OPTIMIZATION), \
CFLAGS := $$(CFLAGS_JDKEXE) $$($1_CFLAGS) \
$$(LAUNCHER_CFLAGS) \
$$(VERSION_CFLAGS) \
-DLAUNCHER_NAME='"$$(LAUNCHER_NAME)"' \
-DPROGNAME='"$1"' \
$$($1_CFLAGS), \
CFLAGS_solaris := -KPIC, \
CFLAGS_windows := $$($1_CFLAGS_windows), \
LDFLAGS := $$(LDFLAGS_JDKEXE) \
$$(ORIGIN_ARG) \
$$($1_LDFLAGS), \
LDFLAGS_linux := \
-L$(call FindLibDirForModule, java.base)/jli, \
LDFLAGS_macosx := \
-L$(call FindLibDirForModule, java.base)/jli, \
LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \
-L$(call FindLibDirForModule, java.base)/jli, \
LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \
LIBS_unix := $$($1_LIBS_unix), \
LIBS_linux := -lpthread -ljli $(LIBDL), \
LIBS_macosx := -ljli, \
LIBS_solaris := -ljli -lthread $(LIBDL), \
LIBS_windows := $$($1_WINDOWS_JLI_LIB) \
$(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \
$$($1_LIBS_windows), \
OUTPUT_DIR := $$($1_OUTPUT_DIR), \
VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \
EXTRA_RC_FLAGS := $$($1_EXTRA_RC_FLAGS), \
MANIFEST := $(JAVA_MANIFEST), \
MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
))
$1 += $$(BUILD_LAUNCHER_$1)
TARGETS += $$($1)
$$(BUILD_LAUNCHER_$1): $$(BUILD_PLIST_$1)
ifeq ($(call isTargetOs, aix), true)
$$(BUILD_LAUNCHER_$1): $(call FindStaticLib, java.base, jli_static)
endif
ifeq ($(call isTargetOs, windows), true)
$$(BUILD_LAUNCHER_$1): $(call FindStaticLib, java.base, java, /libjava) \
$$($1_WINDOWS_JLI_LIB)
endif
ifeq ($(call isTargetOs, macosx), true)
$$(BUILD_LAUNCHER_$1): $$($1_PLIST_FILE)
endif
endef
|