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