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.incubator.jpackage \ 132 jdk.pack \ 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.localedata \ 167 jdk.management \ 168 jdk.management.agent \ 169 jdk.management.jfr \ 170 jdk.naming.dns \ 171 jdk.naming.rmi \ 172 jdk.net \ 173 jdk.pack \ 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 # Find all module-info.java files for the current build target platform and 278 # configuration. 279 # Param 1 - Module to find for, set to * for finding all 280 FindAllModuleInfos = \ 281 $(sort $(wildcard \ 282 $(foreach sub, $(SRC_SUBDIRS), \ 283 $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 284 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))) 285 286 # Find module-info.java files in the specific source dir 287 # Param 1 - Src dir to find module-info.java files in 288 FindModuleInfosForSrcDir = \ 289 $(wildcard \ 290 $(foreach sub, $(SRC_SUBDIRS), \ 291 $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \ 292 ) \ 293 $(patsubst %,%/*/module-info.java, $(strip $1)) \ 294 ) 295 296 # Extract the module names from the paths of module-info.java files. The 297 # position of the module directory differs depending on if this is an imported 298 # src dir or not. 299 GetModuleNameFromModuleInfo = \ 300 $(strip $(foreach mi, $1, \ 301 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 302 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 303 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 304 305 # Find all modules by looking for module-info.java files and looking at parent 306 # directories. 307 FindAllModules = \ 308 $(sort $(filter-out $(MODULES_FILTER), \ 309 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 310 311 # Find all modules in a specific src dir 312 # Param 1 - Src dir to find modules in 313 FindModulesForSrcDir = \ 314 $(sort $(filter-out $(MODULES_FILTER), \ 315 $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \ 316 )) 317 318 FindImportedModules = \ 319 $(filter-out $(MODULES_FILTER), \ 320 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) 321 322 # Find all source dirs for a particular module 323 # $1 - Module to find source dirs for 324 FindModuleSrcDirs = \ 325 $(strip $(wildcard \ 326 $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 327 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 328 329 # Find all specs dirs for a particular module 330 # $1 - Module to find specs dirs for 331 FindModuleSpecsDirs = \ 332 $(strip $(wildcard \ 333 $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 334 335 # Find all man dirs for a particular module 336 # $1 - Module to find man dirs for 337 FindModuleManDirs = \ 338 $(strip $(wildcard \ 339 $(foreach sub, $(MAN_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 340 341 # Construct the complete module source path 342 GetModuleSrcPath = \ 343 $(call PathList, \ 344 $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 345 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) 346 347 ################################################################################ 348 # Extract module dependencies from module-info.java files, both normal 349 # dependencies ("requires"), and indirect exports ("requires transitive"). 350 351 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 352 353 MODULE_INFOS := $(call FindAllModuleInfos, *) 354 355 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 356 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 357 $(call MakeTargetDir) 358 $(RM) $@ 359 $(foreach m, $(MODULE_INFOS), \ 360 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 361 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 362 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 363 /^ *requires/ { sub(/;/, ""); \ 364 sub(/requires /, " "); \ 365 sub(/ static /, " "); \ 366 sub(/ transitive /, " "); \ 367 sub(/\/\/.*/, ""); \ 368 sub(/\/\*.*\*\//, ""); \ 369 gsub(/^ +\*.*/, ""); \ 370 gsub(/ /, ""); \ 371 printf(" %s", $$0) } \ 372 END { printf("\n") }' $m && \ 373 $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 374 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 375 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 376 /^ *requires *transitive/ { \ 377 sub(/;/, ""); \ 378 sub(/requires/, ""); \ 379 sub(/transitive/, ""); \ 380 sub(/\/\/.*/, ""); \ 381 sub(/\/\*.*\*\//, ""); \ 382 gsub(/^ +\*.*/, ""); \ 383 gsub(/ /, ""); \ 384 printf(" %s", $$0) } \ 385 END { printf("\n") }' $m \ 386 ) >> $@ $(NEWLINE)) 387 388 -include $(MODULE_DEPS_MAKEFILE) 389 390 # Find dependencies ("requires") for a given module. 391 # Param 1: Module to find dependencies for. 392 FindDepsForModule = \ 393 $(DEPS_$(strip $1)) 394 395 # Find dependencies ("requires") transitively in 3 levels for a given module. 396 # Param 1: Module to find dependencies for. 397 FindTransitiveDepsForModule = \ 398 $(sort $(call FindDepsForModule, $1) \ 399 $(foreach m, $(call FindDepsForModule, $1), \ 400 $(call FindDepsForModule, $m) \ 401 $(foreach n, $(call FindDepsForModule, $m), \ 402 $(call FindDepsForModule, $n)))) 403 404 # Find dependencies ("requires") transitively in 3 levels for a set of modules. 405 # Param 1: List of modules to find dependencies for. 406 FindTransitiveDepsForModules = \ 407 $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m))) 408 409 # Find indirect exported modules ("requires transitive") for a given module . 410 # Param 1: Module to find indirect exported modules for. 411 FindIndirectExportsForModule = \ 412 $(TRANSITIVE_MODULES_$(strip $1)) 413 414 # Finds indirect exported modules transitively in 3 levels for a given module. 415 # Param 1: Module to find indirect exported modules for. 416 FindTransitiveIndirectDepsForModule = \ 417 $(sort $(call FindIndirectExportsForModule, $1) \ 418 $(foreach m, $(call FindIndirectExportsForModule, $1), \ 419 $(call FindIndirectExportsForModule, $m) \ 420 $(foreach n, $(call FindIndirectExportsForModule, $m), \ 421 $(call FindIndirectExportsForModule, $n)))) 422 423 # Finds indirect exported modules transitively in 3 levels for a set of modules. 424 # Param 1: List of modules to find indirect exported modules for. 425 FindTransitiveIndirectDepsForModules = \ 426 $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m))) 427 428 # Upgradeable modules are those that are either defined as upgradeable or that 429 # require an upradeable module. 430 FindAllUpgradeableModules = \ 431 $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES))) 432 433 434 ################################################################################ 435 436 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal 437 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 438 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal 439 endif 440 LEGAL_SUBDIRS += share/legal 441 442 # Find all legal src dirs for a particular module 443 # $1 - Module to find legal dirs for 444 FindModuleLegalSrcDirs = \ 445 $(strip $(wildcard \ 446 $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \ 447 $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \ 448 )) 449 450 ################################################################################ 451 452 # Param 1 - Name of module 453 define ReadSingleImportMetaData 454 ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), ) 455 classloader := 456 include_in_jre := 457 include_in_jdk := 458 include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties 459 ifeq ($$(include_in_jre), true) 460 JRE_MODULES += $1 461 endif 462 ifeq ($$(include_in_jdk), true) 463 JDK_MODULES += $1 464 endif 465 ifeq ($$(classloader), boot) 466 BOOT_MODULES += $1 467 else ifeq ($$(classloader), ext) 468 PLATFORM_MODULES += $1 469 endif 470 ifneq ($$(include_in_docs), false) 471 # defaults to true if unspecified 472 DOCS_MODULES += $1 473 endif 474 else 475 # Default to include in all 476 JRE_MODULES += $1 477 JDK_MODULES += $1 478 endif 479 endef 480 481 # Reading the imported modules metadata has a cost, so to make it available, 482 # a makefile needs to eval-call this macro first. After calling this, the 483 # following variables are populated with data from the imported modules: 484 # * JRE_MODULES 485 # * JDK_MODULES 486 # * BOOT_MODULES 487 # * PLATFORM_MODULES 488 # * JRE_TOOL_MODULES 489 define ReadImportMetaData 490 IMPORTED_MODULES := $$(call FindImportedModules) 491 $$(foreach m, $$(IMPORTED_MODULES), \ 492 $$(eval $$(call ReadSingleImportMetaData, $$m))) 493 endef 494 495 ################################################################################ 496 497 endif # _MODULES_GMK