1 #
   2 # Copyright (c) 2014, 2017, 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 $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))
  31 
  32 ################################################################################
  33 
  34 ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
  35 
  36   TZMAPPINGS_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf
  37 
  38   $(LIB_DST_DIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings
  39         $(call install-file)
  40 
  41   TARGETS += $(LIB_DST_DIR)/tzmappings
  42 
  43 endif
  44 
  45 ################################################################################
  46 # Copy the microsoft runtime libraries on windows
  47 ifeq ($(OPENJDK_TARGET_OS), windows)
  48 
  49   # Chmod to avoid permission issues if bundles are unpacked on unix platforms.
  50   define copy-and-chmod
  51         $(install-file)
  52         $(CHMOD) a+rx $@
  53   endef
  54 
  55   # Use separate macro calls in case the source files are not in the same
  56   # directory.
  57   $(eval $(call SetupCopyFiles,COPY_MSVCR, \
  58       DEST := $(LIB_DST_DIR), \
  59       FILES := $(MSVCR_DLL), \
  60       MACRO := copy-and-chmod))
  61 
  62   $(eval $(call SetupCopyFiles,COPY_MSVCP, \
  63       DEST := $(LIB_DST_DIR), \
  64       FILES := $(MSVCP_DLL), \
  65       MACRO := copy-and-chmod))
  66 
  67   TARGETS += $(COPY_MSVCR) $(COPY_MSVCP)
  68 endif
  69 
  70 ################################################################################
  71 #
  72 # How to install jvm.cfg.
  73 #
  74 ifeq ($(call check-jvm-variant, zero), true)
  75   JVMCFG_ARCH := zero
  76 else
  77   JVMCFG_ARCH := $(OPENJDK_TARGET_CPU_LEGACY)
  78 endif
  79 
  80 ifeq ($(OPENJDK_TARGET_OS), macosx)
  81   JVMCFG_SRC := $(TOPDIR)/src/java.base/macosx/conf/$(JVMCFG_ARCH)/jvm.cfg
  82 else
  83   JVMCFG_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg
  84   # Allow override by ALT_JVMCFG_SRC if it exists
  85   JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
  86 endif
  87 JVMCFG := $(LIB_DST_DIR)/jvm.cfg
  88 
  89 ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
  90   COPY_JVM_CFG_FILE := true
  91 else
  92   # On 32-bit machines we have three potential VMs: client, server and minimal.
  93   # Historically we usually have both client and server and so that is what the
  94   # committed jvm.cfg expects (including platform specific ergonomics switches
  95   # to decide whether to use client or server by default). So when we have anything
  96   # other than client and server we need to define a new jvm.cfg file.
  97   # The main problem is deciding whether to use aliases for the VMs that are not
  98   # present and the current position is that we add aliases for client and server, but
  99   # not for minimal.
 100   CLIENT_AND_SERVER := $(call check-jvm-variant, client)+$(call check-jvm-variant, server)
 101   ifeq ($(CLIENT_AND_SERVER), true+true)
 102     COPY_JVM_CFG_FILE := true
 103   else
 104     # For zero, the default jvm.cfg file is sufficient
 105     ifeq ($(call check-jvm-variant, zero), true)
 106       COPY_JVM_CFG_FILE := true
 107     endif
 108   endif
 109 endif
 110 
 111 ifeq ($(COPY_JVM_CFG_FILE), true)
 112   $(JVMCFG): $(JVMCFG_SRC)
 113         $(call install-file)
 114 else
 115   $(JVMCFG):
 116         $(MKDIR) -p $(@D)
 117         $(RM) $(@)
 118         # Now check for other permutations
 119         ifeq ($(call check-jvm-variant, server), true)
 120           $(PRINTF) "-server KNOWN\n">>$(@)
 121           $(PRINTF) "-client ALIASED_TO -server\n">>$(@)
 122           ifeq ($(call check-jvm-variant, minimal), true)
 123             $(PRINTF) "-minimal KNOWN\n">>$(@)
 124           endif
 125         else
 126           ifeq ($(call check-jvm-variant, client), true)
 127             $(PRINTF) "-client KNOWN\n">>$(@)
 128             $(PRINTF) "-server ALIASED_TO -client\n">>$(@)
 129             ifeq ($(call check-jvm-variant, minimal), true)
 130               $(PRINTF) "-minimal KNOWN\n">>$(@)
 131             endif
 132           else
 133             ifeq ($(call check-jvm-variant, minimal), true)
 134               $(PRINTF) "-minimal KNOWN\n">>$(@)
 135               $(PRINTF) "-server ALIASED_TO -minimal\n">>$(@)
 136               $(PRINTF) "-client ALIASED_TO -minimal\n">>$(@)
 137             endif
 138           endif
 139         endif
 140 endif
 141 
 142 TARGETS += $(JVMCFG)
 143 
 144 ################################################################################
 145 
 146 POLICY_SRC := $(TOPDIR)/src/java.base/share/conf/security/java.policy
 147 POLICY_DST := $(CONF_DST_DIR)/security/java.policy
 148 
 149 POLICY_SRC_LIST := $(POLICY_SRC)
 150 
 151 $(POLICY_DST): $(POLICY_SRC_LIST)
 152         $(MKDIR) -p $(@D)
 153         $(RM) $@ $@.tmp
 154         $(foreach f,$(POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
 155         $(MV) $@.tmp $@
 156 
 157 TARGETS += $(POLICY_DST)
 158 
 159 ################################################################################
 160 
 161 DEF_POLICY_SRC := $(TOPDIR)/src/java.base/share/lib/security/default.policy
 162 DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy
 163 
 164 DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC)
 165 DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST)
 166 
 167 ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )
 168   DEF_POLICY_SRC_LIST += $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy
 169 endif
 170 
 171 # Allow imported modules to modify the java.policy
 172 ifneq ($(IMPORT_MODULES_CONF), )
 173   DEF_POLICY_SRC_LIST += $(wildcard $(IMPORT_MODULES_CONF)/java.base/security/java.policy.extra)
 174 endif
 175 
 176 $(DEF_POLICY_DST): $(DEF_POLICY_SRC_LIST)
 177         $(MKDIR) -p $(@D)
 178         $(RM) $@ $@.tmp
 179         $(foreach f,$(DEF_POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
 180         $(MV) $@.tmp $@
 181 
 182 TARGETS += $(DEF_POLICY_DST)
 183 
 184 ################################################################################
 185 
 186 ifeq ($(CACERTS_FILE), )
 187   CACERTS_FILE := $(TOPDIR)/src/java.base/share/lib/security/cacerts
 188 endif
 189 
 190 CACERTS_DST := $(LIB_DST_DIR)/security/cacerts
 191 
 192 $(CACERTS_DST): $(CACERTS_FILE)
 193         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%, %, $@))
 194         $(call install-file)
 195 
 196 TARGETS += $(CACERTS_DST)
 197 
 198 ################################################################################
 199 
 200 $(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \
 201     FILES := $(TOPDIR)/src/java.base/share/conf/net.properties, \
 202     DEST := $(CONF_DST_DIR), \
 203 ))
 204 
 205 TARGETS += $(COPY_NET_PROPERTIES)
 206 
 207 ifeq ($(OPENJDK_TARGET_OS), solaris)
 208   $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \
 209       FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \
 210       DEST := $(CONF_DST_DIR)/sdp, \
 211   ))
 212 
 213   TARGETS += $(COPY_SDP_CONF)
 214 endif
 215 
 216 ################################################################################
 217 
 218 # JDK license and assembly exception files to be packaged in JMOD
 219 
 220 # The license files may not be present if the source has been obtained using a
 221 # different license.
 222 JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE)
 223 JDK_NOTICE  ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION)
 224 JDK_ADDITIONAL_LICENSE_INFO  ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO)
 225 
 226 $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
 227     FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \
 228     DEST := $(COMMON_LEGAL_DST_DIR), \
 229     FLATTEN := true, \
 230 ))
 231 
 232 TARGETS += $(COPY_JDK_NOTICES)
 233 
 234 ################################################################################
 235 #
 236 # Copy and filter the legal files depending on what 3rd party components are
 237 # bundled or linked from the OS.
 238 #
 239 ifeq ($(USE_EXTERNAL_LIBZ), true)
 240   LEGAL_EXCLUDES += zlib.md
 241 endif
 242 
 243 $(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \
 244     EXCLUDES := $(LEGAL_EXCLUDES), \
 245 ))
 246 
 247 TARGETS += $(COPY_LEGAL)
 248 
 249 ################################################################################
 250 # Optionally copy libffi.so.? into the the image
 251 
 252 ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
 253   $(eval $(call SetupCopyFiles, COPY_LIBFFI, \
 254       FILES := $(LIBFFI_LIB_FILE), \
 255       DEST := $(call FindLibDirForModule, $(MODULE)), \
 256       FLATTEN := true, \
 257       MACRO := install-file-nolink, \
 258   ))
 259 
 260   TARGETS += $(COPY_LIBFFI)
 261 endif
 262 
 263 ################################################################################
 264 # Generate classfile_constants.h
 265 
 266 $(eval $(call SetupTextFileProcessing, CREATE_CLASSFILE_CONSTANTS_H, \
 267     SOURCE_FILES := $(TOPDIR)/src/java.base/share/native/include/classfile_constants.h.template, \
 268     OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/modules_include/java.base/classfile_constants.h, \
 269     REPLACEMENTS := \
 270         @@VERSION_CLASSFILE_MAJOR@@ => $(VERSION_CLASSFILE_MAJOR) ; \
 271         @@VERSION_CLASSFILE_MINOR@@ => $(VERSION_CLASSFILE_MINOR) ; , \
 272 ))
 273 
 274 TARGETS += $(CREATE_CLASSFILE_CONSTANTS_H)
 275 
 276 ################################################################################