author | egahlin |
Tue, 23 Aug 2016 22:51:24 +0200 | |
changeset 40666 | 83beca9dbc5f |
parent 36511 | 9d0388c6b336 |
child 42753 | 40f61533b93d |
permissions | -rw-r--r-- |
25859 | 1 |
# |
35781 | 2 |
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
25859 | 3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
# |
|
5 |
# This code is free software; you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
|
7 |
# published by the Free Software Foundation. Oracle designates this |
|
8 |
# particular file as subject to the "Classpath" exception as provided |
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
24 |
# |
|
25 |
||
26 |
include NativeCompilation.gmk |
|
27 |
||
28 |
ifeq ($(OPENJDK_TARGET_OS), macosx) |
|
35781 | 29 |
DISABLE_MAPFILES := true |
25859 | 30 |
ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN) |
31 |
else |
|
35781 | 32 |
ifeq ($(OPENJDK_TARGET_OS), windows) |
33 |
DISABLE_MAPFILES := true |
|
34 |
endif |
|
33523 | 35 |
ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli) |
25859 | 36 |
|
33523 | 37 |
# Applications expect to be able to link against libjawt without invoking |
38 |
# System.loadLibrary("jawt") first. This was the behaviour described in the |
|
39 |
# devloper documentation of JAWT and what worked with OpenJDK6. |
|
40 |
ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) |
|
41 |
ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib$(OPENJDK_TARGET_CPU_LIBDIR)) |
|
42 |
endif |
|
25859 | 43 |
endif |
44 |
||
45 |
LAUNCHER_SRC := $(JDK_TOPDIR)/src/java.base/share/native/launcher |
|
46 |
LAUNCHER_CFLAGS := -I$(JDK_TOPDIR)/src/java.base/share/native/launcher \ |
|
47 |
-I$(JDK_TOPDIR)/src/java.base/share/native/libjli \ |
|
27736
8c9bd4be4a86
8058631: Rename posix to unix in build system to match file name changes
ihse
parents:
25859
diff
changeset
|
48 |
-I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \ |
25859 | 49 |
-I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \ |
50 |
# |
|
51 |
GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc |
|
52 |
JAVA_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/launcher/java.rc |
|
53 |
MACOSX_PLIST_DIR := $(JDK_TOPDIR)/src/java.base/macosx/native/launcher |
|
54 |
JAVA_MANIFEST := $(JDK_TOPDIR)/src/java.base/windows/native/launcher/java.manifest |
|
55 |
||
33523 | 56 |
################################################################################ |
57 |
# Build standard launcher. |
|
25859 | 58 |
|
33523 | 59 |
# Setup make rules for building a standard launcher. |
60 |
# |
|
61 |
# Parameter 1 is the name of the rule. This name is used as variable prefix, |
|
62 |
# and the targets generated are listed in a variable by that name. It is also |
|
63 |
# used as the name of the executable. |
|
64 |
# |
|
65 |
# Remaining parameters are named arguments. These include: |
|
36511 | 66 |
# MAIN_MODULE The module of the main class to launch if different from the |
67 |
# current module |
|
33523 | 68 |
# MAIN_CLASS The Java main class to launch |
69 |
# JAVA_ARGS Processed into a -DJAVA_ARGS C flag |
|
70 |
# CFLAGS Additional CFLAGS |
|
71 |
# CFLAGS_windows Additional CFLAGS_windows |
|
72 |
# LIBS_unix Additional LIBS_unix |
|
73 |
# LIBS_windows Additional LIBS_windows |
|
74 |
# LDFLAGS_solaris Additional LDFLAGS_solaris |
|
75 |
# RC_FLAGS Additional RC_FLAGS |
|
76 |
# MACOSX_SIGNED On macosx, sign this binary |
|
77 |
# WINDOWS_STATIC_LINK On windows, link statically with C runtime and libjli. |
|
78 |
# OPTIMIZATION Override default optimization level (LOW) |
|
79 |
# OUTPUT_DIR Override default output directory |
|
80 |
# VERSION_INFO_RESOURCE Override default Windows resource file |
|
81 |
# NO_JAVA_MS Do not add -ms8m to JAVA_ARGS. |
|
82 |
SetupBuildLauncher = $(NamedParamsMacroTemplate) |
|
83 |
define SetupBuildLauncherBody |
|
84 |
# Setup default values (unless overridden) |
|
85 |
ifeq ($$($1_VERSION_INFO_RESOURCE), ) |
|
86 |
$1_VERSION_INFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE) |
|
25859 | 87 |
endif |
88 |
||
33523 | 89 |
ifeq ($$($1_OUTPUT_DIR), ) |
90 |
$1_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE) |
|
25859 | 91 |
endif |
92 |
||
33523 | 93 |
ifeq ($$($1_OPTIMIZATION), ) |
94 |
$1_OPTIMIZATION := LOW |
|
95 |
endif |
|
96 |
||
97 |
ifneq ($$($1_NO_JAVA_MS), true) |
|
98 |
# The norm is to append -ms8m, unless otherwise instructed. |
|
99 |
$1_JAVA_ARGS += -ms8m |
|
100 |
endif |
|
101 |
||
36511 | 102 |
ifeq ($$($1_MAIN_MODULE), ) |
103 |
$1_MAIN_MODULE := $(MODULE) |
|
104 |
endif |
|
105 |
||
33523 | 106 |
ifneq ($$($1_JAVA_ARGS), ) |
107 |
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ |
|
36511 | 108 |
$$(addprefix -J, $$($1_JAVA_ARGS)) -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS), "$$a"$(COMMA) )) }' |
33523 | 109 |
$1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR) |
110 |
endif |
|
111 |
||
33406 | 112 |
$1_LIBS := |
25859 | 113 |
ifeq ($(OPENJDK_TARGET_OS), macosx) |
33523 | 114 |
ifeq ($$($1_MACOSX_SIGNED), true) |
115 |
$1_PLIST_FILE := Info-privileged.plist |
|
25859 | 116 |
$1_CODESIGN := true |
33523 | 117 |
else |
118 |
$1_PLIST_FILE := Info-cmdline.plist |
|
25859 | 119 |
endif |
120 |
||
33523 | 121 |
$1_CFLAGS += -DPACKAGE_PATH='"$(PACKAGE_PATH)"' |
33666 | 122 |
$1_LDFLAGS += -Wl,-all_load \ |
25859 | 123 |
-sectcreate __TEXT __info_plist $(MACOSX_PLIST_DIR)/$$($1_PLIST_FILE) |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
124 |
ifeq ($(STATIC_BUILD), true) |
33666 | 125 |
$1_LDFLAGS += -exported_symbols_list \ |
126 |
$(SUPPORT_OUTPUTDIR)/build-static/exported.symbols |
|
127 |
$1_LIBS += \ |
|
35241 | 128 |
$$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \ |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
129 |
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
130 |
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
131 |
$(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
132 |
-framework CoreFoundation \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
133 |
-framework Foundation \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
134 |
-framework SystemConfiguration \ |
33666 | 135 |
-lstdc++ -liconv |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
136 |
else |
33666 | 137 |
$1_LIBS += $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
138 |
endif |
33406 | 139 |
$1_LIBS += -framework Cocoa -framework Security \ |
140 |
-framework ApplicationServices |
|
25859 | 141 |
endif |
142 |
||
143 |
ifeq ($(OPENJDK_TARGET_OS), aix) |
|
33406 | 144 |
$1_LDFLAGS += -L$(SUPPORT_OUTPUTDIR)/native/java.base |
145 |
$1_LIBS += -ljli_static |
|
25859 | 146 |
endif |
147 |
||
148 |
ifeq ($(USE_EXTERNAL_LIBZ), true) |
|
33406 | 149 |
$1_LIBS += -lz |
25859 | 150 |
endif |
151 |
||
33523 | 152 |
ifeq ($$($1_WINDOWS_STATIC_LINK), true) |
153 |
$1_CFLAGS += $(filter-out -MD, $(CFLAGS_JDKEXE)) |
|
154 |
$1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib |
|
25859 | 155 |
else |
33523 | 156 |
$1_CFLAGS += $(CFLAGS_JDKEXE) |
157 |
$1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib |
|
25859 | 158 |
endif |
159 |
||
160 |
# The linker on older SuSE distros (e.g. on SLES 10) complains with: |
|
161 |
# "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable." |
|
162 |
# if feeded with a version script which contains named tags. |
|
163 |
ifeq ($(USING_BROKEN_SUSE_LD),yes) |
|
164 |
ifneq ($(wildcard $(JDK_TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU).anonymous), ) |
|
165 |
$1_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU).anonymous |
|
166 |
else |
|
167 |
$1_MAPFILE := |
|
168 |
endif |
|
169 |
else |
|
170 |
ifneq ($(wildcard $(JDK_TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU)), ) |
|
171 |
$1_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU) |
|
172 |
else |
|
173 |
$1_MAPFILE := |
|
174 |
endif |
|
175 |
endif |
|
176 |
||
33523 | 177 |
$$(eval $$(call SetupNativeCompilation, BUILD_LAUNCHER_$1, \ |
35241 | 178 |
EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \ |
33523 | 179 |
OPTIMIZATION := $$($1_OPTIMIZATION), \ |
25859 | 180 |
CFLAGS := $$($1_CFLAGS) \ |
181 |
$(LAUNCHER_CFLAGS) \ |
|
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
29931
diff
changeset
|
182 |
$(VERSION_CFLAGS) \ |
25859 | 183 |
-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \ |
33523 | 184 |
-DPROGNAME='"$1"' \ |
185 |
$$($1_CFLAGS), \ |
|
25859 | 186 |
CFLAGS_linux := -fPIC, \ |
187 |
CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \ |
|
33523 | 188 |
CFLAGS_windows := $$($1_CFLAGS_windows), \ |
34695
7a6cc9982d22
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
34389
diff
changeset
|
189 |
LDFLAGS := $$(LDFLAGS_JDKEXE) \ |
33523 | 190 |
$$(ORIGIN_ARG) \ |
25859 | 191 |
$$($1_LDFLAGS), \ |
33406 | 192 |
LDFLAGS_linux := \ |
193 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base$(OPENJDK_TARGET_CPU_LIBDIR)/jli, \ |
|
25859 | 194 |
LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \ |
33406 | 195 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base$(OPENJDK_TARGET_CPU_LIBDIR)/jli, \ |
25859 | 196 |
MAPFILE := $$($1_MAPFILE), \ |
33406 | 197 |
LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \ |
33523 | 198 |
LIBS_unix := $$($1_LIBS_unix), \ |
33406 | 199 |
LIBS_linux := -lpthread -ljli $(LIBDL) -lc, \ |
200 |
LIBS_solaris := -ljli -lthread $(LIBDL) -lc, \ |
|
201 |
LIBS_windows := $$($1_WINDOWS_JLI_LIB) \ |
|
33523 | 202 |
$(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \ |
203 |
$$($1_LIBS_windows), \ |
|
204 |
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$1_objs, \ |
|
205 |
OUTPUT_DIR := $$($1_OUTPUT_DIR), \ |
|
25859 | 206 |
PROGRAM := $1, \ |
207 |
VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \ |
|
33523 | 208 |
RC_FLAGS := $$(RC_FLAGS) \ |
25859 | 209 |
-D "JDK_FNAME=$1$(EXE_SUFFIX)" \ |
210 |
-D "JDK_INTERNAL_NAME=$1" \ |
|
211 |
-D "JDK_FTYPE=0x1L" \ |
|
33523 | 212 |
$$($1_RC_FLAGS), \ |
25859 | 213 |
MANIFEST := $(JAVA_MANIFEST), \ |
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
29931
diff
changeset
|
214 |
MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \ |
29925
6d47adfc6b47
8077847: Better handling of Windows executable manifest version
ihse
parents:
27953
diff
changeset
|
215 |
CODESIGN := $$($1_CODESIGN), \ |
33523 | 216 |
)) |
25859 | 217 |
|
33523 | 218 |
$1 += $$(BUILD_LAUNCHER_$1) |
219 |
TARGETS += $$($1) |
|
25859 | 220 |
|
221 |
ifneq (,$(filter $(OPENJDK_TARGET_OS), macosx aix)) |
|
27565 | 222 |
$$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a |
25859 | 223 |
endif |
224 |
||
225 |
ifeq ($(OPENJDK_TARGET_OS), windows) |
|
27565 | 226 |
$$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib \ |
25859 | 227 |
$$($1_WINDOWS_JLI_LIB) |
228 |
endif |
|
229 |
endef |