1# 2# Copyright (c) 2014, 2020, 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 26ifndef _MODULES_GMK 27_MODULES_GMK := 1 28 29################################################################################ 30# 31# BOOT_MODULES are modules defined by the boot loader 32# PLATFORM_MODULES are modules defined by the platform loader 33# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader 34# 35# All other modules not declared below are defined by the application loader 36# and are not included in JRE. 37 38BOOT_MODULES := 39PLATFORM_MODULES := 40JRE_TOOL_MODULES := 41UPGRADEABLE_MODULES := 42AGGREGATOR_MODULES := 43DOCS_MODULES := 44 45# Hook to include the corresponding custom file, if present. 46$(eval $(call IncludeCustomExtension, common/Modules.gmk)) 47 48BOOT_MODULES += \ 49 java.base \ 50 java.datatransfer \ 51 java.desktop \ 52 java.instrument \ 53 java.logging \ 54 java.management \ 55 java.management.rmi \ 56 java.naming \ 57 java.prefs \ 58 java.rmi \ 59 java.security.sasl \ 60 java.xml \ 61 jdk.internal.vm.ci \ 62 jdk.jfr \ 63 jdk.management \ 64 jdk.management.jfr \ 65 jdk.management.agent \ 66 jdk.naming.ldap \ 67 jdk.net \ 68 jdk.sctp \ 69 jdk.unsupported \ 70 # 71 72# to be deprivileged 73BOOT_MODULES += \ 74 jdk.naming.rmi \ 75 # 76 77# Modules that directly or indirectly requiring upgradeable modules 78# should carefully be considered if it should be upgradeable or not. 79UPGRADEABLE_MODULES += \ 80 java.compiler \ 81 jdk.aot \ 82 jdk.internal.vm.compiler \ 83 jdk.internal.vm.compiler.management \ 84 # 85 86 87AGGREGATOR_MODULES += \ 88 java.se \ 89 # 90 91PLATFORM_MODULES += \ 92 $(UPGRADEABLE_MODULES) \ 93 $(AGGREGATOR_MODULES) 94 # 95 96PLATFORM_MODULES += \ 97 java.net.http \ 98 java.scripting \ 99 java.security.jgss \ 100 java.smartcardio \ 101 java.sql \ 102 java.sql.rowset \ 103 java.transaction.xa \ 104 java.xml.crypto \ 105 jdk.accessibility \ 106 jdk.charsets \ 107 jdk.crypto.cryptoki \ 108 jdk.crypto.ec \ 109 jdk.dynalink \ 110 jdk.httpserver \ 111 jdk.jsobject \ 112 jdk.localedata \ 113 jdk.naming.dns \ 114 jdk.scripting.nashorn \ 115 jdk.security.auth \ 116 jdk.security.jgss \ 117 jdk.xml.dom \ 118 jdk.zipfs \ 119 # 120 121ifeq ($(OPENJDK_TARGET_OS), windows) 122 PLATFORM_MODULES += jdk.crypto.mscapi 123endif 124 125ifeq ($(OPENJDK_TARGET_OS), solaris) 126 PLATFORM_MODULES += jdk.crypto.ucrypto 127endif 128 129JRE_TOOL_MODULES += \ 130 jdk.jdwp.agent \ 131 jdk.pack \ 132 jdk.scripting.nashorn.shell \ 133 # 134 135################################################################################ 136 137# DOCS_MODULES defines the root modules for javadoc generation. 138# All of their `require transitive` modules directly and indirectly will be included. 139DOCS_MODULES += \ 140 java.se \ 141 java.smartcardio \ 142 jdk.accessibility \ 143 jdk.attach \ 144 jdk.charsets \ 145 jdk.compiler \ 146 jdk.crypto.cryptoki \ 147 jdk.crypto.ec \ 148 jdk.dynalink \ 149 jdk.editpad \ 150 jdk.hotspot.agent \ 151 jdk.httpserver \ 152 jdk.jartool \ 153 jdk.javadoc \ 154 jdk.jcmd \ 155 jdk.jconsole \ 156 jdk.jdeps \ 157 jdk.jdi \ 158 jdk.jdwp.agent \ 159 jdk.jfr \ 160 jdk.jlink \ 161 jdk.jsobject \ 162 jdk.jshell \ 163 jdk.jstatd \ 164 jdk.localedata \ 165 jdk.management \ 166 jdk.management.agent \ 167 jdk.management.jfr \ 168 jdk.naming.dns \ 169 jdk.naming.ldap \ 170 jdk.naming.rmi \ 171 jdk.net \ 172 jdk.pack \ 173 jdk.rmic \ 174 jdk.scripting.nashorn \ 175 jdk.sctp \ 176 jdk.security.auth \ 177 jdk.security.jgss \ 178 jdk.xml.dom \ 179 jdk.zipfs \ 180 # 181 182# These modules are included in the interim image which is used to run profiling 183# before building the real images. 184INTERIM_IMAGE_MODULES := java.base java.logging 185 186LANGTOOLS_MODULES := \ 187 java.compiler \ 188 jdk.compiler \ 189 jdk.javadoc \ 190 jdk.jdeps \ 191 jdk.jshell \ 192 # 193 194HOTSPOT_MODULES := \ 195 jdk.aot \ 196 jdk.hotspot.agent \ 197 jdk.internal.vm.ci \ 198 jdk.internal.vm.compiler \ 199 jdk.internal.vm.compiler.management \ 200 # 201 202################################################################################ 203# Some platforms don't have the serviceability agent 204 205ifeq ($(INCLUDE_SA), false) 206 MODULES_FILTER += jdk.hotspot.agent 207endif 208 209################################################################################ 210# Filter out jvmci specific modules if jvmci is disabled 211 212ifeq ($(INCLUDE_JVMCI), false) 213 MODULES_FILTER += jdk.internal.vm.ci 214endif 215 216################################################################################ 217# Filter out Graal specific modules if Graal is disabled 218 219ifeq ($(INCLUDE_GRAAL), false) 220 MODULES_FILTER += jdk.internal.vm.compiler 221 MODULES_FILTER += jdk.internal.vm.compiler.management 222endif 223 224################################################################################ 225# Filter out aot specific modules if aot is disabled 226 227ifeq ($(ENABLE_AOT), false) 228 MODULES_FILTER += jdk.aot 229endif 230 231################################################################################ 232# Module list macros 233 234# Use append so that the custom extension may add to these variables 235 236GENERATED_SRC_DIRS += \ 237 $(SUPPORT_OUTPUTDIR)/gensrc \ 238 # 239 240TOP_SRC_DIRS += \ 241 $(TOPDIR)/src \ 242 # 243 244SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 245ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 246 SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes 247endif 248SRC_SUBDIRS += share/classes 249 250SPEC_SUBDIRS += share/specs 251 252# Find all module-info.java files for the current build target platform and 253# configuration. 254# Param 1 - Module to find for, set to * for finding all 255FindAllModuleInfos = \ 256 $(sort $(wildcard \ 257 $(foreach sub, $(SRC_SUBDIRS), \ 258 $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 259 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))) 260 261# Find module-info.java files in the specific source dir 262# Param 1 - Src dir to find module-info.java files in 263FindModuleInfosForSrcDir = \ 264 $(wildcard \ 265 $(foreach sub, $(SRC_SUBDIRS), \ 266 $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \ 267 ) \ 268 $(patsubst %,%/*/module-info.java, $(strip $1)) \ 269 ) 270 271# Extract the module names from the paths of module-info.java files. The 272# position of the module directory differs depending on if this is an imported 273# src dir or not. 274GetModuleNameFromModuleInfo = \ 275 $(strip $(foreach mi, $1, \ 276 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 277 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 278 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 279 280# Find all modules by looking for module-info.java files and looking at parent 281# directories. 282FindAllModules = \ 283 $(sort $(filter-out $(MODULES_FILTER), \ 284 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 285 286# Find all modules in a specific src dir 287# Param 1 - Src dir to find modules in 288FindModulesForSrcDir = \ 289 $(sort $(filter-out $(MODULES_FILTER), \ 290 $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \ 291 )) 292 293FindImportedModules = \ 294 $(filter-out $(MODULES_FILTER), \ 295 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) 296 297# Find all source dirs for a particular module 298# $1 - Module to find source dirs for 299FindModuleSrcDirs = \ 300 $(strip $(wildcard \ 301 $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 302 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 303 304# Find all specs dirs for a particular module 305# $1 - Module to find specs dirs for 306FindModuleSpecsDirs = \ 307 $(strip $(wildcard \ 308 $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 309 310# Construct the complete module source path 311GetModuleSrcPath = \ 312 $(call PathList, \ 313 $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 314 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) 315 316################################################################################ 317# Extract module dependencies from module-info.java files, both normal 318# dependencies ("requires"), and indirect exports ("requires transitive"). 319 320MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 321 322MODULE_INFOS := $(call FindAllModuleInfos, *) 323 324$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 325 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 326 $(MKDIR) -p $(@D) 327 $(RM) $@ 328 $(foreach m, $(MODULE_INFOS), \ 329 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 330 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 331 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 332 /^ *requires/ { sub(/;/, ""); \ 333 sub(/requires /, " "); \ 334 sub(/ static /, " "); \ 335 sub(/ transitive /, " "); \ 336 sub(/\/\/.*/, ""); \ 337 sub(/\/\*.*\*\//, ""); \ 338 gsub(/^ +\*.*/, ""); \ 339 gsub(/ /, ""); \ 340 printf(" %s", $$0) } \ 341 END { printf("\n") }' $m && \ 342 $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 343 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 344 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 345 /^ *requires *transitive/ { \ 346 sub(/;/, ""); \ 347 sub(/requires/, ""); \ 348 sub(/transitive/, ""); \ 349 sub(/\/\/.*/, ""); \ 350 sub(/\/\*.*\*\//, ""); \ 351 gsub(/^ +\*.*/, ""); \ 352 gsub(/ /, ""); \ 353 printf(" %s", $$0) } \ 354 END { printf("\n") }' $m \ 355 ) >> $@ $(NEWLINE)) 356 357-include $(MODULE_DEPS_MAKEFILE) 358 359# Find dependencies ("requires") for a given module. 360# Param 1: Module to find dependencies for. 361FindDepsForModule = \ 362 $(DEPS_$(strip $1)) 363 364# Find dependencies ("requires") transitively in 3 levels for a given module. 365# Param 1: Module to find dependencies for. 366FindTransitiveDepsForModule = \ 367 $(sort $(call FindDepsForModule, $1) \ 368 $(foreach m, $(call FindDepsForModule, $1), \ 369 $(call FindDepsForModule, $m) \ 370 $(foreach n, $(call FindDepsForModule, $m), \ 371 $(call FindDepsForModule, $n)))) 372 373# Find dependencies ("requires") transitively in 3 levels for a set of modules. 374# Param 1: List of modules to find dependencies for. 375FindTransitiveDepsForModules = \ 376 $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m))) 377 378# Find indirect exported modules ("requires transitive") for a given module . 379# Param 1: Module to find indirect exported modules for. 380FindIndirectExportsForModule = \ 381 $(TRANSITIVE_MODULES_$(strip $1)) 382 383# Finds indirect exported modules transitively in 3 levels for a given module. 384# Param 1: Module to find indirect exported modules for. 385FindTransitiveIndirectDepsForModule = \ 386 $(sort $(call FindIndirectExportsForModule, $1) \ 387 $(foreach m, $(call FindIndirectExportsForModule, $1), \ 388 $(call FindIndirectExportsForModule, $m) \ 389 $(foreach n, $(call FindIndirectExportsForModule, $m), \ 390 $(call FindIndirectExportsForModule, $n)))) 391 392# Finds indirect exported modules transitively in 3 levels for a set of modules. 393# Param 1: List of modules to find indirect exported modules for. 394FindTransitiveIndirectDepsForModules = \ 395 $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m))) 396 397# Upgradeable modules are those that are either defined as upgradeable or that 398# require an upradeable module. 399FindAllUpgradeableModules = \ 400 $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES))) 401 402 403################################################################################ 404 405LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal 406ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 407 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal 408endif 409LEGAL_SUBDIRS += share/legal 410 411# Find all legal src dirs for a particular module 412# $1 - Module to find legal dirs for 413FindModuleLegalSrcDirs = \ 414 $(strip $(wildcard \ 415 $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \ 416 $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \ 417 )) 418 419################################################################################ 420 421# Param 1 - Name of module 422define ReadSingleImportMetaData 423 ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), ) 424 classloader := 425 include_in_jre := 426 include_in_jdk := 427 include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties 428 ifeq ($$(include_in_jre), true) 429 JRE_MODULES += $1 430 endif 431 ifeq ($$(include_in_jdk), true) 432 JDK_MODULES += $1 433 endif 434 ifeq ($$(classloader), boot) 435 BOOT_MODULES += $1 436 else ifeq ($$(classloader), ext) 437 PLATFORM_MODULES += $1 438 endif 439 ifneq ($$(include_in_docs), false) 440 # defaults to true if unspecified 441 DOCS_MODULES += $1 442 endif 443 else 444 # Default to include in all 445 JRE_MODULES += $1 446 JDK_MODULES += $1 447 endif 448endef 449 450# Reading the imported modules metadata has a cost, so to make it available, 451# a makefile needs to eval-call this macro first. After calling this, the 452# following variables are populated with data from the imported modules: 453# * JRE_MODULES 454# * JDK_MODULES 455# * BOOT_MODULES 456# * PLATFORM_MODULES 457# * JRE_TOOL_MODULES 458define ReadImportMetaData 459 IMPORTED_MODULES := $$(call FindImportedModules) 460 $$(foreach m, $$(IMPORTED_MODULES), \ 461 $$(eval $$(call ReadSingleImportMetaData, $$m))) 462endef 463 464################################################################################ 465 466endif # _MODULES_GMK 467