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