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