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