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 UPGRADEABLE_MODULES += \
  76     java.activation \
  77     java.corba \
  78     java.transaction \
  79     java.xml.bind \
  80     java.xml.ws \
  81     java.xml.ws.annotation \
  82     #
  83 
  84 # Modules explicitly declared as not being upgradeable even though they require
  85 # an upgradeable module.
  86 NON_UPGRADEABLE_MODULES +=
  87 
  88 AGGREGATOR_MODULES += \
  89     java.se \
  90     java.se.ee \
  91     #
  92 
  93 PLATFORM_MODULES += \
  94     $(UPGRADEABLE_MODULES) \
  95     $(AGGREGATOR_MODULES)
  96     #
  97 
  98 PLATFORM_MODULES += \
  99     java.compiler \
 100     java.scripting \
 101     java.security.jgss \
 102     java.smartcardio \
 103     java.sql \
 104     java.sql.rowset \
 105     java.xml.crypto \
 106     jdk.accessibility \
 107     jdk.charsets \
 108     jdk.crypto.cryptoki \
 109     jdk.crypto.ec \
 110     jdk.dynalink \
 111     jdk.incubator.httpclient \
 112     jdk.internal.vm.compiler \
 113     jdk.jsobject \
 114     jdk.localedata \
 115     jdk.naming.dns \
 116     jdk.scripting.nashorn \
 117     jdk.security.auth \
 118     jdk.security.jgss \
 119     jdk.xml.dom \
 120     jdk.zipfs \
 121     #
 122 
 123 ifeq ($(OPENJDK_TARGET_OS), windows)
 124   PLATFORM_MODULES += jdk.crypto.mscapi
 125   DOCS_MODULES += jdk.crypto.mscapi
 126 endif
 127 
 128 ifeq ($(OPENJDK_TARGET_OS), solaris)
 129   PLATFORM_MODULES += jdk.crypto.ucrypto
 130   DOCS_MODULES += jdk.crypto.ucrypto
 131 endif
 132 
 133 JRE_TOOL_MODULES += \
 134     jdk.jdwp.agent \
 135     jdk.pack \
 136     jdk.scripting.nashorn.shell \
 137     #
 138 
 139 ################################################################################
 140 
 141 #
 142 # Workaround --expand-requires transitive that does not include java.base
 143 #
 144 DOCS_MODULES += \
 145     java.base \
 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.httpserver \
 157     jdk.incubator.httpclient \
 158     jdk.jartool \
 159     jdk.javadoc \
 160     jdk.jconsole \
 161     jdk.jdeps \
 162     jdk.jdi \
 163     jdk.jlink \
 164     jdk.jshell \
 165     jdk.localedata \
 166     jdk.management \
 167     jdk.naming.dns \
 168     jdk.naming.rmi \
 169     jdk.net \
 170     jdk.scripting.nashorn \
 171     jdk.sctp \
 172     jdk.security.auth \
 173     jdk.security.jgss \
 174     jdk.xml.dom \
 175     jdk.zipfs \
 176     #
 177 
 178 # These modules are included in the interim image which is used to run profiling
 179 # before building the real images.
 180 INTERIM_IMAGE_MODULES := java.base java.logging
 181 
 182 ################################################################################
 183 # Some platforms don't have the serviceability agent
 184 
 185 ifeq ($(INCLUDE_SA), false)
 186   MODULES_FILTER += jdk.hotspot.agent
 187 endif
 188 
 189 ################################################################################
 190 # Filter out Graal specific modules if Graal build is disabled
 191 
 192 ifeq ($(INCLUDE_GRAAL), false)
 193   MODULES_FILTER += jdk.internal.vm.compiler
 194 endif
 195 
 196 ################################################################################
 197 # Filter out aot specific modules if aot is disabled
 198 
 199 ifeq ($(ENABLE_AOT), false)
 200   MODULES_FILTER += jdk.aot
 201 endif
 202 
 203 ################################################################################
 204 # Module list macros
 205 
 206 # Use append so that the custom extension may add to these variables
 207 
 208 GENERATED_SRC_DIRS += \
 209     $(SUPPORT_OUTPUTDIR)/gensrc \
 210     #
 211 
 212 TOP_SRC_DIRS += \
 213     $(CORBA_TOPDIR)/src \
 214     $(HOTSPOT_TOPDIR)/src \
 215     $(JDK_TOPDIR)/src \
 216     $(LANGTOOLS_TOPDIR)/src \
 217     $(JAXP_TOPDIR)/src \
 218     $(JAXWS_TOPDIR)/src \
 219     $(NASHORN_TOPDIR)/src \
 220     #
 221 
 222 SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
 223 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 224   SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
 225 endif
 226 SRC_SUBDIRS += share/classes
 227 
 228 # Find all module-info.java files for the current build target platform and
 229 # configuration.
 230 # Param 1 - Module to find for, set to * for finding all
 231 FindAllModuleInfos = \
 232     $(wildcard \
 233         $(foreach sub, $(SRC_SUBDIRS), \
 234           $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
 235         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
 236 
 237 # Find module-info.java files in the specific source dir
 238 # Param 1 - Src dir to find module-info.java files in
 239 FindModuleInfosForSrcDir = \
 240     $(wildcard \
 241         $(foreach sub, $(SRC_SUBDIRS), \
 242           $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
 243         ) \
 244         $(patsubst %,%/*/module-info.java, $(strip $1)) \
 245     )
 246 
 247 # Extract the module names from the paths of module-info.java files. The
 248 # position of the module directory differs depending on if this is an imported
 249 # src dir or not.
 250 GetModuleNameFromModuleInfo = \
 251     $(strip $(foreach mi, $1, \
 252       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
 253         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
 254         $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
 255 
 256 # Find all modules by looking for module-info.java files and looking at parent
 257 # directories.
 258 FindAllModules = \
 259     $(sort $(filter-out $(MODULES_FILTER), \
 260     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
 261 
 262 # Find all modules in a specific src dir
 263 # Param 1 - Src dir to find modules in
 264 FindModulesForSrcDir = \
 265     $(sort $(filter-out $(MODULES_FILTER), \
 266         $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
 267     ))
 268 
 269 FindImportedModules = \
 270     $(filter-out $(MODULES_FILTER), \
 271     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
 272 
 273 # Find all source dirs for a particular module
 274 # $1 - Module to find source dirs for
 275 FindModuleSrcDirs = \
 276     $(strip $(wildcard \
 277         $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 278         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 279 
 280 # Construct the complete module source path
 281 GetModuleSrcPath = \
 282     $(call PathList, \
 283         $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 284         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
 285 
 286 ################################################################################
 287 # Extract module dependencies from module-info.java files.
 288 
 289 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 290 
 291 MODULE_INFOS := $(call FindAllModuleInfos, *)
 292 
 293 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
 294     $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
 295         $(MKDIR) -p $(@D)
 296         $(RM) $@
 297         $(foreach m, $(MODULE_INFOS), \
 298             ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 299               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 300                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 301                   /requires/ { sub(/;/, ""); \
 302                                sub(/requires/, ""); \
 303                                sub(/transitive/, ""); \
 304                                sub(/\/\/.*/, ""); \
 305                                sub(/\/\*.*\*\//, ""); \
 306                                gsub(/^ +\*.*/, ""); \
 307                                gsub(/ /, ""); \
 308                                printf(" %s", $$0) } \
 309                   END        { printf("\n") }' $m \
 310             ) >> $@ $(NEWLINE))
 311 
 312 -include $(MODULE_DEPS_MAKEFILE)
 313 
 314 # Param 1: Module to find deps for
 315 FindDepsForModule = \
 316   $(DEPS_$(strip $1))
 317 
 318 # Finds transitive dependencies in 3 levels.
 319 # Param 1: Module to find transitive deps for
 320 FindTransitiveDepsForModule = \
 321     $(sort $(call FindDepsForModule, $1) \
 322         $(foreach m, $(call FindDepsForModule, $1), \
 323             $(call FindDepsForModule, $m) \
 324             $(foreach n, $(call FindDepsForModule, $m), \
 325                  $(call FindDepsForModule, $n))))
 326 
 327 # Upgradeable modules are those that are either defined as upgradeable or that
 328 # require an upradeable module.
 329 FindAllUpgradeableModules = \
 330     $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
 331         $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
 332             $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
 333           $(if $(filter $(UPGRADEABLE_MODULES), \
 334               $(call FindTransitiveDepsForModule, $m)), \
 335             $m \
 336           ) \
 337         )) \
 338     )
 339 
 340 ################################################################################
 341 
 342 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
 343 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 344   LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
 345 endif
 346 LEGAL_SUBDIRS += share/legal
 347 
 348 # Find all legal dirs for a particular module
 349 # $1 - Module to find legal dirs for
 350 FindModuleLegalDirs = \
 351     $(strip $(wildcard \
 352         $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
 353         $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 354 
 355 ################################################################################
 356 
 357 # Param 1 - Name of module
 358 define ReadSingleImportMetaData
 359     ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
 360       classloader :=
 361       include_in_jre :=
 362       include_in_jdk :=
 363       include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
 364       ifeq ($$(include_in_jre), true)
 365         JRE_MODULES += $1
 366       endif
 367       ifeq ($$(include_in_jdk), true)
 368         JDK_MODULES += $1
 369       endif
 370       ifeq ($$(classloader), boot)
 371         BOOT_MODULES += $1
 372       else ifeq ($$(classloader), ext)
 373         PLATFORM_MODULES += $1
 374       endif
 375       DOCS_MODULES += $1
 376     else
 377       # Default to include in all
 378       JRE_MODULES += $1
 379       JDK_MODULES += $1
 380     endif
 381 endef
 382 
 383 # Reading the imported modules metadata has a cost, so to make it available,
 384 # a makefile needs to eval-call this macro first. After calling this, the
 385 # following variables are populated with data from the imported modules:
 386 # * JRE_MODULES
 387 # * JDK_MODULES
 388 # * BOOT_MODULES
 389 # * PLATFORM_MODULES
 390 # * JRE_TOOL_MODULES
 391 define ReadImportMetaData
 392     IMPORTED_MODULES := $$(call FindImportedModules)
 393     $$(foreach m, $$(IMPORTED_MODULES), \
 394       $$(eval $$(call ReadSingleImportMetaData, $$m)))
 395 endef
 396 
 397 ################################################################################
 398 
 399 endif # _MODULES_GMK