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.incubator.mvt \
 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.incubator.mvt \
 160     jdk.jartool \
 161     jdk.javadoc \
 162     jdk.jcmd \
 163     jdk.jconsole \
 164     jdk.jdeps \
 165     jdk.jdi \
 166     jdk.jdwp.agent \
 167     jdk.jlink \
 168     jdk.jsobject \
 169     jdk.jshell \
 170     jdk.jstatd \
 171     jdk.localedata \
 172     jdk.management \
 173     jdk.management.agent \
 174     jdk.naming.dns \
 175     jdk.naming.rmi \
 176     jdk.net \
 177     jdk.pack \
 178     jdk.policytool \
 179     jdk.rmic \
 180     jdk.scripting.nashorn \
 181     jdk.sctp \
 182     jdk.security.auth \
 183     jdk.security.jgss \
 184     jdk.xml.dom \
 185     jdk.zipfs \
 186     #
 187 
 188 # These modules are included in the interim image which is used to run profiling
 189 # before building the real images.
 190 INTERIM_IMAGE_MODULES := java.base java.logging
 191 
 192 ################################################################################
 193 # Some platforms don't have the serviceability agent
 194 
 195 ifeq ($(INCLUDE_SA), false)
 196   MODULES_FILTER += jdk.hotspot.agent
 197 endif
 198 
 199 ################################################################################
 200 # Filter out Graal specific modules if Graal build is disabled
 201 
 202 ifeq ($(INCLUDE_GRAAL), false)
 203   MODULES_FILTER += jdk.internal.vm.compiler
 204 endif
 205 
 206 ################################################################################
 207 # Filter out aot specific modules if aot is disabled
 208 
 209 ifeq ($(ENABLE_AOT), false)
 210   MODULES_FILTER += jdk.aot
 211 endif
 212 
 213 ################################################################################
 214 # Module list macros
 215 
 216 # Use append so that the custom extension may add to these variables
 217 
 218 GENERATED_SRC_DIRS += \
 219     $(SUPPORT_OUTPUTDIR)/gensrc \
 220     #
 221 
 222 TOP_SRC_DIRS += \
 223     $(CORBA_TOPDIR)/src \
 224     $(HOTSPOT_TOPDIR)/src \
 225     $(JDK_TOPDIR)/src \
 226     $(LANGTOOLS_TOPDIR)/src \
 227     $(JAXP_TOPDIR)/src \
 228     $(JAXWS_TOPDIR)/src \
 229     $(NASHORN_TOPDIR)/src \
 230     #
 231 
 232 SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
 233 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 234   SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
 235 endif
 236 SRC_SUBDIRS += share/classes
 237 
 238 SPEC_SUBDIRS += share/specs
 239 
 240 # Find all module-info.java files for the current build target platform and
 241 # configuration.
 242 # Param 1 - Module to find for, set to * for finding all
 243 FindAllModuleInfos = \
 244     $(wildcard \
 245         $(foreach sub, $(SRC_SUBDIRS), \
 246           $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
 247         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
 248 
 249 # Find module-info.java files in the specific source dir
 250 # Param 1 - Src dir to find module-info.java files in
 251 FindModuleInfosForSrcDir = \
 252     $(wildcard \
 253         $(foreach sub, $(SRC_SUBDIRS), \
 254           $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
 255         ) \
 256         $(patsubst %,%/*/module-info.java, $(strip $1)) \
 257     )
 258 
 259 # Extract the module names from the paths of module-info.java files. The
 260 # position of the module directory differs depending on if this is an imported
 261 # src dir or not.
 262 GetModuleNameFromModuleInfo = \
 263     $(strip $(foreach mi, $1, \
 264       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
 265         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
 266         $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
 267 
 268 # Find all modules by looking for module-info.java files and looking at parent
 269 # directories.
 270 FindAllModules = \
 271     $(sort $(filter-out $(MODULES_FILTER), \
 272     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
 273 
 274 # Find all modules in a specific src dir
 275 # Param 1 - Src dir to find modules in
 276 FindModulesForSrcDir = \
 277     $(sort $(filter-out $(MODULES_FILTER), \
 278         $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
 279     ))
 280 
 281 FindImportedModules = \
 282     $(filter-out $(MODULES_FILTER), \
 283     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
 284 
 285 # Find all source dirs for a particular module
 286 # $1 - Module to find source dirs for
 287 FindModuleSrcDirs = \
 288     $(strip $(wildcard \
 289         $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 290         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 291 
 292 # Find all specs dirs for a particular module
 293 # $1 - Module to find specs dirs for
 294 FindModuleSpecsDirs = \
 295     $(strip $(wildcard \
 296         $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 297 
 298 # Construct the complete module source path
 299 GetModuleSrcPath = \
 300     $(call PathList, \
 301         $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 302         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
 303 
 304 ################################################################################
 305 # Extract module dependencies from module-info.java files, both normal
 306 # dependencies ("requires"), and indirect exports ("requires transitive").
 307 
 308 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 309 
 310 MODULE_INFOS := $(call FindAllModuleInfos, *)
 311 
 312 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
 313     $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
 314         $(MKDIR) -p $(@D)
 315         $(RM) $@
 316         $(foreach m, $(MODULE_INFOS), \
 317             ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 318               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 319                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 320                   /^ *requires/ { sub(/;/, ""); \
 321                                   sub(/requires/, ""); \
 322                                   sub(/transitive/, ""); \
 323                                   sub(/\/\/.*/, ""); \
 324                                   sub(/\/\*.*\*\//, ""); \
 325                                   gsub(/^ +\*.*/, ""); \
 326                                   gsub(/ /, ""); \
 327                                   printf(" %s", $$0) } \
 328                   END           { printf("\n") }' $m && \
 329               $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 330               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 331                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 332                   /^ *requires  *transitive/ { \
 333                                   sub(/;/, ""); \
 334                                   sub(/requires/, ""); \
 335                                   sub(/transitive/, ""); \
 336                                   sub(/\/\/.*/, ""); \
 337                                   sub(/\/\*.*\*\//, ""); \
 338                                   gsub(/^ +\*.*/, ""); \
 339                                   gsub(/ /, ""); \
 340                                   printf(" %s", $$0) } \
 341                   END           { printf("\n") }' $m \
 342             ) >> $@ $(NEWLINE))
 343 
 344 -include $(MODULE_DEPS_MAKEFILE)
 345 
 346 # Find dependencies ("requires") for a given module.
 347 # Param 1: Module to find dependencies for.
 348 FindDepsForModule = \
 349   $(DEPS_$(strip $1))
 350 
 351 # Find dependencies ("requires") transitively in 3 levels for a given module.
 352 # Param 1: Module to find dependencies for.
 353 FindTransitiveDepsForModule = \
 354     $(sort $(call FindDepsForModule, $1) \
 355         $(foreach m, $(call FindDepsForModule, $1), \
 356             $(call FindDepsForModule, $m) \
 357             $(foreach n, $(call FindDepsForModule, $m), \
 358                  $(call FindDepsForModule, $n))))
 359 
 360 # Find dependencies ("requires") transitively in 3 levels for a set of modules.
 361 # Param 1: List of modules to find dependencies for.
 362 FindTransitiveDepsForModules = \
 363     $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
 364 
 365 # Find indirect exported modules ("requires transitive") for a given module .
 366 # Param 1: Module to find indirect exported modules for.
 367 FindIndirectExportsForModule = \
 368   $(TRANSITIVE_MODULES_$(strip $1))
 369 
 370 # Finds indirect exported modules transitively in 3 levels for a given module.
 371 # Param 1: Module to find indirect exported modules for.
 372 FindTransitiveIndirectDepsForModule = \
 373     $(sort $(call FindIndirectExportsForModule, $1) \
 374         $(foreach m, $(call FindIndirectExportsForModule, $1), \
 375             $(call FindIndirectExportsForModule, $m) \
 376             $(foreach n, $(call FindIndirectExportsForModule, $m), \
 377                  $(call FindIndirectExportsForModule, $n))))
 378 
 379 # Finds indirect exported modules transitively in 3 levels for a set of modules.
 380 # Param 1: List of modules to find indirect exported modules for.
 381 FindTransitiveIndirectDepsForModules = \
 382     $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m)))
 383 
 384 # Upgradeable modules are those that are either defined as upgradeable or that
 385 # require an upradeable module.
 386 FindAllUpgradeableModules = \
 387     $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES) $(UPGRADEABLE_TOOL_MODULES)))
 388 
 389 
 390 ################################################################################
 391 
 392 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
 393 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 394   LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
 395 endif
 396 LEGAL_SUBDIRS += share/legal
 397 
 398 # Find all legal dirs for a particular module
 399 # $1 - Module to find legal dirs for
 400 FindModuleLegalDirs = \
 401     $(strip $(wildcard \
 402         $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
 403         $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 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