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