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