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