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