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