2
# Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
29
################################################################################
30
# Setup module sets for classloaders
32
include $(TOPDIR)/make/conf/module-loader-map.conf
34
# Append platform-specific and upgradeable modules
35
PLATFORM_MODULES += $(PLATFORM_MODULES_$(OPENJDK_TARGET_OS)) \
36
$(UPGRADEABLE_PLATFORM_MODULES)
38
################################################################################
39
# Setup module sets for docs
41
include $(TOPDIR)/make/conf/docs-modules.conf
43
################################################################################
44
# Setup module sets needed by the build system
46
include $(TOPDIR)/make/conf/build-module-sets.conf
48
################################################################################
49
# Hook to include the corresponding custom file, if present.
50
# Allowing MODULE list extensions setup above.
51
$(eval $(call IncludeCustomExtension, common/Modules.gmk))
53
################################################################################
54
# Depending on the configuration, we might need to filter out some modules that
55
# normally should have been included
57
# Some platforms don't have the serviceability agent
58
ifeq ($(INCLUDE_SA), false)
59
MODULES_FILTER += jdk.hotspot.agent
62
# Filter out jvmci specific modules if jvmci is disabled
63
ifeq ($(INCLUDE_JVMCI), false)
64
MODULES_FILTER += jdk.internal.vm.ci
65
MODULES_FILTER += jdk.graal.compiler
66
MODULES_FILTER += jdk.graal.compiler.management
69
# jpackage is only on windows, macosx, and linux
70
ifeq ($(call isTargetOs, windows macosx linux), false)
71
MODULES_FILTER += jdk.jpackage
74
################################################################################
77
# Use append so that the custom extension may add to these variables
79
GENERATED_SRC_DIRS += \
80
$(SUPPORT_OUTPUTDIR)/gensrc \
87
SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
88
ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
89
SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
91
SRC_SUBDIRS += share/classes
93
SPEC_SUBDIRS += share/specs
95
MAN_SUBDIRS += share/man
97
# Find all module-info.java files for the current build target platform and
99
# Param 1 - Module to find for, set to * for finding all
100
FindAllModuleInfos = \
102
$(foreach sub, $(SRC_SUBDIRS), \
103
$(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
104
$(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))))
106
# Find module-info.java files in the specific source dir
107
# Param 1 - Src dir to find module-info.java files in
108
FindModuleInfosForSrcDir = \
110
$(foreach sub, $(SRC_SUBDIRS), \
111
$(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
113
$(patsubst %,%/*/module-info.java, $(strip $1)) \
116
# Extract the module names from the paths of module-info.java files. The
117
# position of the module directory differs depending on if this is an imported
119
GetModuleNameFromModuleInfo = \
120
$(strip $(foreach mi, $1, \
121
$(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
122
$(notdir $(patsubst %/,%, $(dir $(mi)))), \
123
$(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
125
# Find all modules by looking for module-info.java files and looking at parent
128
$(sort $(filter-out $(MODULES_FILTER), \
129
$(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
131
# Find all modules in a specific src dir
132
# Param 1 - Src dir to find modules in
133
FindModulesForSrcDir = \
134
$(sort $(filter-out $(MODULES_FILTER), \
135
$(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
138
FindImportedModules = \
139
$(filter-out $(MODULES_FILTER), \
140
$(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
142
# Find all source dirs for a particular module
143
# $1 - Module to find source dirs for
146
$(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
147
$(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
149
# Find all specs dirs for a particular module
150
# $1 - Module to find specs dirs for
151
FindModuleSpecsDirs = \
153
$(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
155
# Find all man dirs for a particular module
156
# $1 - Module to find man dirs for
159
$(foreach sub, $(MAN_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
161
# Construct the complete module source path
164
$(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
165
$(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
167
################################################################################
168
# Extract module dependencies from module-info.java files, both normal
169
# dependencies ("requires"), and indirect exports ("requires transitive").
171
MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
173
MODULE_INFOS := $(call FindAllModuleInfos, *)
175
$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
176
$(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
177
$(call MakeTargetDir)
179
$(foreach m, $(MODULE_INFOS), \
180
( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
181
$(AWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
182
BEGIN { if (MODULE != "java.base") printf(" java.base"); } \
183
/^ *requires/ { sub(/;/, ""); \
184
sub(/requires /, " "); \
185
sub(/ static /, " "); \
186
sub(/ transitive /, " "); \
188
sub(/\/\*.*\*\//, ""); \
189
gsub(/^ +\*.*/, ""); \
192
printf(" %s", $$0) } \
193
END { printf("\n") }' $m && \
194
$(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \
195
$(AWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
196
BEGIN { if (MODULE != "java.base") printf(" java.base"); } \
197
/^ *requires *transitive/ { \
199
sub(/requires/, ""); \
200
sub(/transitive/, ""); \
202
sub(/\/\*.*\*\//, ""); \
203
gsub(/^ +\*.*/, ""); \
206
printf(" %s", $$0) } \
207
END { printf("\n") }' $m \
210
-include $(MODULE_DEPS_MAKEFILE)
212
# Find dependencies ("requires") for a given module.
213
# Param 1: Module to find dependencies for.
217
# Find dependencies ("requires") transitively in 3 levels for a given module.
218
# Param 1: Module to find dependencies for.
219
FindTransitiveDepsForModule = \
220
$(sort $(call FindDepsForModule, $1) \
221
$(foreach m, $(call FindDepsForModule, $1), \
222
$(call FindDepsForModule, $m) \
223
$(foreach n, $(call FindDepsForModule, $m), \
224
$(call FindDepsForModule, $n))))
226
# Find dependencies ("requires") transitively in 3 levels for a set of modules.
227
# Param 1: List of modules to find dependencies for.
228
FindTransitiveDepsForModules = \
229
$(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
231
# Find indirect exported modules ("requires transitive") for a given module .
232
# Param 1: Module to find indirect exported modules for.
233
FindIndirectExportsForModule = \
234
$(TRANSITIVE_MODULES_$(strip $1))
236
# Finds indirect exported modules transitively in 3 levels for a given module.
237
# Param 1: Module to find indirect exported modules for.
238
FindTransitiveIndirectDepsForModule = \
239
$(sort $(call FindIndirectExportsForModule, $1) \
240
$(foreach m, $(call FindIndirectExportsForModule, $1), \
241
$(call FindIndirectExportsForModule, $m) \
242
$(foreach n, $(call FindIndirectExportsForModule, $m), \
243
$(call FindIndirectExportsForModule, $n))))
245
# Finds indirect exported modules transitively in 3 levels for a set of modules.
246
# Param 1: List of modules to find indirect exported modules for.
247
FindTransitiveIndirectDepsForModules = \
248
$(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m)))
250
# Upgradeable modules are those that are either defined as upgradeable or that
251
# require an upradeable module.
252
FindAllUpgradeableModules = \
253
$(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_PLATFORM_MODULES)))
255
################################################################################
257
LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
258
ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
259
LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
261
LEGAL_SUBDIRS += share/legal
263
# Find all legal src dirs for a particular module
264
# $1 - Module to find legal dirs for
265
FindModuleLegalSrcDirs = \
267
$(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
268
$(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \
271
################################################################################
273
# Param 1 - Name of module
274
define ReadSingleImportMetaData
275
ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
279
include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
280
ifeq ($$(include_in_jre), true)
283
ifeq ($$(include_in_jdk), true)
286
ifeq ($$(classloader), boot)
288
else ifeq ($$(classloader), ext)
289
PLATFORM_MODULES += $1
291
ifneq ($$(include_in_docs), false)
292
# defaults to true if unspecified
296
# Default to include in all
302
# Reading the imported modules metadata has a cost, so to make it available,
303
# a makefile needs to eval-call this macro first. After calling this, the
304
# following variables are populated with data from the imported modules:
309
define ReadImportMetaData
310
IMPORTED_MODULES := $$(call FindImportedModules)
311
$$(foreach m, $$(IMPORTED_MODULES), \
312
$$(eval $$(call ReadSingleImportMetaData, $$m)))
315
################################################################################