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