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