1 # 2 # Copyright (c) 2014, 2020, 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 26 include CopyCommon.gmk 27 include Modules.gmk 28 include TextFileProcessing.gmk 29 30 # Hook to include the corresponding custom file, if present. 31 $(eval $(call IncludeCustomExtension, modules/java.base/Copy.gmk)) 32 33 ################################################################################ 34 35 ifeq ($(call isTargetOs, aix), true) 36 37 TZMAPPINGS_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf 38 39 $(LIB_DST_DIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings 40 $(call install-file) 41 42 TARGETS += $(LIB_DST_DIR)/tzmappings 43 44 endif 45 46 ################################################################################ 47 # Copy the microsoft runtime libraries on windows 48 ifeq ($(call isTargetOs, windows), true) 49 50 # Chmod to avoid permission issues if bundles are unpacked on unix platforms. 51 define copy-and-chmod 52 $(install-file) 53 $(CHMOD) a+rx $@ 54 endef 55 56 # Use separate macro calls in case the source files are not in the same 57 # directory. 58 $(eval $(call SetupCopyFiles,COPY_MSVCR, \ 59 DEST := $(LIB_DST_DIR), \ 60 FILES := $(MSVCR_DLL), \ 61 MACRO := copy-and-chmod)) 62 63 $(eval $(call SetupCopyFiles,COPY_VCRUNTIME_1, \ 64 DEST := $(LIB_DST_DIR), \ 65 FILES := $(VCRUNTIME_1_DLL), \ 66 MACRO := copy-and-chmod)) 67 68 $(eval $(call SetupCopyFiles,COPY_MSVCP, \ 69 DEST := $(LIB_DST_DIR), \ 70 FILES := $(MSVCP_DLL), \ 71 MACRO := copy-and-chmod)) 72 73 TARGETS += $(COPY_MSVCR) $(COPY_VCRUNTIME_1) $(COPY_MSVCP) 74 75 ifneq ($(UCRT_DLL_DIR), ) 76 $(eval $(call SetupCopyFiles, COPY_UCRT_DLLS, \ 77 DEST := $(LIB_DST_DIR), \ 78 SRC := $(UCRT_DLL_DIR), \ 79 FILES := $(wildcard $(UCRT_DLL_DIR)/*.dll), \ 80 MACRO := copy-and-chmod, \ 81 )) 82 83 TARGETS += $(COPY_UCRT_DLLS) 84 endif 85 endif 86 87 ################################################################################ 88 # In jvm.cfg, the first listed KNOWN variant is the default. On most build 89 # configurations, that is the server variant. 90 ifeq ($(call And, $(call isTargetOs, windows) $(call isTargetCpu, x86)), true) 91 DEFAULT_CFG_VARIANT ?= client 92 endif 93 DEFAULT_CFG_VARIANT ?= server 94 95 # Any variant other than server, client or minimal is represented as server in 96 # the cfg file. 97 VALID_CFG_VARIANTS := server client minimal 98 CFG_VARIANTS := $(filter $(VALID_CFG_VARIANTS), $(JVM_VARIANTS)) \ 99 $(if $(filter-out $(VALID_CFG_VARIANTS), $(JVM_VARIANTS)), server) 100 101 # Change the order to put the default variant first if present. 102 ORDERED_CFG_VARIANTS := \ 103 $(if $(filter $(DEFAULT_CFG_VARIANT), $(CFG_VARIANTS)), $(DEFAULT_CFG_VARIANT)) \ 104 $(filter-out $(DEFAULT_CFG_VARIANT), $(CFG_VARIANTS)) 105 106 JVMCFG := $(LIB_DST_DIR)/jvm.cfg 107 108 define print-cfg-line 109 $(call LogInfo, Adding -$1 $2 to jvm.cfg) 110 $(PRINTF) -- "-$1 $2\n" >> $@ $(NEWLINE) 111 endef 112 113 $(JVMCFG): $(call DependOnVariable, ORDERED_CFG_VARIANTS) 114 $(call MakeTargetDir) 115 $(RM) $@ 116 $(foreach v, $(ORDERED_CFG_VARIANTS), \ 117 $(call print-cfg-line,$v,KNOWN) \ 118 ) 119 # If either of server or client aren't present, add IGNORE lines for 120 # them. 121 $(foreach v, server client, \ 122 $(if $(filter $v, $(ORDERED_CFG_VARIANTS)), , \ 123 $(call print-cfg-line,$v,IGNORE) \ 124 ) \ 125 ) 126 127 TARGETS += $(JVMCFG) 128 129 ################################################################################ 130 131 POLICY_SRC := $(TOPDIR)/src/java.base/share/conf/security/java.policy 132 POLICY_DST := $(CONF_DST_DIR)/security/java.policy 133 134 POLICY_SRC_LIST := $(POLICY_SRC) 135 136 $(POLICY_DST): $(POLICY_SRC_LIST) 137 $(call MakeTargetDir) 138 $(RM) $@ $@.tmp 139 $(foreach f,$(POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;) 140 $(MV) $@.tmp $@ 141 142 TARGETS += $(POLICY_DST) 143 144 ################################################################################ 145 146 DEF_POLICY_SRC := $(TOPDIR)/src/java.base/share/lib/security/default.policy 147 DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy 148 149 DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC) 150 DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST) 151 152 ifeq ($(call isTargetOs, windows solaris), true) 153 DEF_POLICY_SRC_LIST += $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy 154 endif 155 156 # Allow imported modules to modify the java.policy 157 ifneq ($(IMPORT_MODULES_CONF), ) 158 DEF_POLICY_SRC_LIST += $(wildcard $(IMPORT_MODULES_CONF)/java.base/security/java.policy.extra) 159 endif 160 161 $(DEF_POLICY_DST): $(DEF_POLICY_SRC_LIST) 162 $(call MakeTargetDir) 163 $(RM) $@ $@.tmp 164 $(foreach f,$(DEF_POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;) 165 $(MV) $@.tmp $@ 166 167 TARGETS += $(DEF_POLICY_DST) 168 169 ################################################################################ 170 171 # CACERTS_FILE is optionally set in configure to override the default cacerts 172 # which is otherwise generated in Gendata-java.base.gmk 173 CACERTS_DST := $(LIB_DST_DIR)/security/cacerts 174 175 $(CACERTS_DST): $(CACERTS_FILE) 176 $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%, %, $@)) 177 $(call install-file) 178 179 ifneq ($(CACERTS_FILE), ) 180 TARGETS += $(CACERTS_DST) 181 endif 182 183 ################################################################################ 184 185 $(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \ 186 FILES := $(TOPDIR)/src/java.base/share/conf/net.properties, \ 187 DEST := $(CONF_DST_DIR), \ 188 )) 189 190 TARGETS += $(COPY_NET_PROPERTIES) 191 192 ifeq ($(call isTargetOs, solaris linux), true) 193 $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \ 194 FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \ 195 DEST := $(CONF_DST_DIR)/sdp, \ 196 )) 197 198 TARGETS += $(COPY_SDP_CONF) 199 endif 200 201 ################################################################################ 202 203 # JDK license and assembly exception files to be packaged in JMOD 204 205 # The license files may not be present if the source has been obtained using a 206 # different license. 207 JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE) 208 JDK_NOTICE ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION) 209 JDK_ADDITIONAL_LICENSE_INFO ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO) 210 211 $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \ 212 FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \ 213 DEST := $(COMMON_LEGAL_DST_DIR), \ 214 FLATTEN := true, \ 215 )) 216 217 TARGETS += $(COPY_JDK_NOTICES) 218 219 ################################################################################ 220 # 221 # Copy and filter the legal files depending on what 3rd party components are 222 # bundled or linked from the OS. 223 # 224 ifeq ($(USE_EXTERNAL_LIBZ), true) 225 LEGAL_EXCLUDES += zlib.md 226 endif 227 228 $(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \ 229 EXCLUDES := $(LEGAL_EXCLUDES), \ 230 )) 231 232 TARGETS += $(COPY_LEGAL) 233 234 ################################################################################ 235 # Optionally copy libffi.so.? into the the image 236 237 ifeq ($(ENABLE_LIBFFI_BUNDLING), true) 238 $(eval $(call SetupCopyFiles, COPY_LIBFFI, \ 239 FILES := $(LIBFFI_LIB_FILE), \ 240 DEST := $(call FindLibDirForModule, $(MODULE)), \ 241 FLATTEN := true, \ 242 MACRO := install-file-nolink, \ 243 )) 244 245 TARGETS += $(COPY_LIBFFI) 246 endif 247 248 ################################################################################ 249 # Generate classfile_constants.h 250 251 $(eval $(call SetupTextFileProcessing, CREATE_CLASSFILE_CONSTANTS_H, \ 252 SOURCE_FILES := $(TOPDIR)/src/java.base/share/native/include/classfile_constants.h.template, \ 253 OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/modules_include/java.base/classfile_constants.h, \ 254 REPLACEMENTS := \ 255 @@VERSION_CLASSFILE_MAJOR@@ => $(VERSION_CLASSFILE_MAJOR) ; \ 256 @@VERSION_CLASSFILE_MINOR@@ => $(VERSION_CLASSFILE_MINOR) ; , \ 257 )) 258 259 TARGETS += $(CREATE_CLASSFILE_CONSTANTS_H) 260 261 ################################################################################