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.internal.vm.compiler \
  81     #
  82 
  83 
  84 AGGREGATOR_MODULES += \
  85     java.se \
  86     #
  87 
  88 PLATFORM_MODULES += \
  89     $(UPGRADEABLE_MODULES) \
  90     $(AGGREGATOR_MODULES)
  91     #
  92 
  93 PLATFORM_MODULES += \
  94     java.scripting \
  95     java.security.jgss \
  96     java.smartcardio \
  97     java.sql \
  98     java.sql.rowset \
  99     java.transaction.xa \
 100     java.xml.crypto \
 101     jdk.accessibility \
 102     jdk.charsets \
 103     jdk.crypto.cryptoki \
 104     jdk.crypto.ec \
 105     jdk.dynalink \
 106     jdk.httpserver \
 107     jdk.incubator.httpclient \
 108     jdk.internal.vm.compiler.management \
 109     jdk.jsobject \
 110     jdk.localedata \
 111     jdk.naming.dns \
 112     jdk.scripting.nashorn \
 113     jdk.security.auth \
 114     jdk.security.jgss \
 115     jdk.xml.dom \
 116     jdk.zipfs \
 117     #
 118 
 119 ifeq ($(OPENJDK_TARGET_OS), windows)
 120   PLATFORM_MODULES += jdk.crypto.mscapi
 121 endif
 122 
 123 ifeq ($(OPENJDK_TARGET_OS), solaris)
 124   PLATFORM_MODULES += jdk.crypto.ucrypto
 125 endif
 126 
 127 JRE_TOOL_MODULES += \
 128     jdk.jdwp.agent \
 129     jdk.pack \
 130     jdk.scripting.nashorn.shell \
 131     #
 132 
 133 ################################################################################
 134 
 135 # DOCS_MODULES defines the root modules for javadoc generation.
 136 # All of their `require transitive` modules directly and indirectly will be included.
 137 DOCS_MODULES += \
 138     java.se \
 139     java.smartcardio \
 140     jdk.accessibility \
 141     jdk.attach \
 142     jdk.charsets \
 143     jdk.compiler \
 144     jdk.crypto.cryptoki \
 145     jdk.crypto.ec \
 146     jdk.dynalink \
 147     jdk.editpad \
 148     jdk.hotspot.agent \
 149     jdk.httpserver \
 150     jdk.incubator.httpclient \
 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     #
 198 
 199 ################################################################################
 200 # Some platforms don't have the serviceability agent
 201 
 202 ifeq ($(INCLUDE_SA), false)
 203   MODULES_FILTER += jdk.hotspot.agent
 204 endif
 205 
 206 ################################################################################
 207 # Filter out Graal specific modules if Graal build is disabled
 208 
 209 ifeq ($(INCLUDE_GRAAL), false)
 210   MODULES_FILTER += jdk.internal.vm.compiler
 211   MODULES_FILTER += jdk.internal.vm.compiler.management
 212 endif
 213 
 214 ################################################################################
 215 # Filter out aot specific modules if aot is disabled
 216 
 217 ifeq ($(ENABLE_AOT), false)
 218   MODULES_FILTER += jdk.aot
 219 endif
 220 
 221 ################################################################################
 222 # Module list macros
 223 
 224 # Use append so that the custom extension may add to these variables
 225 
 226 GENERATED_SRC_DIRS += \
 227     $(SUPPORT_OUTPUTDIR)/gensrc \
 228     #
 229 
 230 TOP_SRC_DIRS += \
 231     $(TOPDIR)/src \
 232     #
 233 
 234 SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
 235 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 236   SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
 237 endif
 238 SRC_SUBDIRS += share/classes
 239 
 240 SPEC_SUBDIRS += share/specs
 241 
 242 # Find all module-info.java files for the current build target platform and
 243 # configuration.
 244 # Param 1 - Module to find for, set to * for finding all
 245 FindAllModuleInfos = \
 246     $(sort $(wildcard \
 247         $(foreach sub, $(SRC_SUBDIRS), \
 248           $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
 249         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))))
 250 
 251 # Find module-info.java files in the specific source dir
 252 # Param 1 - Src dir to find module-info.java files in
 253 FindModuleInfosForSrcDir = \
 254     $(wildcard \
 255         $(foreach sub, $(SRC_SUBDIRS), \
 256           $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
 257         ) \
 258         $(patsubst %,%/*/module-info.java, $(strip $1)) \
 259     )
 260 
 261 # Extract the module names from the paths of module-info.java files. The
 262 # position of the module directory differs depending on if this is an imported
 263 # src dir or not.
 264 GetModuleNameFromModuleInfo = \
 265     $(strip $(foreach mi, $1, \
 266       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
 267         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
 268         $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
 269 
 270 # Find all modules by looking for module-info.java files and looking at parent
 271 # directories.
 272 FindAllModules = \
 273     $(sort $(filter-out $(MODULES_FILTER), \
 274     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
 275 
 276 # Find all modules in a specific src dir
 277 # Param 1 - Src dir to find modules in
 278 FindModulesForSrcDir = \
 279     $(sort $(filter-out $(MODULES_FILTER), \
 280         $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
 281     ))
 282 
 283 FindImportedModules = \
 284     $(filter-out $(MODULES_FILTER), \
 285     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
 286 
 287 # Find all source dirs for a particular module
 288 # $1 - Module to find source dirs for
 289 FindModuleSrcDirs = \
 290     $(strip $(wildcard \
 291         $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 292         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 293 
 294 # Find all specs dirs for a particular module
 295 # $1 - Module to find specs dirs for
 296 FindModuleSpecsDirs = \
 297     $(strip $(wildcard \
 298         $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 299 
 300 # Construct the complete module source path
 301 GetModuleSrcPath = \
 302     $(call PathList, \
 303         $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 304         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
 305 
 306 ################################################################################
 307 # Extract module dependencies from module-info.java files, both normal
 308 # dependencies ("requires"), and indirect exports ("requires transitive").
 309 
 310 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 311 
 312 MODULE_INFOS := $(call FindAllModuleInfos, *)
 313 
 314 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
 315     $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
 316         $(MKDIR) -p $(@D)
 317         $(RM) $@
 318         $(foreach m, $(MODULE_INFOS), \
 319             ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 320               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 321                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 322                   /^ *requires/ { sub(/;/, ""); \
 323                                   sub(/requires /, " "); \
 324                                   sub(/ static /, " "); \
 325                                   sub(/ transitive /, " "); \
 326                                   sub(/\/\/.*/, ""); \
 327                                   sub(/\/\*.*\*\//, ""); \
 328                                   gsub(/^ +\*.*/, ""); \
 329                                   gsub(/ /, ""); \
 330                                   printf(" %s", $$0) } \
 331                   END           { printf("\n") }' $m && \
 332               $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 333               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 334                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 335                   /^ *requires  *transitive/ { \
 336                                   sub(/;/, ""); \
 337                                   sub(/requires/, ""); \
 338                                   sub(/transitive/, ""); \
 339                                   sub(/\/\/.*/, ""); \
 340                                   sub(/\/\*.*\*\//, ""); \
 341                                   gsub(/^ +\*.*/, ""); \
 342                                   gsub(/ /, ""); \
 343                                   printf(" %s", $$0) } \
 344                   END           { printf("\n") }' $m \
 345             ) >> $@ $(NEWLINE))
 346 
 347 -include $(MODULE_DEPS_MAKEFILE)
 348 
 349 # Find dependencies ("requires") for a given module.
 350 # Param 1: Module to find dependencies for.
 351 FindDepsForModule = \
 352   $(DEPS_$(strip $1))
 353 
 354 # Find dependencies ("requires") transitively in 3 levels for a given module.
 355 # Param 1: Module to find dependencies for.
 356 FindTransitiveDepsForModule = \
 357     $(sort $(call FindDepsForModule, $1) \
 358         $(foreach m, $(call FindDepsForModule, $1), \
 359             $(call FindDepsForModule, $m) \
 360             $(foreach n, $(call FindDepsForModule, $m), \
 361                  $(call FindDepsForModule, $n))))
 362 
 363 # Find dependencies ("requires") transitively in 3 levels for a set of modules.
 364 # Param 1: List of modules to find dependencies for.
 365 FindTransitiveDepsForModules = \
 366     $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
 367 
 368 # Find indirect exported modules ("requires transitive") for a given module .
 369 # Param 1: Module to find indirect exported modules for.
 370 FindIndirectExportsForModule = \
 371   $(TRANSITIVE_MODULES_$(strip $1))
 372 
 373 # Finds indirect exported modules transitively in 3 levels for a given module.
 374 # Param 1: Module to find indirect exported modules for.
 375 FindTransitiveIndirectDepsForModule = \
 376     $(sort $(call FindIndirectExportsForModule, $1) \
 377         $(foreach m, $(call FindIndirectExportsForModule, $1), \
 378             $(call FindIndirectExportsForModule, $m) \
 379             $(foreach n, $(call FindIndirectExportsForModule, $m), \
 380                  $(call FindIndirectExportsForModule, $n))))
 381 
 382 # Finds indirect exported modules transitively in 3 levels for a set of modules.
 383 # Param 1: List of modules to find indirect exported modules for.
 384 FindTransitiveIndirectDepsForModules = \
 385     $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m)))
 386 
 387 # Upgradeable modules are those that are either defined as upgradeable or that
 388 # require an upradeable module.
 389 FindAllUpgradeableModules = \
 390     $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES)))
 391 
 392 
 393 ################################################################################
 394 
 395 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
 396 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 397   LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
 398 endif
 399 LEGAL_SUBDIRS += share/legal
 400 
 401 # Find all legal dirs for a particular module
 402 # $1 - Module to find legal dirs for
 403 FindModuleLegalDirs = \
 404     $(strip $(wildcard \
 405         $(addsuffix /$(strip $1), $(SUPPORT_OUTPUTDIR)/modules_legal \
 406             $(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