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