make/copy/Copy-java.base.gmk
author mli
Fri, 16 Mar 2018 18:15:31 +0800
changeset 49255 acdb8531cc8b
parent 48355 4944950606ef
child 49537 149dc554808c
permissions -rw-r--r--
8199215: Re-examine getFreePort method in test infrastructure library Reviewed-by: alanb

#
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

include CopyCommon.gmk
include TextFileProcessing.gmk

$(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))

################################################################################

ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)

  TZMAPPINGS_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf

  $(LIB_DST_DIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings
	$(call install-file)

  TARGETS += $(LIB_DST_DIR)/tzmappings

endif

################################################################################
# Copy the microsoft runtime libraries on windows
ifeq ($(OPENJDK_TARGET_OS), windows)

  # Chmod to avoid permission issues if bundles are unpacked on unix platforms.
  define copy-and-chmod
	$(install-file)
	$(CHMOD) a+rx $@
  endef

  # Use separate macro calls in case the source files are not in the same
  # directory.
  $(eval $(call SetupCopyFiles,COPY_MSVCR, \
      DEST := $(LIB_DST_DIR), \
      FILES := $(MSVCR_DLL), \
      MACRO := copy-and-chmod))

  $(eval $(call SetupCopyFiles,COPY_MSVCP, \
      DEST := $(LIB_DST_DIR), \
      FILES := $(MSVCP_DLL), \
      MACRO := copy-and-chmod))

  TARGETS += $(COPY_MSVCR) $(COPY_MSVCP)
endif

################################################################################
#
# How to install jvm.cfg.
#
ifeq ($(call check-jvm-variant, zero), true)
  JVMCFG_ARCH := zero
else
  JVMCFG_ARCH := $(OPENJDK_TARGET_CPU_LEGACY)
endif

ifeq ($(OPENJDK_TARGET_OS), macosx)
  JVMCFG_SRC := $(TOPDIR)/src/java.base/macosx/conf/$(JVMCFG_ARCH)/jvm.cfg
else
  JVMCFG_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg
  # Allow override by ALT_JVMCFG_SRC if it exists
  JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
endif
JVMCFG := $(LIB_DST_DIR)/jvm.cfg

ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
  COPY_JVM_CFG_FILE := true
else
  # On 32-bit machines we have three potential VMs: client, server and minimal.
  # Historically we usually have both client and server and so that is what the
  # committed jvm.cfg expects (including platform specific ergonomics switches
  # to decide whether to use client or server by default). So when we have anything
  # other than client and server we need to define a new jvm.cfg file.
  # The main problem is deciding whether to use aliases for the VMs that are not
  # present and the current position is that we add aliases for client and server, but
  # not for minimal.
  CLIENT_AND_SERVER := $(call check-jvm-variant, client)+$(call check-jvm-variant, server)
  ifeq ($(CLIENT_AND_SERVER), true+true)
    COPY_JVM_CFG_FILE := true
  else
    # For zero, the default jvm.cfg file is sufficient
    ifeq ($(call check-jvm-variant, zero), true)
      COPY_JVM_CFG_FILE := true
    endif
  endif
endif

ifeq ($(COPY_JVM_CFG_FILE), true)
  $(JVMCFG): $(JVMCFG_SRC)
	$(call install-file)
else
  $(JVMCFG):
	$(MKDIR) -p $(@D)
	$(RM) $(@)
        # Now check for other permutations
        ifeq ($(call check-jvm-variant, server), true)
	  $(PRINTF) "-server KNOWN\n">>$(@)
	  $(PRINTF) "-client ALIASED_TO -server\n">>$(@)
          ifeq ($(call check-jvm-variant, minimal), true)
	    $(PRINTF) "-minimal KNOWN\n">>$(@)
          endif
        else
          ifeq ($(call check-jvm-variant, client), true)
	    $(PRINTF) "-client KNOWN\n">>$(@)
	    $(PRINTF) "-server ALIASED_TO -client\n">>$(@)
            ifeq ($(call check-jvm-variant, minimal), true)
	      $(PRINTF) "-minimal KNOWN\n">>$(@)
            endif
          else
            ifeq ($(call check-jvm-variant, minimal), true)
	      $(PRINTF) "-minimal KNOWN\n">>$(@)
	      $(PRINTF) "-server ALIASED_TO -minimal\n">>$(@)
	      $(PRINTF) "-client ALIASED_TO -minimal\n">>$(@)
            endif
          endif
        endif
endif

TARGETS += $(JVMCFG)

################################################################################

POLICY_SRC := $(TOPDIR)/src/java.base/share/conf/security/java.policy
POLICY_DST := $(CONF_DST_DIR)/security/java.policy

POLICY_SRC_LIST := $(POLICY_SRC)

$(POLICY_DST): $(POLICY_SRC_LIST)
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	$(foreach f,$(POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
	$(MV) $@.tmp $@

TARGETS += $(POLICY_DST)

################################################################################

DEF_POLICY_SRC := $(TOPDIR)/src/java.base/share/lib/security/default.policy
DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy

DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC)
DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST)

ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )
  DEF_POLICY_SRC_LIST += $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy
endif

# Allow imported modules to modify the java.policy
ifneq ($(IMPORT_MODULES_CONF), )
  DEF_POLICY_SRC_LIST += $(wildcard $(IMPORT_MODULES_CONF)/java.base/security/java.policy.extra)
endif

$(DEF_POLICY_DST): $(DEF_POLICY_SRC_LIST)
	$(MKDIR) -p $(@D)
	$(RM) $@ $@.tmp
	$(foreach f,$(DEF_POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
	$(MV) $@.tmp $@

TARGETS += $(DEF_POLICY_DST)

################################################################################

ifeq ($(CACERTS_FILE), )
  CACERTS_FILE := $(TOPDIR)/src/java.base/share/lib/security/cacerts
endif

CACERTS_DST := $(LIB_DST_DIR)/security/cacerts

$(CACERTS_DST): $(CACERTS_FILE)
	$(call LogInfo, Copying $(patsubst $(OUTPUTDIR)/%, %, $@))
	$(call install-file)

TARGETS += $(CACERTS_DST)

################################################################################

$(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \
    FILES := $(TOPDIR)/src/java.base/share/conf/net.properties, \
    DEST := $(CONF_DST_DIR), \
))

TARGETS += $(COPY_NET_PROPERTIES)

ifeq ($(OPENJDK_TARGET_OS), solaris)
  $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \
      FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \
      DEST := $(CONF_DST_DIR)/sdp, \
  ))

  TARGETS += $(COPY_SDP_CONF)
endif

################################################################################

# JDK license and assembly exception files to be packaged in JMOD

# The license files may not be present if the source has been obtained using a
# different license.
JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE)
JDK_NOTICE  ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION)
JDK_ADDITIONAL_LICENSE_INFO  ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO)

$(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
    FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \
    DEST := $(LEGAL_DST_DIR), \
    FLATTEN := true, \
))

TARGETS += $(COPY_JDK_NOTICES)

################################################################################
# Optionally copy libffi.so.? into the the image

ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
  $(eval $(call SetupCopyFiles, COPY_LIBFFI, \
      FILES := $(LIBFFI_LIB_FILE), \
      DEST := $(call FindLibDirForModule, $(MODULE)), \
      FLATTEN := true, \
      MACRO := install-file-nolink, \
  ))

  TARGETS += $(COPY_LIBFFI)
endif

################################################################################
# Generate classfile_constants.h

$(eval $(call SetupTextFileProcessing, CREATE_CLASSFILE_CONSTANTS_H, \
    SOURCE_FILES := $(TOPDIR)/src/java.base/share/native/include/classfile_constants.h.template, \
    OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/modules_include/java.base/classfile_constants.h, \
    REPLACEMENTS := \
        @@VERSION_CLASSFILE_MAJOR@@ => $(VERSION_CLASSFILE_MAJOR) ; \
        @@VERSION_CLASSFILE_MINOR@@ => $(VERSION_CLASSFILE_MINOR) ; , \
))

TARGETS += $(CREATE_CLASSFILE_CONSTANTS_H)

################################################################################