author | ihse |
Tue, 18 Sep 2018 13:32:40 +0200 | |
changeset 51783 | 4482acfef2a5 |
parent 50126 | 98f57dff16f3 |
child 51808 | 3f32076a43a6 |
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 |
||
49244
995a5556edfa
8199639: Introduce SetupJdkLibrary and SetupJdkExecutable
ihse
parents:
49241
diff
changeset
|
26 |
include JdkNativeCompilation.gmk |
25859 | 27 |
|
51783 | 28 |
ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/jli) |
25859 | 29 |
|
51783 | 30 |
# Applications expect to be able to link against libjawt without invoking |
31 |
# System.loadLibrary("jawt") first. This was the behaviour described in the |
|
32 |
# devloper documentation of JAWT and what worked with OpenJDK6. |
|
33 |
ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) |
|
34 |
ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib) |
|
25859 | 35 |
endif |
36 |
||
49534 | 37 |
# Tell the compiler not to export any functions unless declared so in |
38 |
# the source code. On Windows, this is the default and cannot be changed. |
|
39 |
# On Mac, we have always exported all symbols, probably due to oversight |
|
40 |
# and/or misunderstanding. To emulate this, don't hide any symbols |
|
41 |
# by default. |
|
50126
98f57dff16f3
8202322: AIX: symbol visibility flags not support on xlc 12.1
mbaesken
parents:
49534
diff
changeset
|
42 |
# On AIX/xlc we need at least xlc 13.1 for the symbol hiding |
49534 | 43 |
# Also provide an override for non-conformant libraries. |
44 |
ifeq ($(TOOLCHAIN_TYPE), gcc) |
|
45 |
LAUNCHER_CFLAGS += -fvisibility=hidden |
|
46 |
LDFLAGS_JDKEXE += -Wl,--exclude-libs,ALL |
|
47 |
else ifeq ($(TOOLCHAIN_TYPE), clang) |
|
48 |
ifneq ($(OPENJDK_TARGET_OS), macosx) |
|
49 |
LAUNCHER_CFLAGS += -fvisibility=hidden |
|
50 |
endif |
|
51 |
else ifeq ($(TOOLCHAIN_TYPE), solstudio) |
|
52 |
LAUNCHER_CFLAGS += -xldscope=hidden |
|
53 |
else ifeq ($(TOOLCHAIN_TYPE), xlc) |
|
50126
98f57dff16f3
8202322: AIX: symbol visibility flags not support on xlc 12.1
mbaesken
parents:
49534
diff
changeset
|
54 |
ifneq ($(CC_VERSION_NUMBER), 12.1) |
98f57dff16f3
8202322: AIX: symbol visibility flags not support on xlc 12.1
mbaesken
parents:
49534
diff
changeset
|
55 |
CXXFLAGS_JDKEXE += -qvisibility=hidden |
98f57dff16f3
8202322: AIX: symbol visibility flags not support on xlc 12.1
mbaesken
parents:
49534
diff
changeset
|
56 |
endif |
49534 | 57 |
endif |
58 |
||
47217 | 59 |
LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher |
49534 | 60 |
LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \ |
47217 | 61 |
-I$(TOPDIR)/src/java.base/share/native/libjli \ |
62 |
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \ |
|
63 |
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \ |
|
25859 | 64 |
# |
47217 | 65 |
GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc |
66 |
JAVA_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/launcher/java.rc |
|
67 |
MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher |
|
68 |
JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest |
|
25859 | 69 |
|
33523 | 70 |
################################################################################ |
71 |
# Build standard launcher. |
|
25859 | 72 |
|
33523 | 73 |
# Setup make rules for building a standard launcher. |
74 |
# |
|
75 |
# Parameter 1 is the name of the rule. This name is used as variable prefix, |
|
76 |
# and the targets generated are listed in a variable by that name. It is also |
|
77 |
# used as the name of the executable. |
|
78 |
# |
|
79 |
# Remaining parameters are named arguments. These include: |
|
36511 | 80 |
# MAIN_MODULE The module of the main class to launch if different from the |
81 |
# current module |
|
33523 | 82 |
# MAIN_CLASS The Java main class to launch |
45463
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
83 |
# 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
|
84 |
# 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
|
85 |
# 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
|
86 |
# compile time defines exceeding Visual Studio 2013 limitations. |
33523 | 87 |
# CFLAGS Additional CFLAGS |
88 |
# CFLAGS_windows Additional CFLAGS_windows |
|
89 |
# LIBS_unix Additional LIBS_unix |
|
90 |
# LIBS_windows Additional LIBS_windows |
|
91 |
# LDFLAGS_solaris Additional LDFLAGS_solaris |
|
92 |
# RC_FLAGS Additional RC_FLAGS |
|
93 |
# MACOSX_SIGNED On macosx, sign this binary |
|
94 |
# WINDOWS_STATIC_LINK On windows, link statically with C runtime and libjli. |
|
95 |
# OPTIMIZATION Override default optimization level (LOW) |
|
96 |
# OUTPUT_DIR Override default output directory |
|
97 |
# VERSION_INFO_RESOURCE Override default Windows resource file |
|
98 |
# NO_JAVA_MS Do not add -ms8m to JAVA_ARGS. |
|
99 |
SetupBuildLauncher = $(NamedParamsMacroTemplate) |
|
100 |
define SetupBuildLauncherBody |
|
101 |
# Setup default values (unless overridden) |
|
102 |
ifeq ($$($1_OPTIMIZATION), ) |
|
103 |
$1_OPTIMIZATION := LOW |
|
104 |
endif |
|
105 |
||
106 |
ifneq ($$($1_NO_JAVA_MS), true) |
|
107 |
# The norm is to append -ms8m, unless otherwise instructed. |
|
108 |
$1_JAVA_ARGS += -ms8m |
|
109 |
endif |
|
110 |
||
36511 | 111 |
ifeq ($$($1_MAIN_MODULE), ) |
112 |
$1_MAIN_MODULE := $(MODULE) |
|
113 |
endif |
|
114 |
||
33523 | 115 |
ifneq ($$($1_JAVA_ARGS), ) |
45463
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
116 |
ifneq ($$($1_EXTRA_JAVA_ARGS), ) |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
117 |
$1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
118 |
$$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }' |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
119 |
$1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR) |
d9325138bac6
8180334: Unable to build jaotc launcher on windows
ksrini
parents:
42753
diff
changeset
|
120 |
endif |
33523 | 121 |
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ |
36511 | 122 |
$$(addprefix -J, $$($1_JAVA_ARGS)) -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS), "$$a"$(COMMA) )) }' |
33523 | 123 |
$1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR) |
124 |
endif |
|
125 |
||
33406 | 126 |
$1_LIBS := |
25859 | 127 |
ifeq ($(OPENJDK_TARGET_OS), macosx) |
33523 | 128 |
ifeq ($$($1_MACOSX_SIGNED), true) |
129 |
$1_PLIST_FILE := Info-privileged.plist |
|
25859 | 130 |
$1_CODESIGN := true |
33523 | 131 |
else |
132 |
$1_PLIST_FILE := Info-cmdline.plist |
|
25859 | 133 |
endif |
134 |
||
33523 | 135 |
$1_CFLAGS += -DPACKAGE_PATH='"$(PACKAGE_PATH)"' |
33666 | 136 |
$1_LDFLAGS += -Wl,-all_load \ |
25859 | 137 |
-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
|
138 |
ifeq ($(STATIC_BUILD), true) |
33666 | 139 |
$1_LDFLAGS += -exported_symbols_list \ |
140 |
$(SUPPORT_OUTPUTDIR)/build-static/exported.symbols |
|
141 |
$1_LIBS += \ |
|
35241 | 142 |
$$(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
|
143 |
$(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
|
144 |
$(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
|
145 |
$(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
|
146 |
-framework CoreFoundation \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
147 |
-framework Foundation \ |
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
148 |
-framework SystemConfiguration \ |
33666 | 149 |
-lstdc++ -liconv |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32515
diff
changeset
|
150 |
endif |
33406 | 151 |
$1_LIBS += -framework Cocoa -framework Security \ |
152 |
-framework ApplicationServices |
|
25859 | 153 |
endif |
154 |
||
155 |
ifeq ($(OPENJDK_TARGET_OS), aix) |
|
33406 | 156 |
$1_LDFLAGS += -L$(SUPPORT_OUTPUTDIR)/native/java.base |
157 |
$1_LIBS += -ljli_static |
|
25859 | 158 |
endif |
159 |
||
160 |
ifeq ($(USE_EXTERNAL_LIBZ), true) |
|
33406 | 161 |
$1_LIBS += -lz |
25859 | 162 |
endif |
163 |
||
33523 | 164 |
ifeq ($$($1_WINDOWS_STATIC_LINK), true) |
165 |
$1_CFLAGS += $(filter-out -MD, $(CFLAGS_JDKEXE)) |
|
166 |
$1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib |
|
25859 | 167 |
else |
33523 | 168 |
$1_CFLAGS += $(CFLAGS_JDKEXE) |
169 |
$1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib |
|
25859 | 170 |
endif |
171 |
||
49244
995a5556edfa
8199639: Introduce SetupJdkLibrary and SetupJdkExecutable
ihse
parents:
49241
diff
changeset
|
172 |
$$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \ |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
173 |
NAME := $1, \ |
35241 | 174 |
EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \ |
33523 | 175 |
OPTIMIZATION := $$($1_OPTIMIZATION), \ |
25859 | 176 |
CFLAGS := $$($1_CFLAGS) \ |
177 |
$(LAUNCHER_CFLAGS) \ |
|
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
29931
diff
changeset
|
178 |
$(VERSION_CFLAGS) \ |
25859 | 179 |
-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \ |
33523 | 180 |
-DPROGNAME='"$1"' \ |
181 |
$$($1_CFLAGS), \ |
|
25859 | 182 |
CFLAGS_linux := -fPIC, \ |
183 |
CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \ |
|
33523 | 184 |
CFLAGS_windows := $$($1_CFLAGS_windows), \ |
34695
7a6cc9982d22
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
34389
diff
changeset
|
185 |
LDFLAGS := $$(LDFLAGS_JDKEXE) \ |
33523 | 186 |
$$(ORIGIN_ARG) \ |
25859 | 187 |
$$($1_LDFLAGS), \ |
33406 | 188 |
LDFLAGS_linux := \ |
42753
40f61533b93d
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
36511
diff
changeset
|
189 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ |
51783 | 190 |
LDFLAGS_macosx := \ |
191 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ |
|
25859 | 192 |
LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \ |
42753
40f61533b93d
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
36511
diff
changeset
|
193 |
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ |
33406 | 194 |
LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \ |
33523 | 195 |
LIBS_unix := $$($1_LIBS_unix), \ |
49241 | 196 |
LIBS_linux := -lpthread -ljli $(LIBDL), \ |
51783 | 197 |
LIBS_macosx := -ljli, \ |
49241 | 198 |
LIBS_solaris := -ljli -lthread $(LIBDL), \ |
33406 | 199 |
LIBS_windows := $$($1_WINDOWS_JLI_LIB) \ |
33523 | 200 |
$(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \ |
201 |
$$($1_LIBS_windows), \ |
|
202 |
OUTPUT_DIR := $$($1_OUTPUT_DIR), \ |
|
25859 | 203 |
VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \ |
49244
995a5556edfa
8199639: Introduce SetupJdkLibrary and SetupJdkExecutable
ihse
parents:
49241
diff
changeset
|
204 |
EXTRA_RC_FLAGS := $$($1_EXTRA_RC_FLAGS), \ |
25859 | 205 |
MANIFEST := $(JAVA_MANIFEST), \ |
33984
2333676816eb
8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents:
29931
diff
changeset
|
206 |
MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \ |
29925
6d47adfc6b47
8077847: Better handling of Windows executable manifest version
ihse
parents:
27953
diff
changeset
|
207 |
CODESIGN := $$($1_CODESIGN), \ |
33523 | 208 |
)) |
25859 | 209 |
|
33523 | 210 |
$1 += $$(BUILD_LAUNCHER_$1) |
211 |
TARGETS += $$($1) |
|
25859 | 212 |
|
51783 | 213 |
ifeq ($(OPENJDK_TARGET_OS), aix) |
27565 | 214 |
$$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a |
25859 | 215 |
endif |
216 |
||
217 |
ifeq ($(OPENJDK_TARGET_OS), windows) |
|
27565 | 218 |
$$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib \ |
25859 | 219 |
$$($1_WINDOWS_JLI_LIB) |
220 |
endif |
|
221 |
endef |