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