blob: 1e391c3f4e59dc305a96a5ae8e6c247511ca6c28 [file] [log] [blame]
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
default: all
include $(SPEC)
include MakeBase.gmk
include Modules.gmk
ifeq ($(MODULE), )
$(error MODULE must be set when calling CreateJmods.gmk)
endif
$(eval $(call IncludeCustomExtension, CreateJmods.gmk))
################################################################################
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
CMDS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
CONF_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
CLASSES_DIR ?= $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
$(eval $(call FillCacheFind, \
$(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \
))
ifneq ($(LIBS_DIR), )
JMOD_FLAGS += --libs $(LIBS_DIR)
DEPS += $(call CacheFind, $(LIBS_DIR))
endif
ifneq ($(CMDS_DIR), )
JMOD_FLAGS += --cmds $(CMDS_DIR)
DEPS += $(call CacheFind, $(CMDS_DIR))
endif
ifneq ($(CONF_DIR), )
JMOD_FLAGS += --config $(CONF_DIR)
DEPS += $(call CacheFind, $(CONF_DIR))
endif
ifneq ($(CLASSES_DIR), )
JMOD_FLAGS += --class-path $(CLASSES_DIR)
DEPS += $(call CacheFind, $(CLASSES_DIR))
endif
ifneq ($(INCLUDE_HEADERS_DIR), )
JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR)
DEPS += $(call CacheFind, $(INCLUDE_HEADERS_DIR))
endif
ifneq ($(MAN_DIR), )
JMOD_FLAGS += --man-pages $(MAN_DIR)
DEPS += $(call CacheFind, $(MAN_DIR))
endif
# If a specific modules_legal dir exists for this module, only pick up files
# from there. These files were explicitly filtered or modified in <module>-copy
# targets. For the rest, just pick up everything from the source legal dirs.
LEGAL_NOTICES := \
$(SUPPORT_OUTPUTDIR)/modules_legal/common \
$(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
$(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
$(call FindModuleLegalSrcDirs, $(MODULE)) \
)
LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
DEPS += $(call CacheFind, $(LEGAL_NOTICES))
JMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH)
ifeq ($(filter-out jdk.incubator.%, $(MODULE)), )
JMOD_FLAGS += --do-not-resolve-by-default
JMOD_FLAGS += --warn-if-resolved=incubating
endif
# Add dependencies on other jmod files. Only java.base needs access to other
# jmods.
ifeq ($(MODULE), java.base)
# When creating a BUILDJDK, we don't need to add hashes to java.base
ifneq ($(CREATING_BUILDJDK), true)
# When creating interim versions of jmods, skip hashes
ifneq ($(INTERIM_JMOD), true)
ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
$(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
EXCLUDE_PATTERN := $(strip $(subst $(SPACE),$$|,$(strip $(ALL_UPGRADEABLE_MODULES))))
JMOD_FLAGS += --module-path $(JMODS_DIR) \
--hash-modules '^(?!$(EXCLUDE_PATTERN)$$)'
endif
endif
else # not java.base
ifeq ($(OPENJDK_TARGET_OS), windows)
# Only java.base needs to include the MSVC*_DLLs. Make sure no other module
# tries to include them (typically imported ones).
ifneq ($(MSVCR_DLL), )
ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCR_DLL))), )
JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))'
endif
endif
ifneq ($(MSVCP_DLL), )
ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), )
JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))'
endif
endif
ifneq ($(UCRT_DLL_DIR), )
UCRT_DLL_FILES := $(notdir $(wildcard $(UCRT_DLL_DIR)/*.dll))
ifneq ($(wildcard $(LIBS_DIR)/$(firstword $(UCRT_DLL_FILES))), )
JMOD_FLAGS += $(patsubst %, --exclude '%', $(UCRT_DLL_FILES))
endif
endif
endif
endif
# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
# The variable JMOD_CMD could contain an environment variable assignment before
# the actual command. Filter that out using wildcard before adding to DEPS.
DEPS += $(wildcard $(JMOD_CMD))
ifeq ($(EXTERNAL_BUILDJDK), false)
DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
endif
# If creating interim versions of jmods, certain files need to be filtered out
# to avoid false incremental rebuilds.
ifeq ($(INTERIM_JMOD), true)
DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
endif
JMOD_FLAGS += --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}'
# Create jmods in a temp dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
$(call LogWarn, Creating $(patsubst $(OUTPUTDIR)/%, %, $@))
$(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/jmods/$(MODULE).jmod, \
$(JMOD) create \
--module-version $(VERSION_SHORT) \
--target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
--module-path $(JMODS_DIR) \
$(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@) \
)
$(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
TARGETS += $(JMODS_DIR)/$(MODULE).jmod
################################################################################
all: $(TARGETS)
################################################################################