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