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.nio.mapmode \ 175 jdk.rmic \ 176 jdk.scripting.nashorn \ 177 jdk.sctp \ 178 jdk.security.auth \ 179 jdk.security.jgss \ 180 jdk.xml.dom \ 181 jdk.zipfs \ 182 # 183 184 # These modules are included in the interim image which is used to run profiling 185 # before building the real images. 186 INTERIM_IMAGE_MODULES := java.base java.logging 187 188 LANGTOOLS_MODULES := \ 189 java.compiler \ 190 jdk.compiler \ 191 jdk.javadoc \ 192 jdk.jdeps \ 193 jdk.jshell \ 194 # 195 196 HOTSPOT_MODULES := \ 197 jdk.aot \ 198 jdk.hotspot.agent \ 199 jdk.internal.vm.ci \ 200 jdk.internal.vm.compiler \ 201 jdk.internal.vm.compiler.management \ 202 # 203 204 # The native dynamic libraries in these modules will also get built into static 205 # libraries for consumption by downstream projects that need to statically link 206 # the JDK libraries. Those static libraries are not part of the main JDK 207 # distribution. 208 STATIC_LIBS_MODULES := \ 209 java.base \ 210 jdk.crypto.ec \ 211 jdk.security.auth \ 212 java.prefs \ 213 java.security.jgss \ 214 java.smartcardio \ 215 jdk.crypto.cryptoki \ 216 jdk.net \ 217 # 218 219 ################################################################################ 220 # Some platforms don't have the serviceability agent 221 222 ifeq ($(INCLUDE_SA), false) 223 MODULES_FILTER += jdk.hotspot.agent 224 endif 225 226 ################################################################################ 227 # Filter out jvmci specific modules if jvmci is disabled 228 229 ifeq ($(INCLUDE_JVMCI), false) 230 MODULES_FILTER += jdk.internal.vm.ci 231 endif 232 233 ################################################################################ 234 # Filter out Graal specific modules if Graal is disabled 235 236 ifeq ($(INCLUDE_GRAAL), false) 237 MODULES_FILTER += jdk.internal.vm.compiler 238 MODULES_FILTER += jdk.internal.vm.compiler.management 239 endif 240 241 ################################################################################ 242 # Filter out aot specific modules if aot is disabled 243 244 ifeq ($(ENABLE_AOT), false) 245 MODULES_FILTER += jdk.aot 246 endif 247 248 ################################################################################ 249 # jpackage is only on windows, macosx, and linux 250 251 ifeq ($(call isTargetOs, windows macosx linux), false) 252 MODULES_FILTER += jdk.incubator.jpackage 253 endif 254 255 ################################################################################ 256 # Module list macros 257 258 # Use append so that the custom extension may add to these variables 259 260 GENERATED_SRC_DIRS += \ 261 $(SUPPORT_OUTPUTDIR)/gensrc \ 262 # 263 264 TOP_SRC_DIRS += \ 265 $(TOPDIR)/src \ 266 # 267 268 SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 269 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 270 SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes 271 endif 272 SRC_SUBDIRS += share/classes 273 274 SPEC_SUBDIRS += share/specs 275 276 MAN_SUBDIRS += share/man 277 278 # Find all module-info.java files for the current build target platform and 279 # configuration. 280 # Param 1 - Module to find for, set to * for finding all 281 FindAllModuleInfos = \ 282 $(sort $(wildcard \ 283 $(foreach sub, $(SRC_SUBDIRS), \ 284 $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 285 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))) 286 287 # Find module-info.java files in the specific source dir 288 # Param 1 - Src dir to find module-info.java files in 289 FindModuleInfosForSrcDir = \ 290 $(wildcard \ 291 $(foreach sub, $(SRC_SUBDIRS), \ 292 $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \ 293 ) \ 294 $(patsubst %,%/*/module-info.java, $(strip $1)) \ 295 ) 296 297 # Extract the module names from the paths of module-info.java files. The 298 # position of the module directory differs depending on if this is an imported 299 # src dir or not. 300 GetModuleNameFromModuleInfo = \ 301 $(strip $(foreach mi, $1, \ 302 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 303 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 304 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 305 306 # Find all modules by looking for module-info.java files and looking at parent 307 # directories. 308 FindAllModules = \ 309 $(sort $(filter-out $(MODULES_FILTER), \ 310 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 311 312 # Find all modules in a specific src dir 313 # Param 1 - Src dir to find modules in 314 FindModulesForSrcDir = \ 315 $(sort $(filter-out $(MODULES_FILTER), \ 316 $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \ 317 )) 318 319 FindImportedModules = \ 320 $(filter-out $(MODULES_FILTER), \ 321 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) 322 323 # Find all source dirs for a particular module 324 # $1 - Module to find source dirs for 325 FindModuleSrcDirs = \ 326 $(strip $(wildcard \ 327 $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 328 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 329 330 # Find all specs dirs for a particular module 331 # $1 - Module to find specs dirs for 332 FindModuleSpecsDirs = \ 333 $(strip $(wildcard \ 334 $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 335 336 # Find all man dirs for a particular module 337 # $1 - Module to find man dirs for 338 FindModuleManDirs = \ 339 $(strip $(wildcard \ 340 $(foreach sub, $(MAN_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 341 342 # Construct the complete module source path 343 GetModuleSrcPath = \ 344 $(call PathList, \ 345 $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 346 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) 347 348 ################################################################################ 349 # Extract module dependencies from module-info.java files, both normal 350 # dependencies ("requires"), and indirect exports ("requires transitive"). 351 352 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 353 354 MODULE_INFOS := $(call FindAllModuleInfos, *) 355 356 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 357 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 358 $(call MakeTargetDir) 359 $(RM) $@ 360 $(foreach m, $(MODULE_INFOS), \ 361 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 362 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 363 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 364 /^ *requires/ { sub(/;/, ""); \ 365 sub(/requires /, " "); \ 366 sub(/ static /, " "); \ 367 sub(/ transitive /, " "); \ 368 sub(/\/\/.*/, ""); \ 369 sub(/\/\*.*\*\//, ""); \ 370 gsub(/^ +\*.*/, ""); \ 371 gsub(/ /, ""); \ 372 printf(" %s", $$0) } \ 373 END { printf("\n") }' $m && \ 374 $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 375 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 376 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 377 /^ *requires *transitive/ { \ 378 sub(/;/, ""); \ 379 sub(/requires/, ""); \ 380 sub(/transitive/, ""); \ 381 sub(/\/\/.*/, ""); \ 382 sub(/\/\*.*\*\//, ""); \ 383 gsub(/^ +\*.*/, ""); \ 384 gsub(/ /, ""); \ 385 printf(" %s", $$0) } \ 386 END { printf("\n") }' $m \ 387 ) >> $@ $(NEWLINE)) 388 389 -include $(MODULE_DEPS_MAKEFILE) 390 391 # Find dependencies ("requires") for a given module. 392 # Param 1: Module to find dependencies for. 393 FindDepsForModule = \ 394 $(DEPS_$(strip $1)) 395 396 # Find dependencies ("requires") transitively in 3 levels for a given module. 397 # Param 1: Module to find dependencies for. 398 FindTransitiveDepsForModule = \ 399 $(sort $(call FindDepsForModule, $1) \ 400 $(foreach m, $(call FindDepsForModule, $1), \ 401 $(call FindDepsForModule, $m) \ 402 $(foreach n, $(call FindDepsForModule, $m), \ 403 $(call FindDepsForModule, $n)))) 404 405 # Find dependencies ("requires") transitively in 3 levels for a set of modules. 406 # Param 1: List of modules to find dependencies for. 407 FindTransitiveDepsForModules = \ 408 $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m))) 409 410 # Find indirect exported modules ("requires transitive") for a given module . 411 # Param 1: Module to find indirect exported modules for. 412 FindIndirectExportsForModule = \ 413 $(TRANSITIVE_MODULES_$(strip $1)) 414 415 # Finds indirect exported modules transitively in 3 levels for a given module. 416 # Param 1: Module to find indirect exported modules for. 417 FindTransitiveIndirectDepsForModule = \ 418 $(sort $(call FindIndirectExportsForModule, $1) \ 419 $(foreach m, $(call FindIndirectExportsForModule, $1), \ 420 $(call FindIndirectExportsForModule, $m) \ 421 $(foreach n, $(call FindIndirectExportsForModule, $m), \ 422 $(call FindIndirectExportsForModule, $n)))) 423 424 # Finds indirect exported modules transitively in 3 levels for a set of modules. 425 # Param 1: List of modules to find indirect exported modules for. 426 FindTransitiveIndirectDepsForModules = \ 427 $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m))) 428 429 # Upgradeable modules are those that are either defined as upgradeable or that 430 # require an upradeable module. 431 FindAllUpgradeableModules = \ 432 $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES))) 433 434 435 ################################################################################ 436 437 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal 438 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 439 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal 440 endif 441 LEGAL_SUBDIRS += share/legal 442 443 # Find all legal src dirs for a particular module 444 # $1 - Module to find legal dirs for 445 FindModuleLegalSrcDirs = \ 446 $(strip $(wildcard \ 447 $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \ 448 $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \ 449 )) 450 451 ################################################################################ 452 453 # Param 1 - Name of module 454 define ReadSingleImportMetaData 455 ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), ) 456 classloader := 457 include_in_jre := 458 include_in_jdk := 459 include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties 460 ifeq ($$(include_in_jre), true) 461 JRE_MODULES += $1 462 endif 463 ifeq ($$(include_in_jdk), true) 464 JDK_MODULES += $1 465 endif 466 ifeq ($$(classloader), boot) 467 BOOT_MODULES += $1 468 else ifeq ($$(classloader), ext) 469 PLATFORM_MODULES += $1 470 endif 471 ifneq ($$(include_in_docs), false) 472 # defaults to true if unspecified 473 DOCS_MODULES += $1 474 endif 475 else 476 # Default to include in all 477 JRE_MODULES += $1 478 JDK_MODULES += $1 479 endif 480 endef 481 482 # Reading the imported modules metadata has a cost, so to make it available, 483 # a makefile needs to eval-call this macro first. After calling this, the 484 # following variables are populated with data from the imported modules: 485 # * JRE_MODULES 486 # * JDK_MODULES 487 # * BOOT_MODULES 488 # * PLATFORM_MODULES 489 # * JRE_TOOL_MODULES 490 define ReadImportMetaData 491 IMPORTED_MODULES := $$(call FindImportedModules) 492 $$(foreach m, $$(IMPORTED_MODULES), \ 493 $$(eval $$(call ReadSingleImportMetaData, $$m))) 494 endef 495 496 ################################################################################ 497 498 endif # _MODULES_GMK