Modules.gmk revision 1975:e850a15d3ac6
1#
2# Copyright (c) 2014, 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
26ifndef _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
38BOOT_MODULES :=
39PLATFORM_MODULES :=
40JRE_TOOL_MODULES :=
41
42# Hook to include the corresponding custom file, if present.
43$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
44
45UPGRADEABLE_MDOULES :=
46AGGREGATOR_MDOULES :=
47
48BOOT_MODULES += \
49    java.base \
50    java.datatransfer \
51    java.desktop \
52    java.httpclient \
53    java.instrument \
54    java.logging \
55    java.management \
56    java.naming \
57    java.prefs \
58    java.rmi \
59    java.security.jgss \
60    java.security.sasl \
61    java.sql \
62    java.xml \
63    java.xml.crypto \
64    jdk.httpserver \
65    jdk.management \
66    jdk.sctp \
67    jdk.security.auth \
68    jdk.security.jgss \
69    #
70
71# to be deprivileged
72BOOT_MODULES += \
73    java.compiler \
74    java.scripting \
75    java.sql.rowset \
76    java.smartcardio \
77    jdk.charsets \
78    jdk.naming.rmi \
79    #
80
81UPGRADEABLE_MODULES += \
82    java.activation \
83    java.annotations.common \
84    java.corba \
85    java.transaction \
86    java.xml.bind \
87    java.xml.ws \
88    #
89
90AGGREGATOR_MODULES += \
91    java.compact1 \
92    java.compact2 \
93    java.compact3 \
94    java.se \
95    java.se.ee \
96    #
97
98PLATFORM_MODULES += \
99    $(UPGRADEABLE_MODULES) \
100    $(AGGREGATOR_MODULES)
101    #
102
103PLATFORM_MODULES += \
104    jdk.accessibility \
105    jdk.crypto.ec \
106    jdk.crypto.pkcs11 \
107    jdk.dynalink \
108    jdk.jsobject \
109    jdk.xml.dom \
110    jdk.localedata \
111    jdk.naming.dns \
112    jdk.scripting.nashorn \
113    jdk.zipfs \
114    #
115
116JRE_TOOL_MODULES += \
117    jdk.pack200 \
118    jdk.scripting.nashorn.shell \
119    #
120
121ifeq ($(OPENJDK_TARGET_OS), windows)
122  PLATFORM_MODULES += jdk.crypto.mscapi
123endif
124ifeq ($(OPENJDK_TARGET_OS), solaris)
125  PLATFORM_MODULES += jdk.crypto.ucrypto
126endif
127
128################################################################################
129# Some platforms don't have the serviceability agent
130
131ifeq ($(INCLUDE_SA), false)
132  MODULES_FILTER += jdk.hotspot.agent
133endif
134
135################################################################################
136# Module list macros
137
138# Use append so that the custom extension may add to this variable
139
140ALL_TOP_SRC_DIRS += \
141    $(HOTSPOT_TOPDIR)/src \
142    $(JDK_TOPDIR)/src \
143    $(LANGTOOLS_TOPDIR)/src \
144    $(CORBA_TOPDIR)/src \
145    $(JAXP_TOPDIR)/src \
146    $(JAXWS_TOPDIR)/src \
147    $(NASHORN_TOPDIR)/src \
148    #
149
150# Find all module-info.java files for the current build target platform and
151# configuration.
152# Param 1 - Module to find for, set to * for finding all
153FindAllModuleInfos = \
154    $(wildcard \
155        $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
156        $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
157        $(patsubst %,%/$(strip $1)/share/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
158        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
159
160# Extract the module names from the paths of module-info.java files. The
161# position of the module directory differs depending on if this is an imported
162# src dir or not.
163GetModuleNameFromModuleInfo = \
164    $(strip $(foreach mi, $1, \
165      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
166        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
167        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
168
169# Find all modules by looking for module-info.java files and looking at parent
170# directories.
171FindAllModules = \
172    $(sort $(filter-out $(MODULES_FILTER), \
173    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
174
175FindImportedModules = \
176    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))
177
178################################################################################
179# Extract module dependencies from module-info.java files.
180
181MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
182
183MODULE_INFOS := $(call FindAllModuleInfos, *)
184
185$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
186    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
187	$(MKDIR) -p $(@D)
188	$(RM) $@
189	$(foreach m, $(MODULE_INFOS), \
190	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
191	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
192	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
193	          /requires/ { sub(/;/, ""); \
194	                       sub(/requires/, ""); \
195	                       sub(/public/, ""); \
196	                       sub(/\/\/.*/, ""); \
197	                       sub(/\/\*.*\*\//, ""); \
198	                       gsub(/ /, ""); \
199	                       printf(" %s", $$0) } \
200	          END        { printf("\n") }' $m \
201	    ) >> $@ $(NEWLINE))
202
203-include $(MODULE_DEPS_MAKEFILE)
204
205# Param 1: Module to find deps for
206FindDepsForModule = \
207  $(DEPS_$(strip $1))
208
209# Finds transitive dependencies in 3 levels.
210# Param 1: Module to find transitive deps for
211FindTransitiveDepsForModule = \
212    $(sort $(call FindDepsForModule, $1) \
213        $(foreach m, $(call FindDepsForModule, $1), \
214            $(call FindDepsForModule, $m) \
215            $(foreach n, $(call FindDepsForModule, $m), \
216                 $(call FindDepsForModule, $n))))
217
218################################################################################
219
220# Param 1 - Name of module
221define ReadSingleImportMetaData
222    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
223      classloader :=
224      include_in_jre :=
225      include_in_jdk :=
226      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
227      ifeq ($$(include_in_jre), true)
228        JRE_MODULES += $1
229      endif
230      ifeq ($$(include_in_jdk), true)
231        JDK_MODULES += $1
232      endif
233      ifeq ($$(classloader), boot)
234        BOOT_MODULES += $1
235      else ifeq ($$(classloader), ext)
236        PLATFORM_MODULES += $1
237      endif
238    else
239      # Default to include in all
240      JRE_MODULES += $1
241      JDK_MODULES += $1
242    endif
243endef
244
245# Reading the imported modules metadata has a cost, so to make it available,
246# a makefile needs to eval-call this macro first. After calling this, the
247# following variables are populated with data from the imported modules:
248# * JRE_MODULES
249# * JDK_MODULES
250# * BOOT_MODULES
251# * PLATFORM_MODULES
252# * JRE_TOOL_MODULES
253define ReadImportMetaData
254    IMPORTED_MODULES := $(call FindImportedModules)
255    $(foreach m, $(IMPORTED_MODULES), $(eval $(call ReadImportMetaData, $m)))
256endef
257
258################################################################################
259
260endif # _MODULES_GMK
261