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.incubator.vector \
 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.incubator.vector \
 153     jdk.jartool \
 154     jdk.javadoc \
 155     jdk.jcmd \
 156     jdk.jconsole \
 157     jdk.jdeps \
 158     jdk.jdi \
 159     jdk.jdwp.agent \
 160     jdk.jfr \
 161     jdk.jlink \
 162     jdk.jsobject \
 163     jdk.jshell \
 164     jdk.jstatd \
 165     jdk.localedata \
 166     jdk.management \
 167     jdk.management.agent \
 168     jdk.management.jfr \
 169     jdk.naming.dns \
 170     jdk.naming.rmi \
 171     jdk.net \
 172     jdk.pack \
 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 LANGTOOLS_MODULES := \
 187     java.compiler \
 188     jdk.compiler \
 189     jdk.internal.clang \
 190     jdk.javadoc \
 191     jdk.jdeps \
 192     jdk.jextract \
 193     jdk.jshell \
 194     #
 195 
 196 HOTSPOT_MODULES := \
 197     jdk.aot \
 198     jdk.hotspot.agent \
 199     jdk.internal.vm.ci \
 200     jdk.internal.vm.compiler \
 201     jdk.internal.vm.compiler.management \
 202     #
 203 
 204 ################################################################################
 205 # Some platforms don't have the serviceability agent
 206 
 207 ifeq ($(INCLUDE_SA), false)
 208   MODULES_FILTER += jdk.hotspot.agent
 209 endif
 210 
 211 ################################################################################
 212 # Filter out jvmci specific modules if jvmci is disabled
 213 
 214 ifeq ($(INCLUDE_JVMCI), false)
 215   MODULES_FILTER += jdk.internal.vm.ci
 216 endif
 217 
 218 ################################################################################
 219 # Filter out Graal specific modules if Graal is disabled
 220 
 221 ifeq ($(INCLUDE_GRAAL), false)
 222   MODULES_FILTER += jdk.internal.vm.compiler
 223   MODULES_FILTER += jdk.internal.vm.compiler.management
 224 endif
 225 
 226 ################################################################################
 227 # Filter out aot specific modules if aot is disabled
 228 
 229 ifeq ($(ENABLE_AOT), false)
 230   MODULES_FILTER += jdk.aot
 231 endif
 232 
 233 ################################################################################
 234 # Filter out panama specific modules if libclang is disabled
 235 
 236 ifeq ($(ENABLE_LIBCLANG), false)
 237   MODULES_FILTER += jdk.internal.clang
 238   MODULES_FILTER += jdk.jextract
 239 endif
 240 
 241 ################################################################################
 242 # Module list macros
 243 
 244 # Use append so that the custom extension may add to these variables
 245 
 246 GENERATED_SRC_DIRS += \
 247     $(SUPPORT_OUTPUTDIR)/gensrc \
 248     #
 249 
 250 TOP_SRC_DIRS += \
 251     $(TOPDIR)/src \
 252     #
 253 
 254 SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
 255 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 256   SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
 257 endif
 258 SRC_SUBDIRS += share/classes
 259 
 260 SPEC_SUBDIRS += share/specs
 261 
 262 MAN_SUBDIRS += share/man
 263 
 264 # Find all module-info.java files for the current build target platform and
 265 # configuration.
 266 # Param 1 - Module to find for, set to * for finding all
 267 FindAllModuleInfos = \
 268     $(sort $(wildcard \
 269         $(foreach sub, $(SRC_SUBDIRS), \
 270           $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
 271         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))))
 272 
 273 # Find module-info.java files in the specific source dir
 274 # Param 1 - Src dir to find module-info.java files in
 275 FindModuleInfosForSrcDir = \
 276     $(wildcard \
 277         $(foreach sub, $(SRC_SUBDIRS), \
 278           $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
 279         ) \
 280         $(patsubst %,%/*/module-info.java, $(strip $1)) \
 281     )
 282 
 283 # Extract the module names from the paths of module-info.java files. The
 284 # position of the module directory differs depending on if this is an imported
 285 # src dir or not.
 286 GetModuleNameFromModuleInfo = \
 287     $(strip $(foreach mi, $1, \
 288       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
 289         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
 290         $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
 291 
 292 # Find all modules by looking for module-info.java files and looking at parent
 293 # directories.
 294 FindAllModules = \
 295     $(sort $(filter-out $(MODULES_FILTER), \
 296     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
 297 
 298 # Find all modules in a specific src dir
 299 # Param 1 - Src dir to find modules in
 300 FindModulesForSrcDir = \
 301     $(sort $(filter-out $(MODULES_FILTER), \
 302         $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
 303     ))
 304 
 305 FindImportedModules = \
 306     $(filter-out $(MODULES_FILTER), \
 307     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
 308 
 309 # Find all source dirs for a particular module
 310 # $1 - Module to find source dirs for
 311 FindModuleSrcDirs = \
 312     $(strip $(wildcard \
 313         $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 314         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 315 
 316 # Find all specs dirs for a particular module
 317 # $1 - Module to find specs dirs for
 318 FindModuleSpecsDirs = \
 319     $(strip $(wildcard \
 320         $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 321 
 322 # Find all man dirs for a particular module
 323 # $1 - Module to find man dirs for
 324 FindModuleManDirs = \
 325     $(strip $(wildcard \
 326         $(foreach sub, $(MAN_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 327 
 328 # Construct the complete module source path
 329 GetModuleSrcPath = \
 330     $(call PathList, \
 331         $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 332         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
 333 
 334 ################################################################################
 335 # Extract module dependencies from module-info.java files, both normal
 336 # dependencies ("requires"), and indirect exports ("requires transitive").
 337 
 338 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 339 
 340 MODULE_INFOS := $(call FindAllModuleInfos, *)
 341 
 342 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
 343     $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
 344         $(call MakeTargetDir)
 345         $(RM) $@
 346         $(foreach m, $(MODULE_INFOS), \
 347             ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 348               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 349                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 350                   /^ *requires/ { sub(/;/, ""); \
 351                                   sub(/requires /, " "); \
 352                                   sub(/ static /, " "); \
 353                                   sub(/ transitive /, " "); \
 354                                   sub(/\/\/.*/, ""); \
 355                                   sub(/\/\*.*\*\//, ""); \
 356                                   gsub(/^ +\*.*/, ""); \
 357                                   gsub(/ /, ""); \
 358                                   printf(" %s", $$0) } \
 359                   END           { printf("\n") }' $m && \
 360               $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 361               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 362                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 363                   /^ *requires  *transitive/ { \
 364                                   sub(/;/, ""); \
 365                                   sub(/requires/, ""); \
 366                                   sub(/transitive/, ""); \
 367                                   sub(/\/\/.*/, ""); \
 368                                   sub(/\/\*.*\*\//, ""); \
 369                                   gsub(/^ +\*.*/, ""); \
 370                                   gsub(/ /, ""); \
 371                                   printf(" %s", $$0) } \
 372                   END           { printf("\n") }' $m \
 373             ) >> $@ $(NEWLINE))
 374 
 375 -include $(MODULE_DEPS_MAKEFILE)
 376 
 377 # Find dependencies ("requires") for a given module.
 378 # Param 1: Module to find dependencies for.
 379 FindDepsForModule = \
 380   $(DEPS_$(strip $1))
 381 
 382 # Find dependencies ("requires") transitively in 3 levels for a given module.
 383 # Param 1: Module to find dependencies for.
 384 FindTransitiveDepsForModule = \
 385     $(sort $(call FindDepsForModule, $1) \
 386         $(foreach m, $(call FindDepsForModule, $1), \
 387             $(call FindDepsForModule, $m) \
 388             $(foreach n, $(call FindDepsForModule, $m), \
 389                  $(call FindDepsForModule, $n))))
 390 
 391 # Find dependencies ("requires") transitively in 3 levels for a set of modules.
 392 # Param 1: List of modules to find dependencies for.
 393 FindTransitiveDepsForModules = \
 394     $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
 395 
 396 # Find indirect exported modules ("requires transitive") for a given module .
 397 # Param 1: Module to find indirect exported modules for.
 398 FindIndirectExportsForModule = \
 399   $(TRANSITIVE_MODULES_$(strip $1))
 400 
 401 # Finds indirect exported modules transitively in 3 levels for a given module.
 402 # Param 1: Module to find indirect exported modules for.
 403 FindTransitiveIndirectDepsForModule = \
 404     $(sort $(call FindIndirectExportsForModule, $1) \
 405         $(foreach m, $(call FindIndirectExportsForModule, $1), \
 406             $(call FindIndirectExportsForModule, $m) \
 407             $(foreach n, $(call FindIndirectExportsForModule, $m), \
 408                  $(call FindIndirectExportsForModule, $n))))
 409 
 410 # Finds indirect exported modules transitively in 3 levels for a set of modules.
 411 # Param 1: List of modules to find indirect exported modules for.
 412 FindTransitiveIndirectDepsForModules = \
 413     $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m)))
 414 
 415 # Upgradeable modules are those that are either defined as upgradeable or that
 416 # require an upradeable module.
 417 FindAllUpgradeableModules = \
 418     $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES)))
 419 
 420 
 421 ################################################################################
 422 
 423 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
 424 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 425   LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
 426 endif
 427 LEGAL_SUBDIRS += share/legal
 428 
 429 # Find all legal src dirs for a particular module
 430 # $1 - Module to find legal dirs for
 431 FindModuleLegalSrcDirs = \
 432     $(strip $(wildcard \
 433         $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
 434         $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \
 435     ))
 436 
 437 ################################################################################
 438 
 439 # Param 1 - Name of module
 440 define ReadSingleImportMetaData
 441     ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
 442       classloader :=
 443       include_in_jre :=
 444       include_in_jdk :=
 445       include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
 446       ifeq ($$(include_in_jre), true)
 447         JRE_MODULES += $1
 448       endif
 449       ifeq ($$(include_in_jdk), true)
 450         JDK_MODULES += $1
 451       endif
 452       ifeq ($$(classloader), boot)
 453         BOOT_MODULES += $1
 454       else ifeq ($$(classloader), ext)
 455         PLATFORM_MODULES += $1
 456       endif
 457       ifneq ($$(include_in_docs), false)
 458         # defaults to true if unspecified
 459         DOCS_MODULES += $1
 460       endif
 461     else
 462       # Default to include in all
 463       JRE_MODULES += $1
 464       JDK_MODULES += $1
 465     endif
 466 endef
 467 
 468 # Reading the imported modules metadata has a cost, so to make it available,
 469 # a makefile needs to eval-call this macro first. After calling this, the
 470 # following variables are populated with data from the imported modules:
 471 # * JRE_MODULES
 472 # * JDK_MODULES
 473 # * BOOT_MODULES
 474 # * PLATFORM_MODULES
 475 # * JRE_TOOL_MODULES
 476 define ReadImportMetaData
 477     IMPORTED_MODULES := $$(call FindImportedModules)
 478     $$(foreach m, $$(IMPORTED_MODULES), \
 479       $$(eval $$(call ReadSingleImportMetaData, $$m)))
 480 endef
 481 
 482 ################################################################################
 483 
 484 endif # _MODULES_GMK