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