@@ -48,8 +48,8 @@ ifneq ($(word 2, $(wildcard $(HOTSPOT_STATIC_LIB_PATH))), )
4848endif
4949
5050# Find all modules with static libraries
51- STATIC_LIB_MODULES := $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-libs/%, \
52- %, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-libs/*))
51+ STATIC_LIB_MODULES := $(sort $( patsubst $(SUPPORT_OUTPUTDIR)/modules_static-libs/%, \
52+ %, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-libs/*)))
5353
5454# Filter out known broken libraries. This is a temporary measure until
5555# proper support for these libraries can be provided.
@@ -123,13 +123,18 @@ else
123123 $(error Unsupported platform)
124124endif
125125
126+ ################################################################################
127+ # Build the java static launcher
128+ ################################################################################
126129$(eval $(call SetupBuildLauncher, java, \
127130 ENABLE_ARG_FILES := true, \
128131 EXPAND_CLASSPATH_WILDCARDS := true, \
129132 EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
130133 VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
131134 OPTIMIZATION := HIGH, \
135+ MACOSX_PRIVILEGED := true, \
132136 STATIC_LAUNCHER := true, \
137+ CFLAGS := -DSTATIC_BUILD, \
133138 LDFLAGS := $(LDFLAGS_STATIC_JDK), \
134139 LIBS := $(STATIC_LIBS) $(EXTERNAL_LIBS), \
135140 LINK_TYPE := C++, \
@@ -146,7 +151,53 @@ TARGETS += $(java)
146151
147152JAVA_LAUNCHER := $(BUILD_LAUNCHER_java_TARGET)
148153
149- static-launcher: $(java)
154+ static-launchers: $(java)
155+
156+ ################################################################################
157+ # Build relaunchers (thin wrappers calling the java binary) for all other
158+ # JDK launchers.
159+ ################################################################################
160+
161+ RELAUNCHER_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/launcher
162+
163+ # $1: The module name
164+ # $2: The launcher name
165+ define SetupRelauncher
166+ $1_$2_LAUNCHER_ARGS_LINE := $$(call ReadFile, $$(SUPPORT_OUTPUTDIR)/static-native/relaunchers/$1/$2-relauncher-arguments.txt)
167+ # Restore |||| with space
168+ $1_$2_LAUNCHER_ARGS := '{ $$(subst ||||,$(SPACE),$$(strip $$(foreach a, $$($1_$2_LAUNCHER_ARGS_LINE), "-J$$a"$$(COMMA) )) ) }'
169+
170+ $$(eval $$(call SetupJdkExecutable, BUILD_relauncher_$2, \
171+ NAME := $2, \
172+ EXTRA_FILES := $$(RELAUNCHER_SRC)/relauncher.c, \
173+ CFLAGS := -DLAUNCHER_ARGS=$$($1_$2_LAUNCHER_ARGS), \
174+ LIBS_windows := shlwapi.lib, \
175+ OUTPUT_DIR := $$(STATIC_LAUNCHER_OUTPUT_DIR), \
176+ OBJECT_DIR := $$(STATIC_LAUNCHER_OUTPUT_DIR)/relaunchers/$2, \
177+ ))
178+
179+ TARGETS += $$(BUILD_relauncher_$2)
180+
181+ RELAUNCHERS += $$(BUILD_relauncher_$2_TARGET)
182+ static-launchers: $$(BUILD_relauncher_$2)
183+ endef
184+
185+ # Find all modules with launchers
186+ LAUNCHER_MODULES := $(sort $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-launchers/%, \
187+ %, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-launchers/*)))
188+
189+ # Find launchers for each module
190+ $(foreach module, $(LAUNCHER_MODULES), \
191+ $(eval LAUNCHERS_$(module) := $(if $(wildcard \
192+ $(SUPPORT_OUTPUTDIR)/modules_static-launchers/$(module)/module-included-launchers.txt), \
193+ $(shell cat \
194+ $(SUPPORT_OUTPUTDIR)/modules_static-launchers/$(module)/module-included-launchers.txt))) \
195+ )
196+
197+ # For all launchers (except java and javaw), setup a relauncher build
198+ $(foreach module, $(LAUNCHER_MODULES), \
199+ $(foreach launcher, $(filter-out java javaw, $(LAUNCHERS_$(module))), \
200+ $(eval $(call SetupRelauncher,$(module),$(launcher)))))
150201
151202################################################################################
152203#
@@ -188,26 +239,72 @@ TARGETS += $(copy-from-jdk-image)
188239
189240$(copy-from-jdk-image): | static-jdk-info
190241
191- $(eval $(call SetupCopyFiles, copy-static-launcher , \
192- FILES := $(JAVA_LAUNCHER), \
242+ $(eval $(call SetupCopyFiles, copy-static-launchers , \
243+ FILES := $(JAVA_LAUNCHER) $(RELAUNCHERS) , \
193244 DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
194245))
195246
196- TARGETS += $(copy-static-launcher )
247+ TARGETS += $(copy-static-launchers )
197248
198- $(eval $(call SetupCopyFiles, copy-static-launcher -debuginfo, \
249+ $(eval $(call SetupCopyFiles, copy-static-launchers -debuginfo, \
199250 SRC := $(STATIC_LAUNCHER_OUTPUT_DIR), \
200251 DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
201252 FILES := $(call FindDebuginfoFiles, $(STATIC_LAUNCHER_OUTPUT_DIR)), \
202253))
203254
204- TARGETS += $(copy-static-launcher-debuginfo)
255+ TARGETS += $(copy-static-launchers-debuginfo)
256+
257+ # Copy the microsoft runtime libraries on windows
258+ ifeq ($(call isTargetOs, windows), true)
259+ # Chmod to avoid permission issues if bundles are unpacked on unix platforms.
260+ # Use separate macro calls in case the source files are not in the same
261+ # directory.
262+ $(eval $(call SetupCopyFiles, copy-windows-msvcr, \
263+ DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
264+ FILES := $(MSVCR_DLL), \
265+ MACRO := copy-and-chmod-executable, \
266+ ))
267+
268+ TARGETS += $(copy-windows-msvcr)
269+
270+ $(eval $(call SetupCopyFiles, copy-windows-vcruntime, \
271+ DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
272+ FILES := $(VCRUNTIME_1_DLL), \
273+ MACRO := copy-and-chmod-executable, \
274+ ))
275+
276+ TARGETS += $(copy-windows-vcruntime)
277+
278+ $(eval $(call SetupCopyFiles, copy-windows-msvcp, \
279+ DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
280+ FILES := $(MSVCP_DLL), \
281+ MACRO := copy-and-chmod-executable, \
282+ ))
283+
284+ TARGETS += $(copy-windows-msvcp)
285+
286+ copy-windows-libs := $(copy-windows-msvcr) $(copy-windows-vcruntime) $(copy-windows-msvcp)
287+
288+ ifneq ($(UCRT_DLL_DIR), )
289+ $(eval $(call SetupCopyFiles, copy-windows-ucrt, \
290+ DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
291+ SRC := $(UCRT_DLL_DIR), \
292+ FILES := $(wildcard $(UCRT_DLL_DIR)/*.dll), \
293+ MACRO := copy-and-chmod-executable, \
294+ ))
295+
296+ TARGETS += $(copy-windows-ucrt)
297+
298+ copy-windows-libs += $(copy-windows-ucrt)
299+ endif
300+ endif
205301
206- static-jdk-image: $(copy-from-jdk-image) $(copy-static-launcher) $(copy-static-launcher-debuginfo)
302+ static-jdk-image: $(copy-from-jdk-image) $(copy-static-launchers) \
303+ $(copy-static-launchers-debuginfo) $(copy-windows-libs)
207304
208305TARGETS += static-jdk-image
209306
210- .PHONY: static-launcher static-jdk-image
307+ .PHONY: static-launchers static-jdk-image
211308
212309################################################################################
213310
0 commit comments