Modules.gmk revision 2046:a36a877e7624
1238535Sgnn#
2238535Sgnn# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3238535Sgnn# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4238535Sgnn#
5238535Sgnn# This code is free software; you can redistribute it and/or modify it
6238535Sgnn# under the terms of the GNU General Public License version 2 only, as
7238535Sgnn# published by the Free Software Foundation.  Oracle designates this
8238535Sgnn# particular file as subject to the "Classpath" exception as provided
9238535Sgnn# by Oracle in the LICENSE file that accompanied this code.
10238535Sgnn#
11238535Sgnn# This code is distributed in the hope that it will be useful, but WITHOUT
12238535Sgnn# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13238535Sgnn# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14238535Sgnn# version 2 for more details (a copy is included in the LICENSE file that
15238535Sgnn# accompanied this code).
16238535Sgnn#
17238535Sgnn# You should have received a copy of the GNU General Public License version
18238535Sgnn# 2 along with this work; if not, write to the Free Software Foundation,
19238535Sgnn# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20238535Sgnn#
21238535Sgnn# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22238535Sgnn# or visit www.oracle.com if you need additional information or have any
23238535Sgnn# questions.
24238535Sgnn#
25238535Sgnn
26238535Sgnnifndef _MODULES_GMK
27238535Sgnn_MODULES_GMK := 1
28238535Sgnn
29238535Sgnn################################################################################
30238535Sgnn#
31238535Sgnn# BOOT_MODULES are modules defined by the boot loader
32238535Sgnn# PLATFORM_MODULES are modules defined by the platform loader
33238535Sgnn# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
34238535Sgnn#
35238535Sgnn# All other modules not declared below are defined by the application loader
36238535Sgnn# and are not included in JRE.
37238535Sgnn
38238535SgnnBOOT_MODULES :=
39238535SgnnPLATFORM_MODULES :=
40238535SgnnJRE_TOOL_MODULES :=
41238535SgnnUPGRADEABLE_MODULES :=
42238535SgnnAGGREGATOR_MODULES :=
43238535Sgnn
44238535Sgnn# Hook to include the corresponding custom file, if present.
45238535Sgnn$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
46238535Sgnn
47238535SgnnBOOT_MODULES += \
48238535Sgnn    java.base \
49238535Sgnn    java.datatransfer \
50238535Sgnn    java.desktop \
51238535Sgnn    java.httpclient \
52238535Sgnn    java.instrument \
53238535Sgnn    java.logging \
54238535Sgnn    java.management \
55238535Sgnn    java.naming \
56238535Sgnn    java.prefs \
57238535Sgnn    java.rmi \
58238535Sgnn    java.security.jgss \
59238535Sgnn    java.security.sasl \
60238535Sgnn    java.sql \
61238535Sgnn    java.xml \
62238535Sgnn    java.xml.crypto \
63238535Sgnn    jdk.httpserver \
64238535Sgnn    jdk.management \
65238535Sgnn    jdk.sctp \
66238535Sgnn    jdk.security.auth \
67238535Sgnn    jdk.security.jgss \
68238535Sgnn    jdk.unsupported \
69238535Sgnn    jdk.vm.ci \
70238535Sgnn    #
71238535Sgnn
72238535Sgnn# to be deprivileged
73238535SgnnBOOT_MODULES += \
74238535Sgnn    java.compiler \
75    java.scripting \
76    java.sql.rowset \
77    java.smartcardio \
78    jdk.charsets \
79    jdk.naming.rmi \
80    #
81
82UPGRADEABLE_MODULES += \
83    java.activation \
84    java.annotations.common \
85    java.corba \
86    java.transaction \
87    java.xml.bind \
88    java.xml.ws \
89    #
90
91AGGREGATOR_MODULES += \
92    java.compact1 \
93    java.compact2 \
94    java.compact3 \
95    java.se \
96    java.se.ee \
97    #
98
99PLATFORM_MODULES += \
100    $(UPGRADEABLE_MODULES) \
101    $(AGGREGATOR_MODULES)
102    #
103
104PLATFORM_MODULES += \
105    jdk.accessibility \
106    jdk.crypto.ec \
107    jdk.crypto.pkcs11 \
108    jdk.dynalink \
109    jdk.jsobject \
110    jdk.xml.dom \
111    jdk.localedata \
112    jdk.naming.dns \
113    jdk.scripting.nashorn \
114    jdk.zipfs \
115    #
116
117JRE_TOOL_MODULES += \
118    jdk.jdwp.agent \
119    jdk.pack200 \
120    jdk.scripting.nashorn.shell \
121    #
122
123ifeq ($(OPENJDK_TARGET_OS), windows)
124  PLATFORM_MODULES += jdk.crypto.mscapi
125endif
126ifeq ($(OPENJDK_TARGET_OS), solaris)
127  PLATFORM_MODULES += jdk.crypto.ucrypto
128endif
129
130################################################################################
131# Some platforms don't have the serviceability agent
132
133ifeq ($(INCLUDE_SA), false)
134  MODULES_FILTER += jdk.hotspot.agent
135endif
136
137################################################################################
138# Module list macros
139
140# Use append so that the custom extension may add to these variables
141
142GENERATED_SRC_DIRS += \
143    $(SUPPORT_OUTPUTDIR)/gensrc \
144    #
145
146TOP_SRC_DIRS += \
147    $(CORBA_TOPDIR)/src \
148    $(HOTSPOT_TOPDIR)/src \
149    $(JDK_TOPDIR)/src \
150    $(LANGTOOLS_TOPDIR)/src \
151    $(JAXP_TOPDIR)/src \
152    $(JAXWS_TOPDIR)/src \
153    $(NASHORN_TOPDIR)/src \
154    #
155
156SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
157ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
158  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
159endif
160SRC_SUBDIRS += share/classes
161
162# Find all module-info.java files for the current build target platform and
163# configuration.
164# Param 1 - Module to find for, set to * for finding all
165FindAllModuleInfos = \
166    $(wildcard \
167        $(foreach sub, $(SRC_SUBDIRS), \
168          $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
169        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
170
171# Extract the module names from the paths of module-info.java files. The
172# position of the module directory differs depending on if this is an imported
173# src dir or not.
174GetModuleNameFromModuleInfo = \
175    $(strip $(foreach mi, $1, \
176      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
177        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
178        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
179
180# Find all modules by looking for module-info.java files and looking at parent
181# directories.
182FindAllModules = \
183    $(sort $(filter-out $(MODULES_FILTER), \
184    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
185
186FindImportedModules = \
187    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))
188
189# Find all source dirs for a particular module
190# $1 - Module to find source dirs for
191FindModuleSrcDirs = \
192    $(strip $(wildcard \
193        $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
194        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
195
196# Construct the complete module source path
197GetModuleSrcPath = \
198    $(call PathList, \
199        $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
200        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
201
202################################################################################
203# Extract module dependencies from module-info.java files.
204
205MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
206
207MODULE_INFOS := $(call FindAllModuleInfos, *)
208
209$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
210    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
211	$(MKDIR) -p $(@D)
212	$(RM) $@
213	$(foreach m, $(MODULE_INFOS), \
214	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
215	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
216	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
217	          /requires/ { sub(/;/, ""); \
218	                       sub(/requires/, ""); \
219	                       sub(/public/, ""); \
220	                       sub(/\/\/.*/, ""); \
221	                       sub(/\/\*.*\*\//, ""); \
222	                       gsub(/ /, ""); \
223	                       printf(" %s", $$0) } \
224	          END        { printf("\n") }' $m \
225	    ) >> $@ $(NEWLINE))
226
227-include $(MODULE_DEPS_MAKEFILE)
228
229# Param 1: Module to find deps for
230FindDepsForModule = \
231  $(DEPS_$(strip $1))
232
233# Finds transitive dependencies in 3 levels.
234# Param 1: Module to find transitive deps for
235FindTransitiveDepsForModule = \
236    $(sort $(call FindDepsForModule, $1) \
237        $(foreach m, $(call FindDepsForModule, $1), \
238            $(call FindDepsForModule, $m) \
239            $(foreach n, $(call FindDepsForModule, $m), \
240                 $(call FindDepsForModule, $n))))
241
242################################################################################
243
244# Param 1 - Name of module
245define ReadSingleImportMetaData
246    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
247      classloader :=
248      include_in_jre :=
249      include_in_jdk :=
250      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
251      ifeq ($$(include_in_jre), true)
252        JRE_MODULES += $1
253      endif
254      ifeq ($$(include_in_jdk), true)
255        JDK_MODULES += $1
256      endif
257      ifeq ($$(classloader), boot)
258        BOOT_MODULES += $1
259      else ifeq ($$(classloader), ext)
260        PLATFORM_MODULES += $1
261      endif
262    else
263      # Default to include in all
264      JRE_MODULES += $1
265      JDK_MODULES += $1
266    endif
267endef
268
269# Reading the imported modules metadata has a cost, so to make it available,
270# a makefile needs to eval-call this macro first. After calling this, the
271# following variables are populated with data from the imported modules:
272# * JRE_MODULES
273# * JDK_MODULES
274# * BOOT_MODULES
275# * PLATFORM_MODULES
276# * JRE_TOOL_MODULES
277define ReadImportMetaData
278    IMPORTED_MODULES := $$(call FindImportedModules)
279    $$(foreach m, $$(IMPORTED_MODULES), \
280      $$(eval $$(call ReadSingleImportMetaData, $$m)))
281endef
282
283################################################################################
284
285endif # _MODULES_GMK
286