1 # Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. 2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 # 4 # This code is free software; you can redistribute it and/or modify it 5 # under the terms of the GNU General Public License version 2 only, as 6 # published by the Free Software Foundation. Oracle designates this 7 # particular file as subject to the "Classpath" exception as provided 8 # by Oracle in the LICENSE file that accompanied this code. 9 # 10 # This code is distributed in the hope that it will be useful, but WITHOUT 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 # version 2 for more details (a copy is included in the LICENSE file that 14 # accompanied this code). 15 # 16 # You should have received a copy of the GNU General Public License version 17 # 2 along with this work; if not, write to the Free Software Foundation, 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 # 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 # or visit www.oracle.com if you need additional information or have any 22 # questions. 23 # 24 25 default: all 26 27 include $(SPEC) 28 include MakeBase.gmk 29 include Execute.gmk 30 include Modules.gmk 31 32 ifeq ($(MODULE), ) 33 $(error MODULE must be set when calling CreateJmods.gmk) 34 endif 35 36 $(eval $(call IncludeCustomExtension, CreateJmods.gmk)) 37 38 ################################################################################ 39 40 JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods 41 JMODS_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jmods 42 JMOD_FILE := $(MODULE).jmod 43 44 LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \ 45 $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS)))) 46 CMDS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \ 47 $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS)))) 48 CONF_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \ 49 $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF)))) 50 CLASSES_DIR ?= $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE)) 51 INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \ 52 $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS)))) 53 MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \ 54 $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN)))) 55 56 $(call FillFindCache, \ 57 $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \ 58 ) 59 60 ifneq ($(LIBS_DIR), ) 61 JMOD_FLAGS += --libs $(LIBS_DIR) 62 DEPS += $(call FindFiles, $(LIBS_DIR)) 63 endif 64 ifneq ($(CMDS_DIR), ) 65 JMOD_FLAGS += --cmds $(CMDS_DIR) 66 DEPS += $(call FindFiles, $(CMDS_DIR)) 67 endif 68 ifneq ($(CONF_DIR), ) 69 JMOD_FLAGS += --config $(CONF_DIR) 70 DEPS += $(call FindFiles, $(CONF_DIR)) 71 endif 72 ifneq ($(CLASSES_DIR), ) 73 JMOD_FLAGS += --class-path $(CLASSES_DIR) 74 DEPS += $(call FindFiles, $(CLASSES_DIR)) 75 endif 76 ifneq ($(INCLUDE_HEADERS_DIR), ) 77 JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR) 78 DEPS += $(call FindFiles, $(INCLUDE_HEADERS_DIR)) 79 endif 80 ifneq ($(MAN_DIR), ) 81 JMOD_FLAGS += --man-pages $(MAN_DIR) 82 DEPS += $(call FindFiles, $(MAN_DIR)) 83 endif 84 85 # If a specific modules_legal dir exists for this module, only pick up files 86 # from there. These files were explicitly filtered or modified in <module>-copy 87 # targets. For the rest, just pick up everything from the source legal dirs. 88 LEGAL_NOTICES := \ 89 $(SUPPORT_OUTPUTDIR)/modules_legal/common \ 90 $(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \ 91 $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \ 92 $(call FindModuleLegalSrcDirs, $(MODULE)) \ 93 ) 94 95 LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES)) 96 DEPS += $(call FindFiles, $(LEGAL_NOTICES)) 97 98 JMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH) 99 100 ifeq ($(filter-out jdk.jpackage, $(MODULE)), ) 101 JMOD_FLAGS += --do-not-resolve-by-default 102 endif 103 104 ifeq ($(filter-out jdk.incubator.%, $(MODULE)), ) 105 JMOD_FLAGS += --do-not-resolve-by-default 106 JMOD_FLAGS += --warn-if-resolved=incubating 107 endif 108 109 # Add dependencies on other jmod files. Only java.base needs access to other 110 # jmods. 111 ifeq ($(MODULE), java.base) 112 # When creating a BUILDJDK, we don't need to add hashes to java.base 113 ifneq ($(CREATING_BUILDJDK), true) 114 # When creating interim versions of jmods, skip hashes 115 ifneq ($(INTERIM_JMOD), true) 116 ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules) 117 DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \ 118 $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules))) 119 120 EXCLUDE_PATTERN := $(strip $(subst $(SPACE),$$|,$(strip $(ALL_UPGRADEABLE_MODULES)))) 121 122 JMOD_FLAGS += --module-path $(JMODS_DIR) \ 123 --hash-modules '^(?!$(EXCLUDE_PATTERN)$$)' 124 endif 125 endif 126 else # not java.base 127 ifeq ($(call isTargetOs, windows), true) 128 # Only java.base needs to include the MSVC*_DLLs. Make sure no other module 129 # tries to include them (typically imported ones). 130 ifneq ($(MSVCR_DLL), ) 131 ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCR_DLL))), ) 132 JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))' 133 endif 134 endif 135 ifneq ($(MSVCP_DLL), ) 136 ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), ) 137 JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))' 138 endif 139 endif 140 ifneq ($(UCRT_DLL_DIR), ) 141 UCRT_DLL_FILES := $(notdir $(wildcard $(UCRT_DLL_DIR)/*.dll)) 142 ifneq ($(wildcard $(LIBS_DIR)/$(firstword $(UCRT_DLL_FILES))), ) 143 JMOD_FLAGS += $(patsubst %, --exclude '%', $(UCRT_DLL_FILES)) 144 endif 145 endif 146 endif 147 endif 148 149 # Changes to the jmod tool itself should also trigger a rebuild of all jmods. 150 # The variable JMOD_CMD could contain an environment variable assignment before 151 # the actual command. Filter that out using wildcard before adding to DEPS. 152 DEPS += $(wildcard $(JMOD_CMD)) 153 ifeq ($(EXTERNAL_BUILDJDK), false) 154 DEPS += $(call FindFiles, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod) 155 endif 156 157 # If creating interim versions of jmods, certain files need to be filtered out 158 # to avoid false incremental rebuilds. 159 ifeq ($(INTERIM_JMOD), true) 160 DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS)) 161 INTERIM_MSG := interim$(SPACE) 162 endif 163 164 JMOD_FLAGS += --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' 165 166 # Create jmods in the support dir and then move them into place to keep the 167 # module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times. 168 $(eval $(call SetupExecute, create_$(JMOD_FILE), \ 169 WARN := Creating $(INTERIM_MSG)$(JMOD_FILE), \ 170 DEPS := $(DEPS), \ 171 OUTPUT_FILE := $(JMODS_DIR)/$(JMOD_FILE), \ 172 SUPPORT_DIR := $(JMODS_SUPPORT_DIR), \ 173 PRE_COMMAND := $(RM) $(JMODS_DIR)/$(JMOD_FILE) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \ 174 COMMAND := $(JMOD) create --module-version $(VERSION_SHORT) \ 175 --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \ 176 --module-path $(JMODS_DIR) $(JMOD_FLAGS) \ 177 $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \ 178 POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \ 179 )) 180 181 TARGETS += $(create_$(JMOD_FILE)) 182 183 ################################################################################ 184 185 all: $(TARGETS) 186 187 ################################################################################