Modules.gmk revision 2173:03e2c69ce64a
1172185Simp#
2113515Strhodes# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3172185Simp# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4113515Strhodes#
5113515Strhodes# This code is free software; you can redistribute it and/or modify it
6172185Simp# under the terms of the GNU General Public License version 2 only, as
7172185Simp# published by the Free Software Foundation.  Oracle designates this
8172185Simp# particular file as subject to the "Classpath" exception as provided
9113515Strhodes# by Oracle in the LICENSE file that accompanied this code.
10113515Strhodes#
11113515Strhodes# This code is distributed in the hope that it will be useful, but WITHOUT
12113515Strhodes# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13113515Strhodes# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14113515Strhodes# version 2 for more details (a copy is included in the LICENSE file that
15113515Strhodes# accompanied this code).
16113515Strhodes#
17113515Strhodes# You should have received a copy of the GNU General Public License version
18113515Strhodes# 2 along with this work; if not, write to the Free Software Foundation,
19113515Strhodes# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20113515Strhodes#
21113515Strhodes# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22113515Strhodes# or visit www.oracle.com if you need additional information or have any
23113515Strhodes# questions.
24113515Strhodes#
25113515Strhodes
26113515Strhodesifndef _MODULES_GMK
27113515Strhodes_MODULES_GMK := 1
28113515Strhodes
29113515Strhodes################################################################################
30113515Strhodes#
31113515Strhodes# BOOT_MODULES are modules defined by the boot loader
32172185Simp# PLATFORM_MODULES are modules defined by the platform loader
33113515Strhodes# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
34113515Strhodes#
35113515Strhodes# All other modules not declared below are defined by the application loader
36172185Simp# and are not included in JRE.
37172185Simp
38172185SimpBOOT_MODULES :=
39172185SimpPLATFORM_MODULES :=
40172185SimpJRE_TOOL_MODULES :=
41113515StrhodesUPGRADEABLE_MODULES :=
42113515StrhodesAGGREGATOR_MODULES :=
43113515Strhodes
44172185Simp# Hook to include the corresponding custom file, if present.
45172185Simp$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
46172185Simp
47113515StrhodesBOOT_MODULES += \
48172185Simp    java.base \
49113515Strhodes    java.datatransfer \
50172185Simp    java.desktop \
51172185Simp    java.httpclient \
52172185Simp    java.instrument \
53113515Strhodes    java.logging \
54113515Strhodes    java.management \
55172185Simp    java.naming \
56113515Strhodes    java.prefs \
57172185Simp    java.rmi \
58172185Simp    java.security.jgss \
59172185Simp    java.security.sasl \
60172185Simp    java.xml \
61172185Simp    jdk.httpserver \
62172185Simp    jdk.management \
63172185Simp    jdk.net \
64172185Simp    jdk.sctp \
65172185Simp    jdk.security.auth \
66172185Simp    jdk.security.jgss \
67113515Strhodes    jdk.unsupported \
68172185Simp    jdk.vm.ci \
69172185Simp    #
70172185Simp
71172185Simp# to be deprivileged
72172185SimpBOOT_MODULES += \
73172185Simp    jdk.naming.rmi \
74172185Simp    #
75172185Simp
76113515StrhodesUPGRADEABLE_MODULES += \
77172185Simp    java.activation \
78172185Simp    java.annotations.common \
79172185Simp    java.corba \
80113515Strhodes    java.transaction \
81113515Strhodes    java.xml.bind \
82113515Strhodes    java.xml.ws \
83172185Simp    #
84172185Simp
85172185Simp# Modules explicitly declared as not being upgradeable even though they require
86172185Simp# an upgradeable module.
87172185SimpNON_UPGRADEABLE_MODULES +=
88172185Simp
89172185SimpAGGREGATOR_MODULES += \
90172185Simp    java.compact1 \
91172185Simp    java.compact2 \
92113515Strhodes    java.compact3 \
93113515Strhodes    java.se \
94113515Strhodes    java.se.ee \
95172185Simp    #
96113515Strhodes
97172185SimpPLATFORM_MODULES += \
98172185Simp    $(UPGRADEABLE_MODULES) \
99172185Simp    $(AGGREGATOR_MODULES)
100172185Simp    #
101172185Simp
102172185SimpPLATFORM_MODULES += \
103172185Simp    java.compiler \
104172185Simp    java.scripting \
105113515Strhodes    java.smartcardio \
106113515Strhodes    java.sql \
107113515Strhodes    java.sql.rowset \
108172185Simp    java.xml.crypto \
109172185Simp    jdk.accessibility \
110172185Simp    jdk.charsets \
111172185Simp    jdk.crypto.ec \
112172185Simp    jdk.crypto.pkcs11 \
113172185Simp    jdk.dynalink \
114113515Strhodes    jdk.jsobject \
115172185Simp    jdk.xml.dom \
116172185Simp    jdk.localedata \
117172185Simp    jdk.naming.dns \
118172185Simp    jdk.scripting.nashorn \
119172185Simp    jdk.zipfs \
120172185Simp    #
121172185Simp
122172185SimpJRE_TOOL_MODULES += \
123172185Simp    jdk.jdwp.agent \
124172185Simp    jdk.pack200 \
125172185Simp    jdk.scripting.nashorn.shell \
126172185Simp    #
127172185Simp
128172185Simpifeq ($(OPENJDK_TARGET_OS), windows)
129172185Simp  PLATFORM_MODULES += jdk.crypto.mscapi
130172185Simpendif
131172185Simpifeq ($(OPENJDK_TARGET_OS), solaris)
132172185Simp  PLATFORM_MODULES += jdk.crypto.ucrypto
133172185Simpendif
134172185Simp
135172185Simp# These modules are included in the interim image which is used to run profiling
136172185Simp# before building the real images.
137172185SimpINTERIM_IMAGE_MODULES := java.base java.logging
138172185Simp
139172185Simp################################################################################
140172185Simp# Some platforms don't have the serviceability agent
141172185Simp
142172185Simpifeq ($(INCLUDE_SA), false)
143172185Simp  MODULES_FILTER += jdk.hotspot.agent
144172185Simpendif
145172185Simp
146172185Simp################################################################################
147172185Simp# Module list macros
148172185Simp
149172185Simp# Use append so that the custom extension may add to these variables
150172185Simp
151172185SimpGENERATED_SRC_DIRS += \
152172185Simp    $(SUPPORT_OUTPUTDIR)/gensrc \
153172185Simp    #
154172185Simp
155172185SimpTOP_SRC_DIRS += \
156172185Simp    $(CORBA_TOPDIR)/src \
157172185Simp    $(HOTSPOT_TOPDIR)/src \
158172185Simp    $(JDK_TOPDIR)/src \
159172185Simp    $(LANGTOOLS_TOPDIR)/src \
160172185Simp    $(JAXP_TOPDIR)/src \
161172185Simp    $(JAXWS_TOPDIR)/src \
162172185Simp    $(NASHORN_TOPDIR)/src \
163172185Simp    #
164172185Simp
165172185SimpSRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
166172185Simpifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
167172185Simp  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
168172185Simpendif
169172185SimpSRC_SUBDIRS += share/classes
170172185Simp
171172185Simp# Find all module-info.java files for the current build target platform and
172172185Simp# configuration.
173172185Simp# Param 1 - Module to find for, set to * for finding all
174172185SimpFindAllModuleInfos = \
175172185Simp    $(wildcard \
176172185Simp        $(foreach sub, $(SRC_SUBDIRS), \
177172185Simp          $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
178172185Simp        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
179172185Simp
180172185Simp# Extract the module names from the paths of module-info.java files. The
181172185Simp# position of the module directory differs depending on if this is an imported
182172185Simp# src dir or not.
183172185SimpGetModuleNameFromModuleInfo = \
184172185Simp    $(strip $(foreach mi, $1, \
185172185Simp      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
186172185Simp        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
187172185Simp        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
188172185Simp
189172185Simp# Find all modules by looking for module-info.java files and looking at parent
190172185Simp# directories.
191172185SimpFindAllModules = \
192172185Simp    $(sort $(filter-out $(MODULES_FILTER), \
193172185Simp    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
194172185Simp
195172185SimpFindImportedModules = \
196172185Simp    $(filter-out $(MODULES_FILTER), \
197172185Simp    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
198172185Simp
199172185Simp# Find all source dirs for a particular module
200172185Simp# $1 - Module to find source dirs for
201172185SimpFindModuleSrcDirs = \
202172185Simp    $(strip $(wildcard \
203172185Simp        $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
204172185Simp        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
205172185Simp
206172185Simp# Construct the complete module source path
207172185SimpGetModuleSrcPath = \
208172185Simp    $(call PathList, \
209172185Simp        $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
210172185Simp        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
211172185Simp
212172185Simp################################################################################
213172185Simp# Extract module dependencies from module-info.java files.
214172185Simp
215172185SimpMODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
216172185Simp
217172185SimpMODULE_INFOS := $(call FindAllModuleInfos, *)
218172185Simp
219172185Simp$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
220172185Simp    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
221172185Simp	$(MKDIR) -p $(@D)
222172185Simp	$(RM) $@
223172185Simp	$(foreach m, $(MODULE_INFOS), \
224172185Simp	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
225172185Simp	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
226172185Simp	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
227172185Simp	          /requires/ { sub(/;/, ""); \
228172185Simp	                       sub(/requires/, ""); \
229172185Simp	                       sub(/public/, ""); \
230172185Simp	                       sub(/\/\/.*/, ""); \
231172185Simp	                       sub(/\/\*.*\*\//, ""); \
232172185Simp	                       gsub(/ /, ""); \
233172185Simp	                       printf(" %s", $$0) } \
234172185Simp	          END        { printf("\n") }' $m \
235172185Simp	    ) >> $@ $(NEWLINE))
236172185Simp
237172185Simp-include $(MODULE_DEPS_MAKEFILE)
238172185Simp
239172185Simp# Param 1: Module to find deps for
240172185SimpFindDepsForModule = \
241172185Simp  $(DEPS_$(strip $1))
242172185Simp
243172185Simp# Finds transitive dependencies in 3 levels.
244172185Simp# Param 1: Module to find transitive deps for
245172185SimpFindTransitiveDepsForModule = \
246172185Simp    $(sort $(call FindDepsForModule, $1) \
247172185Simp        $(foreach m, $(call FindDepsForModule, $1), \
248172185Simp            $(call FindDepsForModule, $m) \
249172185Simp            $(foreach n, $(call FindDepsForModule, $m), \
250172185Simp                 $(call FindDepsForModule, $n))))
251172185Simp
252172185Simp# Upgradeable modules are those that are either defined as upgradeable or that
253172185Simp# require an upradeable module.
254172185SimpFindAllUpgradeableModules = \
255172185Simp    $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
256113515Strhodes        $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
257172185Simp            $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
258172185Simp          $(if $(filter $(UPGRADEABLE_MODULES), \
259172185Simp              $(call FindTransitiveDepsForModule, $m)), \
260172185Simp            $m \
261172185Simp          ) \
262172185Simp        )) \
263172185Simp    )
264172185Simp
265172185Simp################################################################################
266172185Simp
267172185Simp# Param 1 - Name of module
268172185Simpdefine ReadSingleImportMetaData
269172185Simp    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
270172185Simp      classloader :=
271113515Strhodes      include_in_jre :=
272113515Strhodes      include_in_jdk :=
273172185Simp      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
274172185Simp      ifeq ($$(include_in_jre), true)
275113515Strhodes        JRE_MODULES += $1
276172185Simp      endif
277172185Simp      ifeq ($$(include_in_jdk), true)
278172185Simp        JDK_MODULES += $1
279172185Simp      endif
280172185Simp      ifeq ($$(classloader), boot)
281172185Simp        BOOT_MODULES += $1
282172185Simp      else ifeq ($$(classloader), ext)
283172185Simp        PLATFORM_MODULES += $1
284172185Simp      endif
285113515Strhodes    else
286172185Simp      # Default to include in all
287211397Sjoel      JRE_MODULES += $1
288172185Simp      JDK_MODULES += $1
289113515Strhodes    endif
290113515Strhodesendef
291113515Strhodes
292113515Strhodes# Reading the imported modules metadata has a cost, so to make it available,
293166798Strhodes# a makefile needs to eval-call this macro first. After calling this, the
294113515Strhodes# following variables are populated with data from the imported modules:
295113515Strhodes# * JRE_MODULES
296113515Strhodes# * JDK_MODULES
297113515Strhodes# * BOOT_MODULES
298113515Strhodes# * PLATFORM_MODULES
299172185Simp# * JRE_TOOL_MODULES
300172185Simpdefine ReadImportMetaData
301172185Simp    IMPORTED_MODULES := $$(call FindImportedModules)
302172185Simp    $$(foreach m, $$(IMPORTED_MODULES), \
303172185Simp      $$(eval $$(call ReadSingleImportMetaData, $$m)))
304172185Simpendef
305172185Simp
306172185Simp################################################################################
307172185Simp
308172185Simpendif # _MODULES_GMK
309172185Simp