author | fyuan |
Tue, 25 Sep 2018 11:24:59 +0800 | |
changeset 51859 | 1a35c474e4a6 |
parent 50847 | b970fae53807 |
child 52022 | 804792ce736f |
permissions | -rw-r--r-- |
49244 | 1 |
# |
2 |
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
|
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 |
ifndef _JDK_NATIVE_COMPILATION_GMK |
|
27 |
_JDK_NATIVE_COMPILATION_GMK := 1 |
|
28 |
||
29 |
ifeq ($(_MAKEBASE_GMK), ) |
|
30 |
$(error You must include MakeBase.gmk prior to including JdkNativeCompilation.gmk) |
|
31 |
endif |
|
32 |
||
33 |
include NativeCompilation.gmk |
|
34 |
||
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
35 |
# Hook to include the corresponding custom file, if present. |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
36 |
$(eval $(call IncludeCustomExtension, common/JdkNativeCompilation.gmk)) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
37 |
|
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
38 |
FindSrcDirsForLib += \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
39 |
$(call uniq, $(wildcard \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
40 |
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/lib$(strip $2) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
41 |
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
42 |
$(TOPDIR)/src/$(strip $1)/share/native/lib$(strip $2))) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
43 |
|
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
44 |
FindSrcDirsForComponent += \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
45 |
$(call uniq, $(wildcard \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
46 |
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/$(strip $2) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
47 |
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/$(strip $2) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
48 |
$(TOPDIR)/src/$(strip $1)/share/native/$(strip $2))) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
49 |
|
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
50 |
GetJavaHeaderDir = \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
51 |
$(wildcard $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
52 |
|
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
53 |
# Process a dir description such as "java.base:headers" into a set of proper absolute paths. |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
54 |
ProcessDir = \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
55 |
$(if $(findstring :, $1), \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
56 |
$(call FindSrcDirsForComponent, $(firstword $(subst :, , $1)), $(lastword $(subst :, , $1))) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
57 |
, \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
58 |
$(if $(filter /%, $1), \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
59 |
$1 \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
60 |
, \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
61 |
$(call FindSrcDirsForComponent, $(MODULE), $1) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
62 |
) \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
63 |
) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
64 |
|
49244 | 65 |
# Setup make rules for creating a native shared library with suitable defaults |
66 |
# for the OpenJDK project. |
|
67 |
# |
|
68 |
# Parameter 1 is the name of the rule. This name is used as variable prefix, |
|
69 |
# and the targets generated are listed in a variable by that name. |
|
70 |
# |
|
71 |
# Remaining parameters are named arguments. These are all passed on to |
|
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
72 |
# SetupNativeCompilation, except for |
49244 | 73 |
# EXTRA_RC_FLAGS -- additional RC_FLAGS to append. |
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
74 |
# EXTRA_HEADER_DIRS -- additional directories to look for headers in |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
75 |
# EXTRA_SRC -- additional directories to look for source in |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
76 |
# EXCLUDE_SRC_PATTERNS -- exclude source dirs matching these patterns from |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
77 |
# appearing in SRC. |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
78 |
# HEADERS_FROM_SRC -- if false, does not add source dirs automatically as |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
79 |
# header include dirs. (Defaults to true.) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
80 |
# SRC -- this is passed on, but preprocessed to accept source dir designations |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
81 |
# such as "java.base:headers". |
49244 | 82 |
SetupJdkLibrary = $(NamedParamsMacroTemplate) |
83 |
define SetupJdkLibraryBody |
|
84 |
ifeq ($$($1_OUTPUT_DIR), ) |
|
85 |
$1_OUTPUT_DIR := $$(call FindLibDirForModule, $$(MODULE)) |
|
86 |
endif |
|
87 |
||
88 |
ifeq ($$($1_OBJECT_DIR), ) |
|
89 |
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/lib$$($1_NAME) |
|
90 |
endif |
|
91 |
||
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
92 |
ifeq ($$($1_SRC), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
93 |
$1_SRC := $$(call FindSrcDirsForLib, $$(MODULE), $$($1_NAME)) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
94 |
else |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
95 |
$1_SRC := $$(foreach dir, $$($1_SRC), $$(call ProcessDir, $$(dir))) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
96 |
endif |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
97 |
ifneq ($$($1_EXTRA_SRC), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
98 |
$1_SRC += $$(foreach dir, $$($1_EXTRA_SRC), $$(call ProcessDir, $$(dir))) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
99 |
endif |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
100 |
|
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
101 |
ifneq ($$($1_EXCLUDE_SRC_PATTERNS), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
102 |
$1_EXCLUDE_SRC := $$(call containing, $$($1_EXCLUDE_SRC_PATTERNS), $$($1_SRC)) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
103 |
$1_SRC := $$(filter-out $$($1_EXCLUDE_SRC), $$($1_SRC)) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
104 |
endif |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
105 |
|
49244 | 106 |
ifeq ($$($1_VERSIONINFO_RESOURCE), ) |
107 |
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE) |
|
108 |
else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE) |
|
109 |
$1_VERSIONINFO_RESOURCE := |
|
110 |
endif |
|
111 |
||
112 |
ifeq ($$($1_RC_FLAGS), ) |
|
113 |
$1_RC_FLAGS := $(RC_FLAGS) \ |
|
114 |
-D "JDK_FNAME=$$($1_NAME).dll" \ |
|
115 |
-D "JDK_INTERNAL_NAME=$$($1_NAME)" \ |
|
116 |
-D "JDK_FTYPE=0x2L" |
|
117 |
else ifeq ($$($1_RC_FLAGS), DISABLE) |
|
118 |
$1_RC_FLAGS := |
|
119 |
endif |
|
120 |
||
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
121 |
ifneq ($$($1_HEADERS_FROM_SRC), false) |
50847
b970fae53807
8205616: Build fails with system headers after 8204572
glaubitz
parents:
50471
diff
changeset
|
122 |
$1_SRC_HEADER_FLAGS := $$(addprefix -I, $$(wildcard $$($1_SRC))) |
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
123 |
endif |
50847
b970fae53807
8205616: Build fails with system headers after 8204572
glaubitz
parents:
50471
diff
changeset
|
124 |
# Always add the java header dir |
b970fae53807
8205616: Build fails with system headers after 8204572
glaubitz
parents:
50471
diff
changeset
|
125 |
$1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE))) |
b970fae53807
8205616: Build fails with system headers after 8204572
glaubitz
parents:
50471
diff
changeset
|
126 |
|
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
127 |
ifneq ($$($1_EXTRA_HEADER_DIRS), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
128 |
$1_PROCESSED_EXTRA_HEADER_DIRS := $$(foreach dir, $$($1_EXTRA_HEADER_DIRS), \ |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
129 |
$$(call ProcessDir, $$(dir))) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
130 |
$1_EXTRA_HEADER_FLAGS := $$(addprefix -I, $$($1_PROCESSED_EXTRA_HEADER_DIRS)) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
131 |
endif |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
132 |
|
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
133 |
ifneq ($$($1_CFLAGS), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
134 |
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
135 |
endif |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
136 |
ifneq ($$($1_CXXFLAGS), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
137 |
$1_CXXFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
138 |
endif |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
139 |
ifeq ($$($1_CFLAGS)$$($1_CXXFLAGS), ) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
140 |
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS) |
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
141 |
endif |
49244 | 142 |
$1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS) |
143 |
||
144 |
# Since we reuse the rule name ($1), all our arguments will pass through. |
|
145 |
# We lose in transparency, but gain in brevity in this call... |
|
146 |
$$(eval $$(call SetupNativeCompilation, $1, )) |
|
147 |
endef |
|
148 |
||
149 |
# Setup make rules for creating a native executable with suitable defaults for |
|
150 |
# the OpenJDK project. |
|
151 |
# |
|
152 |
# Parameter 1 is the name of the rule. This name is used as variable prefix, |
|
153 |
# and the targets generated are listed in a variable by that name. |
|
154 |
# |
|
155 |
# Remaining parameters are named arguments. These are all passed on to |
|
50471
f0aeede1b855
8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents:
49244
diff
changeset
|
156 |
# SetupNativeCompilation, except for |
49244 | 157 |
# EXTRA_RC_FLAGS -- additional RC_FLAGS to append. |
158 |
SetupJdkExecutable = $(NamedParamsMacroTemplate) |
|
159 |
define SetupJdkExecutableBody |
|
160 |
$1_TYPE := EXECUTABLE |
|
161 |
||
162 |
ifeq ($$($1_OUTPUT_DIR), ) |
|
163 |
$1_OUTPUT_DIR := $$(call FindExecutableDirForModule, $$(MODULE)) |
|
164 |
endif |
|
165 |
||
166 |
ifeq ($$($1_OBJECT_DIR), ) |
|
167 |
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$$($1_NAME) |
|
168 |
endif |
|
169 |
||
170 |
ifeq ($$($1_VERSIONINFO_RESOURCE), ) |
|
171 |
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE) |
|
172 |
else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE) |
|
173 |
$1_VERSIONINFO_RESOURCE := |
|
174 |
endif |
|
175 |
||
176 |
ifeq ($$($1_RC_FLAGS), ) |
|
177 |
$1_RC_FLAGS := $(RC_FLAGS) \ |
|
178 |
-D "JDK_FNAME=$$($1_NAME).exe" \ |
|
179 |
-D "JDK_INTERNAL_NAME=$$($1_NAME)" \ |
|
180 |
-D "JDK_FTYPE=0x01L" |
|
181 |
else ifeq ($$($1_RC_FLAGS), DISABLE) |
|
182 |
$1_RC_FLAGS := |
|
183 |
endif |
|
184 |
||
185 |
$1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS) |
|
186 |
||
187 |
# Since we reuse the rule name ($1), all our arguments will pass through. |
|
188 |
# We lose in transparency, but gain in brevity in this call... |
|
189 |
$$(eval $$(call SetupNativeCompilation, $1)) |
|
190 |
endef |
|
191 |
||
192 |
endif # _JDK_NATIVE_COMPILATION_GMK |