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