1 #
   2 # Copyright (c) 2014, 2016, 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 
  44 # Hook to include the corresponding custom file, if present.
  45 $(eval $(call IncludeCustomExtension, , common/Modules.gmk))
  46 
  47 BOOT_MODULES += \
  48     java.base \
  49     java.datatransfer \
  50     java.desktop \
  51     java.httpclient \
  52     java.instrument \
  53     java.logging \
  54     java.management \
  55     java.naming \
  56     java.prefs \
  57     java.rmi \
  58     java.security.sasl \
  59     java.xml \
  60     jdk.httpserver \
  61     jdk.management \
  62     jdk.net \
  63     jdk.sctp \
  64     jdk.unsupported \
  65     jdk.vm.ci \
  66     #
  67 
  68 # to be deprivileged
  69 BOOT_MODULES += \
  70     jdk.naming.rmi \
  71     #
  72 
  73 UPGRADEABLE_MODULES += \
  74     java.activation \
  75     java.annotations.common \
  76     java.corba \
  77     java.transaction \
  78     java.xml.bind \
  79     java.xml.ws \
  80     #
  81 
  82 # Modules explicitly declared as not being upgradeable even though they require
  83 # an upgradeable module.
  84 NON_UPGRADEABLE_MODULES +=
  85 
  86 AGGREGATOR_MODULES += \
  87     java.compact1 \
  88     java.compact2 \
  89     java.compact3 \
  90     java.se \
  91     java.se.ee \
  92     #
  93 
  94 PLATFORM_MODULES += \
  95     $(UPGRADEABLE_MODULES) \
  96     $(AGGREGATOR_MODULES)
  97     #
  98 
  99 PLATFORM_MODULES += \
 100     java.compiler \
 101     java.scripting \
 102     java.security.jgss \
 103     java.smartcardio \
 104     java.sql \
 105     java.sql.rowset \
 106     java.xml.crypto \
 107     jdk.accessibility \
 108     jdk.charsets \
 109     jdk.crypto.ec \
 110     jdk.crypto.pkcs11 \
 111     jdk.dynalink \
 112     jdk.jsobject \
 113     jdk.localedata \
 114     jdk.naming.dns \
 115     jdk.scripting.nashorn \
 116     jdk.security.auth \
 117     jdk.security.jgss \
 118     jdk.xml.dom \
 119     jdk.zipfs \
 120     #
 121 
 122 JRE_TOOL_MODULES += \
 123     jdk.jdwp.agent \
 124     jdk.pack200 \
 125     jdk.scripting.nashorn.shell \
 126     #
 127 
 128 ifeq ($(OPENJDK_TARGET_OS), windows)
 129   PLATFORM_MODULES += jdk.crypto.mscapi
 130 endif
 131 ifeq ($(OPENJDK_TARGET_OS), solaris)
 132   PLATFORM_MODULES += jdk.crypto.ucrypto
 133 endif
 134 
 135 # These modules are included in the interim image which is used to run profiling
 136 # before building the real images.
 137 INTERIM_IMAGE_MODULES := java.base java.logging
 138 
 139 ################################################################################
 140 # Some platforms don't have the serviceability agent
 141 
 142 ifeq ($(INCLUDE_SA), false)
 143   MODULES_FILTER += jdk.hotspot.agent
 144 endif
 145 
 146 ################################################################################
 147 # Module list macros
 148 
 149 # Use append so that the custom extension may add to these variables
 150 
 151 GENERATED_SRC_DIRS += \
 152     $(SUPPORT_OUTPUTDIR)/gensrc \
 153     #
 154 
 155 TOP_SRC_DIRS += \
 156     $(CORBA_TOPDIR)/src \
 157     $(HOTSPOT_TOPDIR)/src \
 158     $(JDK_TOPDIR)/src \
 159     $(LANGTOOLS_TOPDIR)/src \
 160     $(JAXP_TOPDIR)/src \
 161     $(JAXWS_TOPDIR)/src \
 162     $(NASHORN_TOPDIR)/src \
 163     #
 164 
 165 SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
 166 ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
 167   SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
 168 endif
 169 SRC_SUBDIRS += share/classes
 170 
 171 # Find all module-info.java files for the current build target platform and
 172 # configuration.
 173 # Param 1 - Module to find for, set to * for finding all
 174 FindAllModuleInfos = \
 175     $(wildcard \
 176         $(foreach sub, $(SRC_SUBDIRS), \
 177           $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
 178         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
 179 
 180 # Find module-info.java files in the specific source dir
 181 # Param 1 - Src dir to find module-info.java files in
 182 FindModuleInfosForSrcDir = \
 183     $(wildcard \
 184         $(foreach sub, $(SRC_SUBDIRS), \
 185           $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
 186         ) \
 187         $(patsubst %,%/*/module-info.java, $(strip $1)) \
 188     )
 189 
 190 # Extract the module names from the paths of module-info.java files. The
 191 # position of the module directory differs depending on if this is an imported
 192 # src dir or not.
 193 GetModuleNameFromModuleInfo = \
 194     $(strip $(foreach mi, $1, \
 195       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
 196         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
 197         $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
 198 
 199 # Find all modules by looking for module-info.java files and looking at parent
 200 # directories.
 201 FindAllModules = \
 202     $(sort $(filter-out $(MODULES_FILTER), \
 203     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
 204 
 205 # Find all modules in a specific src dir
 206 # Param 1 - Src dir to find modules in
 207 FindModulesForSrcDir = \
 208     $(sort $(filter-out $(MODULES_FILTER), \
 209         $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
 210     ))
 211 
 212 FindImportedModules = \
 213     $(filter-out $(MODULES_FILTER), \
 214     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
 215 
 216 # Find all source dirs for a particular module
 217 # $1 - Module to find source dirs for
 218 FindModuleSrcDirs = \
 219     $(strip $(wildcard \
 220         $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 221         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 222 
 223 # Construct the complete module source path
 224 GetModuleSrcPath = \
 225     $(call PathList, \
 226         $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
 227         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
 228 
 229 ################################################################################
 230 # Extract module dependencies from module-info.java files.
 231 
 232 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 233 
 234 MODULE_INFOS := $(call FindAllModuleInfos, *)
 235 
 236 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
 237     $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
 238         $(MKDIR) -p $(@D)
 239         $(RM) $@
 240         $(foreach m, $(MODULE_INFOS), \
 241             ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 242               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 243                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 244                   /requires/ { sub(/;/, ""); \
 245                                sub(/requires/, ""); \
 246                                sub(/public/, ""); \
 247                                sub(/\/\/.*/, ""); \
 248                                sub(/\/\*.*\*\//, ""); \
 249                                gsub(/^ +\*.*/, ""); \
 250                                gsub(/ /, ""); \
 251                                printf(" %s", $$0) } \
 252                   END        { printf("\n") }' $m \
 253             ) >> $@ $(NEWLINE))
 254 
 255 -include $(MODULE_DEPS_MAKEFILE)
 256 
 257 # Param 1: Module to find deps for
 258 FindDepsForModule = \
 259   $(DEPS_$(strip $1))
 260 
 261 # Finds transitive dependencies in 3 levels.
 262 # Param 1: Module to find transitive deps for
 263 FindTransitiveDepsForModule = \
 264     $(sort $(call FindDepsForModule, $1) \
 265         $(foreach m, $(call FindDepsForModule, $1), \
 266             $(call FindDepsForModule, $m) \
 267             $(foreach n, $(call FindDepsForModule, $m), \
 268                  $(call FindDepsForModule, $n))))
 269 
 270 # Upgradeable modules are those that are either defined as upgradeable or that
 271 # require an upradeable module.
 272 FindAllUpgradeableModules = \
 273     $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
 274         $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
 275             $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
 276           $(if $(filter $(UPGRADEABLE_MODULES), \
 277               $(call FindTransitiveDepsForModule, $m)), \
 278             $m \
 279           ) \
 280         )) \
 281     )
 282 
 283 ################################################################################
 284 
 285 # Param 1 - Name of module
 286 define ReadSingleImportMetaData
 287     ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
 288       classloader :=
 289       include_in_jre :=
 290       include_in_jdk :=
 291       include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
 292       ifeq ($$(include_in_jre), true)
 293         JRE_MODULES += $1
 294       endif
 295       ifeq ($$(include_in_jdk), true)
 296         JDK_MODULES += $1
 297       endif
 298       ifeq ($$(classloader), boot)
 299         BOOT_MODULES += $1
 300       else ifeq ($$(classloader), ext)
 301         PLATFORM_MODULES += $1
 302       endif
 303     else
 304       # Default to include in all
 305       JRE_MODULES += $1
 306       JDK_MODULES += $1
 307     endif
 308 endef
 309 
 310 # Reading the imported modules metadata has a cost, so to make it available,
 311 # a makefile needs to eval-call this macro first. After calling this, the
 312 # following variables are populated with data from the imported modules:
 313 # * JRE_MODULES
 314 # * JDK_MODULES
 315 # * BOOT_MODULES
 316 # * PLATFORM_MODULES
 317 # * JRE_TOOL_MODULES
 318 define ReadImportMetaData
 319     IMPORTED_MODULES := $$(call FindImportedModules)
 320     $$(foreach m, $$(IMPORTED_MODULES), \
 321       $$(eval $$(call ReadSingleImportMetaData, $$m)))
 322 endef
 323 
 324 ################################################################################
 325 
 326 endif # _MODULES_GMK