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