author | jwilhelm |
Fri, 02 Mar 2018 21:00:12 +0100 | |
changeset 49331 | 10b24a3af249 |
parent 49070 | d7859531621b |
child 49241 | de4b3a04feae |
child 56287 | 593a452fcbeb |
permissions | -rw-r--r-- |
25859 | 1 |
# |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
2 |
# Copyright (c) 2011, 2018, 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 |
|
42753
40f61533b93d
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
36511
diff
changeset
|
35 |
ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/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), ) |
|
42753
40f61533b93d
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
36511
diff
changeset
|
41 |
ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib) |
33523 | 42 |
endif |
25859 | 43 |
endif |
44 |
||
47217 | 45 |
LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher |
46 |
LAUNCHER_CFLAGS := -I$(TOPDIR)/src/java.base/share/native/launcher \ |
|
47 |
-I$(TOPDIR)/src/java.base/share/native/libjli \ |
|
48 |
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \ |
|
49 |
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \ |
|
25859 | 50 |
# |
47217 | 51 |
GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc |
52 |
JAVA_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/launcher/java.rc |
|
53 |
MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher |
|
54 |
JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest |
|
25859 | 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 |
45463
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
69 |
# JAVA_ARGS Processed into a -DJAVA_ARGS and added to CFLAGS |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
70 |
# EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
71 |
# before JAVA_ARGS to CFLAGS, primarily to allow long string literal |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
72 |
# compile time defines exceeding Visual Studio 2013 limitations. |
33523 | 73 |
# CFLAGS Additional CFLAGS |
74 |
# CFLAGS_windows Additional CFLAGS_windows |
|
75 |
# LIBS_unix Additional LIBS_unix |
|
76 |
# LIBS_windows Additional LIBS_windows |
|
77 |
# LDFLAGS_solaris Additional LDFLAGS_solaris |
|
78 |
# RC_FLAGS Additional RC_FLAGS |
|
79 |
# MACOSX_SIGNED On macosx, sign this binary |
|
80 |
# WINDOWS_STATIC_LINK On windows, link statically with C runtime and libjli. |
|
81 |
# OPTIMIZATION Override default optimization level (LOW) |
|
82 |
# OUTPUT_DIR Override default output directory |
|
83 |
# VERSION_INFO_RESOURCE Override default Windows resource file |
|
84 |
# NO_JAVA_MS Do not add -ms8m to JAVA_ARGS. |
|
85 |
SetupBuildLauncher = $(NamedParamsMacroTemplate) |
|
86 |
define SetupBuildLauncherBody |
|
87 |
# Setup default values (unless overridden) |
|
88 |
ifeq ($$($1_VERSION_INFO_RESOURCE), ) |
|
89 |
$1_VERSION_INFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE) |
|
25859 | 90 |
endif |
91 |
||
33523 | 92 |
ifeq ($$($1_OUTPUT_DIR), ) |
93 |
$1_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE) |
|
25859 | 94 |
endif |
95 |
||
33523 | 96 |
ifeq ($$($1_OPTIMIZATION), ) |
97 |
$1_OPTIMIZATION := LOW |
|
98 |
endif |
|
99 |
||
100 |
ifneq ($$($1_NO_JAVA_MS), true) |
|
101 |
# The norm is to append -ms8m, unless otherwise instructed. |
|
102 |
$1_JAVA_ARGS += -ms8m |
|
103 |
endif |
|
104 |
||
36511 | 105 |
ifeq ($$($1_MAIN_MODULE), ) |
106 |
$1_MAIN_MODULE := $(MODULE) |
|
107 |
endif |
|
108 |
||
33523 | 109 |
ifneq ($$($1_JAVA_ARGS), ) |
45463
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
110 |
ifneq ($$($1_EXTRA_JAVA_ARGS), ) |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
111 |
$1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
112 |
$$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }' |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
113 |
$1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR) |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
114 |
endif |
33523 | 115 |
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ |
36511 | 116 |
$$(addprefix -J, $$($1_JAVA_ARGS)) -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS), "$$a"$(COMMA) )) }' |
33523 | 117 |
$1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR) |
118 |
endif |
|
119 |
||
33406 | 120 |
$1_LIBS := |
25859 | 121 |
ifeq ($(OPENJDK_TARGET_OS), macosx) |
33523 | 122 |
ifeq ($$($1_MACOSX_SIGNED), true) |
123 |
$1_PLIST_FILE := Info-privileged.plist |
|
25859 | 124 |
$1_CODESIGN := true |
33523 | 125 |
else |
126 |
$1_PLIST_FILE := Info-cmdline.plist |
|
25859 | 127 |
endif |
128 |
||
33523 | 129 |
$1_CFLAGS += -DPACKAGE_PATH='"$(PACKAGE_PATH)"' |
33666 | 130 |
$1_LDFLAGS += -Wl,-all_load \ |
25859 | 131 |
-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
|
132 |
ifeq ($(STATIC_BUILD), true) |
33666 | 133 |
$1_LDFLAGS += -exported_symbols_list \ |
134 |
$(SUPPORT_OUTPUTDIR)/build-static/exported.symbols |
|
135 |
$1_LIBS += \ |
|
35241 | 136 |
$$(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
|
137 |
$(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
|
138 |
$(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
|
139 |
$(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
|
140 |
-framework CoreFoundation \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
141 |
-framework Foundation \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
142 |
-framework SystemConfiguration \ |
33666 | 143 |
-lstdc++ -liconv |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
144 |
else |
33666 | 145 |
$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
|
146 |
endif |
33406 | 147 |
$1_LIBS += -framework Cocoa -framework Security \ |
148 |
-framework ApplicationServices |
|
25859 | 149 |
endif |
150 |
||
151 |
ifeq ($(OPENJDK_TARGET_OS), aix) |
|
33406 | 152 |
$1_LDFLAGS += -L$(SUPPORT_OUTPUTDIR)/native/java.base |
153 |
$1_LIBS += -ljli_static |
|
25859 | 154 |
endif |
155 |
||
156 |
ifeq ($(USE_EXTERNAL_LIBZ), true) |
|
33406 | 157 |
$1_LIBS += -lz |
25859 | 158 |
endif |
159 |
||
33523 | 160 |
ifeq ($$($1_WINDOWS_STATIC_LINK), true) |
161 |
$1_CFLAGS += $(filter-out -MD, $(CFLAGS_JDKEXE)) |
|
162 |
$1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib |
|
25859 | 163 |
else |
33523 | 164 |
$1_CFLAGS += $(CFLAGS_JDKEXE) |
165 |
$1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib |
|
25859 | 166 |
endif |
167 |
||
168 |
# The linker on older SuSE distros (e.g. on SLES 10) complains with: |
|
169 |
# "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable." |
|
170 |
# if feeded with a version script which contains named tags. |
|
171 |
ifeq ($(USING_BROKEN_SUSE_LD),yes) |
|
47217 | 172 |
ifneq ($(wildcard $(TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU).anonymous), ) |
173 |
$1_MAPFILE := $(TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU).anonymous |
|
25859 | 174 |
else |
175 |
$1_MAPFILE := |
|
176 |
endif |
|
177 |
else |
|
47217 | 178 |
ifneq ($(wildcard $(TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU)), ) |
179 |
$1_MAPFILE := $(TOPDIR)/make/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU) |
|
25859 | 180 |
else |
181 |
$1_MAPFILE := |
|
182 |
endif |
|
183 |
endif |
|
184 |
||
33523 | 185 |
$$(eval $$(call SetupNativeCompilation, BUILD_LAUNCHER_$1, \ |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
186 |
NAME := $1, \ |
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
187 |
TYPE := EXECUTABLE, \ |
35241 | 188 |
EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \ |
33523 | 189 |
OPTIMIZATION := $$($1_OPTIMIZATION), \ |
25859 | 190 |
CFLAGS := $$($1_CFLAGS) \ |
191 |
$(LAUNCHER_CFLAGS) \ |
|
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
29931
diff
changeset
|
192 |
$(VERSION_CFLAGS) \ |
25859 | 193 |
-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \ |
33523 | 194 |
-DPROGNAME='"$1"' \ |
195 |
$$($1_CFLAGS), \ |
|
25859 | 196 |
CFLAGS_linux := -fPIC, \ |
197 |
CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \ |
|
33523 | 198 |
CFLAGS_windows := $$($1_CFLAGS_windows), \ |
34695
7a6cc9982d22
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
34389
diff
changeset
|
199 |
LDFLAGS := $$(LDFLAGS_JDKEXE) \ |
33523 | 200 |
$$(ORIGIN_ARG) \ |
25859 | 201 |
$$($1_LDFLAGS), \ |
33406 | 202 |
LDFLAGS_linux := \ |
42753
40f61533b93d
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
36511
diff
changeset
|
203 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ |
25859 | 204 |
LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \ |
42753
40f61533b93d
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
36511
diff
changeset
|
205 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ |
25859 | 206 |
MAPFILE := $$($1_MAPFILE), \ |
33406 | 207 |
LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \ |
33523 | 208 |
LIBS_unix := $$($1_LIBS_unix), \ |
33406 | 209 |
LIBS_linux := -lpthread -ljli $(LIBDL) -lc, \ |
210 |
LIBS_solaris := -ljli -lthread $(LIBDL) -lc, \ |
|
211 |
LIBS_windows := $$($1_WINDOWS_JLI_LIB) \ |
|
33523 | 212 |
$(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \ |
213 |
$$($1_LIBS_windows), \ |
|
214 |
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$1_objs, \ |
|
215 |
OUTPUT_DIR := $$($1_OUTPUT_DIR), \ |
|
25859 | 216 |
VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \ |
33523 | 217 |
RC_FLAGS := $$(RC_FLAGS) \ |
25859 | 218 |
-D "JDK_FNAME=$1$(EXE_SUFFIX)" \ |
219 |
-D "JDK_INTERNAL_NAME=$1" \ |
|
220 |
-D "JDK_FTYPE=0x1L" \ |
|
33523 | 221 |
$$($1_RC_FLAGS), \ |
25859 | 222 |
MANIFEST := $(JAVA_MANIFEST), \ |
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
29931
diff
changeset
|
223 |
MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \ |
29925
6d47adfc6b47
8077847: Better handling of Windows executable manifest version
ihse
parents:
27953
diff
changeset
|
224 |
CODESIGN := $$($1_CODESIGN), \ |
33523 | 225 |
)) |
25859 | 226 |
|
33523 | 227 |
$1 += $$(BUILD_LAUNCHER_$1) |
228 |
TARGETS += $$($1) |
|
25859 | 229 |
|
230 |
ifneq (,$(filter $(OPENJDK_TARGET_OS), macosx aix)) |
|
27565 | 231 |
$$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a |
25859 | 232 |
endif |
233 |
||
234 |
ifeq ($(OPENJDK_TARGET_OS), windows) |
|
27565 | 235 |
$$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib \ |
25859 | 236 |
$$($1_WINDOWS_JLI_LIB) |
237 |
endif |
|
238 |
endef |