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_EXPORT_DIR)/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 zeroshark), 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 # To do: should this also support -zeroshark?
 106 
 107 ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
 108   COPY_JVM_CFG_FILE := true
 109 else
 110   # On 32-bit machines we have three potential VMs: client, server and minimal.
 111   # Historically we usually have both client and server and so that is what the
 112   # committed jvm.cfg expects (including platform specific ergonomics switches
 113   # to decide whether to use client or server by default). So when we have anything
 114   # other than client and server we need to define a new jvm.cfg file.
 115   # The main problem is deciding whether to use aliases for the VMs that are not
 116   # present and the current position is that we add aliases for client and server, but
 117   # not for minimal.
 118   CLIENT_AND_SERVER := $(call check-jvm-variant, client)+$(call check-jvm-variant, server)
 119   ifeq ($(CLIENT_AND_SERVER), true+true)
 120     COPY_JVM_CFG_FILE := true
 121   else
 122     # For zero, the default jvm.cfg file is sufficient
 123     ifeq ($(call check-jvm-variant, zero zeroshark), true)
 124       COPY_JVM_CFG_FILE := true
 125     endif
 126   endif
 127 endif
 128 
 129 ifeq ($(COPY_JVM_CFG_FILE), true)
 130   $(JVMCFG): $(JVMCFG_SRC)
 131         $(call install-file)
 132 else
 133   $(JVMCFG):
 134         $(MKDIR) -p $(@D)
 135         $(RM) $(@)
 136         # Now check for other permutations
 137         ifeq ($(call check-jvm-variant, server), true)
 138           $(PRINTF) "-server KNOWN\n">>$(@)
 139           $(PRINTF) "-client ALIASED_TO -server\n">>$(@)
 140           ifeq ($(call check-jvm-variant, minimal), true)
 141             $(PRINTF) "-minimal KNOWN\n">>$(@)
 142           endif
 143         else
 144           ifeq ($(call check-jvm-variant, client), true)
 145             $(PRINTF) "-client KNOWN\n">>$(@)
 146             $(PRINTF) "-server ALIASED_TO -client\n">>$(@)
 147             ifeq ($(call check-jvm-variant, minimal), true)
 148               $(PRINTF) "-minimal KNOWN\n">>$(@)
 149             endif
 150           else
 151             ifeq ($(call check-jvm-variant, minimal), true)
 152               $(PRINTF) "-minimal KNOWN\n">>$(@)
 153               $(PRINTF) "-server ALIASED_TO -minimal\n">>$(@)
 154               $(PRINTF) "-client ALIASED_TO -minimal\n">>$(@)
 155             endif
 156           endif
 157         endif
 158 endif
 159 
 160 TARGETS += $(JVMCFG)
 161 
 162 ################################################################################
 163 
 164 POLICY_SRC := $(TOPDIR)/src/java.base/share/conf/security/java.policy
 165 POLICY_DST := $(CONF_DST_DIR)/security/java.policy
 166 
 167 POLICY_SRC_LIST := $(POLICY_SRC)
 168 
 169 $(POLICY_DST): $(POLICY_SRC_LIST)
 170         $(MKDIR) -p $(@D)
 171         $(RM) $@ $@.tmp
 172         $(foreach f,$(POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
 173         $(MV) $@.tmp $@
 174 
 175 TARGETS += $(POLICY_DST)
 176 
 177 ################################################################################
 178 
 179 DEF_POLICY_SRC := $(TOPDIR)/src/java.base/share/lib/security/default.policy
 180 DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy
 181 
 182 DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC)
 183 DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST)
 184 
 185 ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )
 186   DEF_POLICY_SRC_LIST += $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy
 187 endif
 188 
 189 # Allow imported modules to modify the java.policy
 190 ifneq ($(IMPORT_MODULES_CONF), )
 191   DEF_POLICY_SRC_LIST += $(wildcard $(IMPORT_MODULES_CONF)/java.base/security/java.policy.extra)
 192 endif
 193 
 194 $(DEF_POLICY_DST): $(DEF_POLICY_SRC_LIST)
 195         $(MKDIR) -p $(@D)
 196         $(RM) $@ $@.tmp
 197         $(foreach f,$(DEF_POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
 198         $(MV) $@.tmp $@
 199 
 200 TARGETS += $(DEF_POLICY_DST)
 201 
 202 ################################################################################
 203 
 204 ifeq ($(CACERTS_FILE), )
 205   CACERTS_FILE := $(TOPDIR)/src/java.base/share/lib/security/cacerts
 206 endif
 207 
 208 CACERTS_DST := $(LIB_DST_DIR)/security/cacerts
 209 
 210 $(CACERTS_DST): $(CACERTS_FILE)
 211         $(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%, %, $@))
 212         $(call install-file)
 213 
 214 TARGETS += $(CACERTS_DST)
 215 
 216 ################################################################################
 217 
 218 $(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \
 219     FILES := $(TOPDIR)/src/java.base/share/conf/net.properties, \
 220     DEST := $(CONF_DST_DIR), \
 221 ))
 222 
 223 TARGETS += $(COPY_NET_PROPERTIES)
 224 
 225 ifeq ($(OPENJDK_TARGET_OS), solaris)
 226   $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \
 227       FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \
 228       DEST := $(CONF_DST_DIR)/sdp, \
 229   ))
 230 
 231   TARGETS += $(COPY_SDP_CONF)
 232 endif
 233 
 234 ################################################################################
 235 
 236 # JDK license and assembly exception files to be packaged in JMOD
 237 
 238 # The license files may not be present if the source has been obtained using a
 239 # different license.
 240 JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE)
 241 JDK_NOTICE  ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION)
 242 
 243 $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
 244     FILES := $(JDK_LICENSE) $(JDK_NOTICE), \
 245     DEST := $(LEGAL_DST_DIR), \
 246     FLATTEN := true, \
 247 ))
 248 
 249 TARGETS += $(COPY_JDK_NOTICES)
 250 
 251 ################################################################################
 252 # Optionally copy libffi.so.? into the the image
 253 
 254 ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
 255   $(eval $(call SetupCopyFiles, COPY_LIBFFI, \
 256       FILES := $(LIBFFI_LIB_FILE), \
 257       DEST := $(call FindLibDirForModule, $(MODULE)), \
 258       FLATTEN := true, \
 259       MACRO := install-file-nolink, \
 260   ))
 261 
 262   TARGETS += $(COPY_LIBFFI)
 263 endif
 264 
 265 ################################################################################