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