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