CreateJmods.gmk revision 2515:9a27a9527866
1314817Sngie
2272343Sngie# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3272343Sngie# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4272343Sngie#
5272343Sngie# This code is free software; you can redistribute it and/or modify it
6272343Sngie# under the terms of the GNU General Public License version 2 only, as
7272343Sngie# published by the Free Software Foundation.  Oracle designates this
8272343Sngie# particular file as subject to the "Classpath" exception as provided
9272343Sngie# by Oracle in the LICENSE file that accompanied this code.
10272343Sngie#
11272343Sngie# This code is distributed in the hope that it will be useful, but WITHOUT
12272343Sngie# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13272343Sngie# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14272343Sngie# version 2 for more details (a copy is included in the LICENSE file that
15272343Sngie# accompanied this code).
16272343Sngie#
17272343Sngie# You should have received a copy of the GNU General Public License version
18272343Sngie# 2 along with this work; if not, write to the Free Software Foundation,
19272343Sngie# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20272343Sngie#
21272343Sngie# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22272343Sngie# or visit www.oracle.com if you need additional information or have any
23272343Sngie# questions.
24314817Sngie#
25272343Sngie
26272343Sngiedefault: all
27272343Sngie
28272343Sngieinclude $(SPEC)
29272343Sngieinclude MakeBase.gmk
30272343Sngieinclude Modules.gmk
31272343Sngie
32272343Sngieifeq ($(MODULE), )
33272343Sngie  $(error MODULE must be set when calling CreateJmods.gmk)
34272343Sngieendif
35272343Sngie
36272343Sngie################################################################################
37272343Sngie
38272343SngieJMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
39272343SngieJMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
40272343Sngie
41272343SngieLIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
42272343Sngie    $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
43272343SngieCMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
44272343Sngie    $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
45272343SngieCONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
46272343Sngie    $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
47272343SngieCLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
48272343SngieINCLUDE_HEADERS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
49272343Sngie    $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
50272343SngieMAN_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
51272343Sngie    $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
52272343Sngie
53272343Sngie$(eval $(call FillCacheFind, \
54272343Sngie    $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \
55272343Sngie))
56272343Sngie
57272343Sngieifneq ($(LIBS_DIR), )
58272343Sngie  JMOD_FLAGS += --libs $(LIBS_DIR)
59272343Sngie  DEPS += $(call CacheFind, $(LIBS_DIR))
60272343Sngieendif
61272343Sngieifneq ($(CMDS_DIR), )
62272343Sngie  JMOD_FLAGS += --cmds $(CMDS_DIR)
63272343Sngie  DEPS += $(call CacheFind, $(CMDS_DIR))
64272343Sngieendif
65272343Sngieifneq ($(CONF_DIR), )
66272343Sngie  JMOD_FLAGS += --config $(CONF_DIR)
67272343Sngie  DEPS += $(call CacheFind, $(CONF_DIR))
68272343Sngieendif
69272343Sngieifneq ($(CLASSES_DIR), )
70272343Sngie  JMOD_FLAGS += --class-path $(CLASSES_DIR)
71272343Sngie  DEPS += $(call CacheFind, $(CLASSES_DIR))
72272343Sngieendif
73272343Sngieifneq ($(INCLUDE_HEADERS_DIR), )
74272343Sngie  JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR)
75272343Sngie  DEPS += $(call CacheFind, $(INCLUDE_HEADERS_DIR))
76272343Sngieendif
77272343Sngieifneq ($(MAN_DIR), )
78272343Sngie  JMOD_FLAGS += --man-pages $(MAN_DIR)
79272343Sngie  DEPS += $(call CacheFind, $(MAN_DIR))
80272343Sngieendif
81272343Sngie
82272343SngieLEGAL_NOTICES := \
83272343Sngie    $(SUPPORT_OUTPUTDIR)/modules_legal/java.base \
84272343Sngie    $(call FindModuleLegalDirs, $(MODULE)) \
85272343Sngie    #
86272343Sngie
87272343SngieLEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
88272343SngieDEPS += $(call CacheFind, $(LEGAL_NOTICES))
89272343Sngie
90272343SngieJMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH)
91272343Sngie
92272343Sngieifeq ($(filter-out jdk.incubator.%, $(MODULE)), )
93272343Sngie  JMOD_FLAGS += --do-not-resolve-by-default
94272343Sngie  JMOD_FLAGS += --warn-if-resolved=incubating
95272343Sngieendif
96272343Sngie
97272343Sngie# Add dependencies on other jmod files. Only java.base needs access to other
98272343Sngie# jmods.
99272343Sngieifeq ($(MODULE), java.base)
100272343Sngie  # When creating a BUILDJDK, we don't need to add hashes to java.base
101272343Sngie  ifneq ($(CREATING_BUILDJDK), true)
102272343Sngie    # When creating interim versions of jmods, skip hashes
103272343Sngie    ifneq ($(INTERIM_JMOD), true)
104272343Sngie      ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
105272343Sngie      DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
106272343Sngie          $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
107272343Sngie
108272343Sngie      EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
109272343Sngie
110272343Sngie      JMOD_FLAGS += --module-path $(JMODS_DIR) \
111272343Sngie          --hash-modules '^(?!$(EXCLUDE_PATTERN))'
112272343Sngie    endif
113272343Sngie  endif
114272343Sngieendif
115272343Sngie
116272343Sngie# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
117272343Sngie# The variable JMOD_CMD could contain an environment variable assignment before
118272343Sngie# the actual command. Filter that out using wildcard before adding to DEPS.
119272343SngieDEPS += $(wildcard $(JMOD_CMD))
120272343Sngieifeq ($(EXTERNAL_BUILDJDK), false)
121272343Sngie  DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
122272343Sngieendif
123272343Sngie
124272343Sngie# If creating interim versions of jmods, certain files need to be filtered out
125272343Sngie# to avoid false incremental rebuilds.
126272343Sngieifeq ($(INTERIM_JMOD), true)
127272343Sngie  DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
128272343Sngieendif
129272343Sngie
130272343Sngie# Create jmods in a temp dir and then move them into place to keep the
131272343Sngie# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
132272343Sngie$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
133272343Sngie	$(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
134272343Sngie	$(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
135272343Sngie	$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
136272343Sngie	$(JMOD) create \
137272343Sngie            --module-version $(VERSION_SHORT) \
138272343Sngie            --os-name $(REQUIRED_OS_NAME) \
139272343Sngie            --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \
140272343Sngie            --os-version $(REQUIRED_OS_VERSION) \
141272343Sngie            --module-path $(JMODS_DIR) \
142272343Sngie	    --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
143272343Sngie	    $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
144272343Sngie	$(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
145272343Sngie
146272343SngieTARGETS += $(JMODS_DIR)/$(MODULE).jmod
147272343Sngie
148272343Sngie################################################################################
149272343Sngie
150272343Sngieall: $(TARGETS)
151272343Sngie
152272343Sngie################################################################################
153272343Sngie