Modules.gmk revision 2645:d273234a040d
11573Srgrimes#
2285140Soshogbo# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
3285140Soshogbo# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4285140Soshogbo#
51573Srgrimes# This code is free software; you can redistribute it and/or modify it
61573Srgrimes# under the terms of the GNU General Public License version 2 only, as
71573Srgrimes# published by the Free Software Foundation.  Oracle designates this
81573Srgrimes# particular file as subject to the "Classpath" exception as provided
91573Srgrimes# by Oracle in the LICENSE file that accompanied this code.
101573Srgrimes#
111573Srgrimes# This code is distributed in the hope that it will be useful, but WITHOUT
121573Srgrimes# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131573Srgrimes# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
141573Srgrimes# version 2 for more details (a copy is included in the LICENSE file that
151573Srgrimes# accompanied this code).
161573Srgrimes#
17249808Semaste# You should have received a copy of the GNU General Public License version
181573Srgrimes# 2 along with this work; if not, write to the Free Software Foundation,
191573Srgrimes# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
201573Srgrimes#
211573Srgrimes# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
221573Srgrimes# or visit www.oracle.com if you need additional information or have any
231573Srgrimes# questions.
241573Srgrimes#
251573Srgrimes
261573Srgrimesifndef _MODULES_GMK
271573Srgrimes_MODULES_GMK := 1
281573Srgrimes
291573Srgrimes################################################################################
301573Srgrimes#
311573Srgrimes# BOOT_MODULES are modules defined by the boot loader
321573Srgrimes# PLATFORM_MODULES are modules defined by the platform loader
331573Srgrimes# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
341573Srgrimes#
351573Srgrimes# All other modules not declared below are defined by the application loader
361573Srgrimes# and are not included in JRE.
3792986Sobrien
3892986SobrienBOOT_MODULES :=
391573SrgrimesPLATFORM_MODULES :=
4071579SdeischenJRE_TOOL_MODULES :=
411573SrgrimesUPGRADEABLE_MODULES :=
42285140SoshogboAGGREGATOR_MODULES :=
431573SrgrimesDOCS_MODULES :=
441573Srgrimes
4571579Sdeischen# Hook to include the corresponding custom file, if present.
46234657Skib$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
4771579Sdeischen
481573SrgrimesBOOT_MODULES += \
491573Srgrimes    java.base \
50285140Soshogbo    java.datatransfer \
51285140Soshogbo    java.desktop \
521573Srgrimes    java.instrument \
5371579Sdeischen    java.logging \
541573Srgrimes    java.management \
55285140Soshogbo    java.management.rmi \
56285140Soshogbo    java.naming \
57285140Soshogbo    java.prefs \
58285140Soshogbo    java.rmi \
591573Srgrimes    java.security.sasl \
60285140Soshogbo    java.xml \
611573Srgrimes    jdk.httpserver \
621573Srgrimes    jdk.internal.vm.ci \
631573Srgrimes    jdk.management \
641573Srgrimes    jdk.management.agent \
651573Srgrimes    jdk.net \
661573Srgrimes    jdk.sctp \
6713545Sjulian    jdk.unsupported \
681573Srgrimes    #
69234657Skib
70234657Skib# to be deprivileged
71234657SkibBOOT_MODULES += \
72234657Skib    jdk.naming.rmi \
73234657Skib    #
74234657Skib
75234657SkibUPGRADEABLE_MODULES += \
76234657Skib    java.activation \
77234657Skib    java.corba \
78234657Skib    java.transaction \
79234657Skib    java.xml.bind \
80234657Skib    java.xml.ws \
8153529Sdt    java.xml.ws.annotation \
82234657Skib    jdk.internal.vm.compiler \
83285140Soshogbo    #
84285140Soshogbo
85285140Soshogbo# Modules explicitly declared as not being upgradeable even though they require
86285140Soshogbo# an upgradeable module.
87285140SoshogboNON_UPGRADEABLE_MODULES += \
88285140Soshogbo    jdk.aot \
89285140Soshogbo    #
90285140Soshogbo
91285140SoshogboAGGREGATOR_MODULES += \
92285140Soshogbo    java.se \
93285140Soshogbo    java.se.ee \
94285140Soshogbo    #
95285140Soshogbo
96285140SoshogboPLATFORM_MODULES += \
97285140Soshogbo    $(UPGRADEABLE_MODULES) \
98285140Soshogbo    $(AGGREGATOR_MODULES)
99285140Soshogbo    #
100320942Skib
101285140SoshogboPLATFORM_MODULES += \
102285140Soshogbo    java.compiler \
103285140Soshogbo    java.scripting \
104285140Soshogbo    java.security.jgss \
105285140Soshogbo    java.smartcardio \
106285140Soshogbo    java.sql \
107285140Soshogbo    java.sql.rowset \
108285140Soshogbo    java.xml.crypto \
109285140Soshogbo    jdk.accessibility \
110285140Soshogbo    jdk.charsets \
111285140Soshogbo    jdk.crypto.cryptoki \
112285140Soshogbo    jdk.crypto.ec \
113285140Soshogbo    jdk.dynalink \
114285140Soshogbo    jdk.incubator.httpclient \
115285140Soshogbo    jdk.jsobject \
116285140Soshogbo    jdk.localedata \
117285140Soshogbo    jdk.naming.dns \
118320942Skib    jdk.scripting.nashorn \
119285140Soshogbo    jdk.security.auth \
1201573Srgrimes    jdk.security.jgss \
1211573Srgrimes    jdk.xml.dom \
122285140Soshogbo    jdk.zipfs \
123285140Soshogbo    #
124285140Soshogbo
125285140Soshogboifeq ($(OPENJDK_TARGET_OS), windows)
126285140Soshogbo  PLATFORM_MODULES += jdk.crypto.mscapi
127285140Soshogboendif
128285140Soshogbo
129285140Soshogboifeq ($(OPENJDK_TARGET_OS), solaris)
130285140Soshogbo  PLATFORM_MODULES += jdk.crypto.ucrypto
131285140Soshogboendif
132285140Soshogbo
133320942SkibJRE_TOOL_MODULES += \
134285140Soshogbo    jdk.jdwp.agent \
135320942Skib    jdk.pack \
136285140Soshogbo    jdk.scripting.nashorn.shell \
137285140Soshogbo    #
138285140Soshogbo
139################################################################################
140
141# DOCS_MODULES defines the root modules for javadoc generation.
142# All of their `require transitive` modules directly and indirectly will be included.
143DOCS_MODULES += \
144    java.se.ee \
145    java.smartcardio \
146    jdk.accessibility \
147    jdk.attach \
148    jdk.charsets \
149    jdk.compiler \
150    jdk.crypto.cryptoki \
151    jdk.crypto.ec \
152    jdk.dynalink \
153    jdk.editpad \
154    jdk.hotspot.agent \
155    jdk.httpserver \
156    jdk.incubator.httpclient \
157    jdk.jartool \
158    jdk.javadoc \
159    jdk.jcmd \
160    jdk.jconsole \
161    jdk.jdeps \
162    jdk.jdi \
163    jdk.jdwp.agent \
164    jdk.jlink \
165    jdk.jsobject \
166    jdk.jshell \
167    jdk.jstatd \
168    jdk.localedata \
169    jdk.management \
170    jdk.management.agent \
171    jdk.naming.dns \
172    jdk.naming.rmi \
173    jdk.net \
174    jdk.pack \
175    jdk.policytool \
176    jdk.rmic \
177    jdk.scripting.nashorn \
178    jdk.sctp \
179    jdk.security.auth \
180    jdk.security.jgss \
181    jdk.xml.dom \
182    jdk.zipfs \
183    #
184
185# These modules are included in the interim image which is used to run profiling
186# before building the real images.
187INTERIM_IMAGE_MODULES := java.base java.logging
188
189################################################################################
190# Some platforms don't have the serviceability agent
191
192ifeq ($(INCLUDE_SA), false)
193  MODULES_FILTER += jdk.hotspot.agent
194endif
195
196################################################################################
197# Filter out Graal specific modules if Graal build is disabled
198
199ifeq ($(INCLUDE_GRAAL), false)
200  MODULES_FILTER += jdk.internal.vm.compiler
201endif
202
203################################################################################
204# Filter out aot specific modules if aot is disabled
205
206ifeq ($(ENABLE_AOT), false)
207  MODULES_FILTER += jdk.aot
208endif
209
210################################################################################
211# Module list macros
212
213# Use append so that the custom extension may add to these variables
214
215GENERATED_SRC_DIRS += \
216    $(SUPPORT_OUTPUTDIR)/gensrc \
217    #
218
219TOP_SRC_DIRS += \
220    $(CORBA_TOPDIR)/src \
221    $(HOTSPOT_TOPDIR)/src \
222    $(JDK_TOPDIR)/src \
223    $(LANGTOOLS_TOPDIR)/src \
224    $(JAXP_TOPDIR)/src \
225    $(JAXWS_TOPDIR)/src \
226    $(NASHORN_TOPDIR)/src \
227    #
228
229SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
230ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
231  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
232endif
233SRC_SUBDIRS += share/classes
234
235SPEC_SUBDIRS += share/specs
236
237# Find all module-info.java files for the current build target platform and
238# configuration.
239# Param 1 - Module to find for, set to * for finding all
240FindAllModuleInfos = \
241    $(wildcard \
242        $(foreach sub, $(SRC_SUBDIRS), \
243          $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
244        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
245
246# Find module-info.java files in the specific source dir
247# Param 1 - Src dir to find module-info.java files in
248FindModuleInfosForSrcDir = \
249    $(wildcard \
250        $(foreach sub, $(SRC_SUBDIRS), \
251          $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
252        ) \
253        $(patsubst %,%/*/module-info.java, $(strip $1)) \
254    )
255
256# Extract the module names from the paths of module-info.java files. The
257# position of the module directory differs depending on if this is an imported
258# src dir or not.
259GetModuleNameFromModuleInfo = \
260    $(strip $(foreach mi, $1, \
261      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
262        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
263        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
264
265# Find all modules by looking for module-info.java files and looking at parent
266# directories.
267FindAllModules = \
268    $(sort $(filter-out $(MODULES_FILTER), \
269    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
270
271# Find all modules in a specific src dir
272# Param 1 - Src dir to find modules in
273FindModulesForSrcDir = \
274    $(sort $(filter-out $(MODULES_FILTER), \
275        $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
276    ))
277
278FindImportedModules = \
279    $(filter-out $(MODULES_FILTER), \
280    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
281
282# Find all source dirs for a particular module
283# $1 - Module to find source dirs for
284FindModuleSrcDirs = \
285    $(strip $(wildcard \
286        $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
287        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
288
289# Find all specs dirs for a particular module
290# $1 - Module to find specs dirs for
291FindModuleSpecsDirs = \
292    $(strip $(wildcard \
293        $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
294
295# Construct the complete module source path
296GetModuleSrcPath = \
297    $(call PathList, \
298        $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
299        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
300
301################################################################################
302# Extract module dependencies from module-info.java files, both normal
303# dependencies ("requires"), and indirect exports ("requires transitive").
304
305MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
306
307MODULE_INFOS := $(call FindAllModuleInfos, *)
308
309$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
310    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
311	$(MKDIR) -p $(@D)
312	$(RM) $@
313	$(foreach m, $(MODULE_INFOS), \
314	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
315	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
316	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
317	          /^ *requires/ { sub(/;/, ""); \
318	                          sub(/requires/, ""); \
319	                          sub(/transitive/, ""); \
320	                          sub(/\/\/.*/, ""); \
321	                          sub(/\/\*.*\*\//, ""); \
322	                          gsub(/^ +\*.*/, ""); \
323	                          gsub(/ /, ""); \
324	                          printf(" %s", $$0) } \
325	          END           { printf("\n") }' $m && \
326	      $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \
327	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
328	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
329	          /^ *requires  *transitive/ { \
330	                          sub(/;/, ""); \
331	                          sub(/requires/, ""); \
332	                          sub(/transitive/, ""); \
333	                          sub(/\/\/.*/, ""); \
334	                          sub(/\/\*.*\*\//, ""); \
335	                          gsub(/^ +\*.*/, ""); \
336	                          gsub(/ /, ""); \
337	                          printf(" %s", $$0) } \
338	          END           { printf("\n") }' $m \
339	    ) >> $@ $(NEWLINE))
340
341-include $(MODULE_DEPS_MAKEFILE)
342
343# Find dependencies ("requires") for a given module.
344# Param 1: Module to find dependencies for.
345FindDepsForModule = \
346  $(DEPS_$(strip $1))
347
348# Find dependencies ("requires") transitively in 3 levels for a given module.
349# Param 1: Module to find dependencies for.
350FindTransitiveDepsForModule = \
351    $(sort $(call FindDepsForModule, $1) \
352        $(foreach m, $(call FindDepsForModule, $1), \
353            $(call FindDepsForModule, $m) \
354            $(foreach n, $(call FindDepsForModule, $m), \
355                 $(call FindDepsForModule, $n))))
356
357# Find dependencies ("requires") transitively in 3 levels for a set of modules.
358# Param 1: List of modules to find dependencies for.
359FindTransitiveDepsForModules = \
360    $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
361
362# Find indirect exported modules ("requires transitive") for a given module .
363# Param 1: Module to find indirect exported modules for.
364FindIndirectExportsForModule = \
365  $(TRANSITIVE_MODULES_$(strip $1))
366
367# Finds indirect exported modules transitively in 3 levels for a given module.
368# Param 1: Module to find indirect exported modules for.
369FindTransitiveIndirectDepsForModule = \
370    $(sort $(call FindIndirectExportsForModule, $1) \
371        $(foreach m, $(call FindIndirectExportsForModule, $1), \
372            $(call FindIndirectExportsForModule, $m) \
373            $(foreach n, $(call FindIndirectExportsForModule, $m), \
374                 $(call FindIndirectExportsForModule, $n))))
375
376# Finds indirect exported modules transitively in 3 levels for a set of modules.
377# Param 1: List of modules to find indirect exported modules for.
378FindTransitiveIndirectDepsForModules = \
379    $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m)))
380
381# Upgradeable modules are those that are either defined as upgradeable or that
382# require an upradeable module.
383FindAllUpgradeableModules = \
384    $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
385        $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
386            $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
387          $(if $(filter $(UPGRADEABLE_MODULES), \
388              $(call FindTransitiveDepsForModule, $m)), \
389            $m \
390          ) \
391        )) \
392    )
393
394################################################################################
395
396LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
397ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
398  LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
399endif
400LEGAL_SUBDIRS += share/legal
401
402# Find all legal dirs for a particular module
403# $1 - Module to find legal dirs for
404FindModuleLegalDirs = \
405    $(strip $(wildcard \
406        $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
407        $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
408
409################################################################################
410
411# Param 1 - Name of module
412define ReadSingleImportMetaData
413    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
414      classloader :=
415      include_in_jre :=
416      include_in_jdk :=
417      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
418      ifeq ($$(include_in_jre), true)
419        JRE_MODULES += $1
420      endif
421      ifeq ($$(include_in_jdk), true)
422        JDK_MODULES += $1
423      endif
424      ifeq ($$(classloader), boot)
425        BOOT_MODULES += $1
426      else ifeq ($$(classloader), ext)
427        PLATFORM_MODULES += $1
428      endif
429      ifneq ($$(include_in_docs), false)
430        # defaults to true if unspecified
431        DOCS_MODULES += $1
432      endif
433    else
434      # Default to include in all
435      JRE_MODULES += $1
436      JDK_MODULES += $1
437    endif
438endef
439
440# Reading the imported modules metadata has a cost, so to make it available,
441# a makefile needs to eval-call this macro first. After calling this, the
442# following variables are populated with data from the imported modules:
443# * JRE_MODULES
444# * JDK_MODULES
445# * BOOT_MODULES
446# * PLATFORM_MODULES
447# * JRE_TOOL_MODULES
448define ReadImportMetaData
449    IMPORTED_MODULES := $$(call FindImportedModules)
450    $$(foreach m, $$(IMPORTED_MODULES), \
451      $$(eval $$(call ReadSingleImportMetaData, $$m)))
452endef
453
454################################################################################
455
456endif # _MODULES_GMK
457