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