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