CreateJmods.gmk revision 2663:abe884590f03
1 2# Copyright (c) 2014, 2016, 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 26default: all 27 28include $(SPEC) 29include MakeBase.gmk 30include Modules.gmk 31 32ifeq ($(MODULE), ) 33 $(error MODULE must be set when calling CreateJmods.gmk) 34endif 35 36################################################################################ 37 38JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods 39JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods 40 41LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 42 $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS)))) 43CMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 44 $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS)))) 45CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 46 $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF)))) 47CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE)) 48INCLUDE_HEADERS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 49 $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS)))) 50MAN_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 51 $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN)))) 52 53$(eval $(call FillCacheFind, \ 54 $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \ 55)) 56 57ifneq ($(LIBS_DIR), ) 58 JMOD_FLAGS += --libs $(LIBS_DIR) 59 DEPS += $(call CacheFind, $(LIBS_DIR)) 60endif 61ifneq ($(CMDS_DIR), ) 62 JMOD_FLAGS += --cmds $(CMDS_DIR) 63 DEPS += $(call CacheFind, $(CMDS_DIR)) 64endif 65ifneq ($(CONF_DIR), ) 66 JMOD_FLAGS += --config $(CONF_DIR) 67 DEPS += $(call CacheFind, $(CONF_DIR)) 68endif 69ifneq ($(CLASSES_DIR), ) 70 JMOD_FLAGS += --class-path $(CLASSES_DIR) 71 DEPS += $(call CacheFind, $(CLASSES_DIR)) 72endif 73ifneq ($(INCLUDE_HEADERS_DIR), ) 74 JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR) 75 DEPS += $(call CacheFind, $(INCLUDE_HEADERS_DIR)) 76endif 77ifneq ($(MAN_DIR), ) 78 JMOD_FLAGS += --man-pages $(MAN_DIR) 79 DEPS += $(call CacheFind, $(MAN_DIR)) 80endif 81 82LEGAL_NOTICES := \ 83 $(SUPPORT_OUTPUTDIR)/modules_legal/java.base \ 84 $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)) \ 85 $(call FindModuleLegalDirs, $(MODULE)) \ 86 # 87 88LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES)) 89DEPS += $(call CacheFind, $(LEGAL_NOTICES)) 90 91JMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH) 92 93ifeq ($(filter-out jdk.incubator.%, $(MODULE)), ) 94 JMOD_FLAGS += --do-not-resolve-by-default 95 JMOD_FLAGS += --warn-if-resolved=incubating 96endif 97 98# Add dependencies on other jmod files. Only java.base needs access to other 99# jmods. 100ifeq ($(MODULE), java.base) 101 # When creating a BUILDJDK, we don't need to add hashes to java.base 102 ifneq ($(CREATING_BUILDJDK), true) 103 # When creating interim versions of jmods, skip hashes 104 ifneq ($(INTERIM_JMOD), true) 105 ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules) 106 DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \ 107 $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules))) 108 109 EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES)))) 110 111 JMOD_FLAGS += --module-path $(JMODS_DIR) \ 112 --hash-modules '^(?!$(EXCLUDE_PATTERN))' 113 endif 114 endif 115endif 116 117# Changes to the jmod tool itself should also trigger a rebuild of all jmods. 118# The variable JMOD_CMD could contain an environment variable assignment before 119# the actual command. Filter that out using wildcard before adding to DEPS. 120DEPS += $(wildcard $(JMOD_CMD)) 121ifeq ($(EXTERNAL_BUILDJDK), false) 122 DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod) 123endif 124 125# If creating interim versions of jmods, certain files need to be filtered out 126# to avoid false incremental rebuilds. 127ifeq ($(INTERIM_JMOD), true) 128 DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS)) 129endif 130 131# Create jmods in a temp dir and then move them into place to keep the 132# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times. 133$(JMODS_DIR)/$(MODULE).jmod: $(DEPS) 134 $(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@)) 135 $(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR)) 136 $(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@) 137 $(JMOD) create \ 138 --module-version $(VERSION_SHORT) \ 139 --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \ 140 --module-path $(JMODS_DIR) \ 141 --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \ 142 $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@) 143 $(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@ 144 145TARGETS += $(JMODS_DIR)/$(MODULE).jmod 146 147################################################################################ 148 149all: $(TARGETS) 150 151################################################################################ 152