hotspot/makefiles/Dist.gmk
changeset 37437 f824aabc7af8
equal deleted inserted replaced
37436:1d902bc02bc2 37437:f824aabc7af8
       
     1 #
       
     2 # Copyright (c) 2013, 2016, 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 ################################################################################
       
    27 # Copy the generated output into well-defined places in the dist directory.
       
    28 
       
    29 # This must be the first rule
       
    30 default: all
       
    31 
       
    32 include $(SPEC)
       
    33 include MakeBase.gmk
       
    34 
       
    35 $(eval $(call IncludeCustomExtension, hotspot, Dist.gmk))
       
    36 
       
    37 DIST_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/dist
       
    38 
       
    39 # Unfortunately, all platforms have different target subdirs.
       
    40 ifeq ($(OPENJDK_TARGET_OS), windows)
       
    41   LIB_SUBDIR := bin
       
    42 else ifeq ($(OPENJDK_TARGET_OS), macosx)
       
    43   LIB_SUBDIR := lib
       
    44 else
       
    45   LIB_SUBDIR := lib$(OPENJDK_TARGET_CPU_LIBDIR)
       
    46 endif
       
    47 
       
    48 ################################################################################
       
    49 # Functions to setup copying of files for variants
       
    50 
       
    51 # Support macro for SetupDistLibFile
       
    52 define macosx_universalize
       
    53 	$(MKDIR) -p $(@D)
       
    54 	$(LIPO) -create -output $@ $<
       
    55 endef
       
    56 
       
    57 ################################################################################
       
    58 # Setup make rules to copy a native library and associated data.
       
    59 #
       
    60 # Parameter 1 is the name of the rule. This name is used as variable prefix,
       
    61 # and the targets generated are listed in a variable by that name.
       
    62 #
       
    63 # Remaining parameters are named arguments. These include:
       
    64 #   NAME -- The base name of the native library (e.g. 'jvm')
       
    65 #   VARIANT -- The variant to copy from
       
    66 #   VARIANT_TARGET_DIR -- The variant target sub dir, with trailing slash, optional
       
    67 SetupDistLibFile = $(NamedParamsMacroTemplate)
       
    68 define SetupDistLibFileBody
       
    69   ifneq ($$($1_VARIANT), )
       
    70     $1_SRC_DIR := $$(HOTSPOT_OUTPUTDIR)/variant-$$($1_VARIANT)/lib$$($1_NAME)
       
    71   else
       
    72     $1_SRC_DIR := $$(HOTSPOT_OUTPUTDIR)/lib$$($1_NAME)
       
    73   endif
       
    74   $1_LIB_NAME := $(LIBRARY_PREFIX)$$($1_NAME)
       
    75   $1_TARGET_DIR := $$(DIST_OUTPUTDIR)/$$(LIB_SUBDIR)/$$($1_VARIANT_TARGET_DIR)
       
    76 
       
    77   ifeq ($(OPENJDK_TARGET_OS), macosx)
       
    78     # We must use the 'universalize' macro to run lipo on shared libraries, at
       
    79     # least until JDK-8069540 is fixed.
       
    80     $1_MACRO := macosx_universalize
       
    81   endif
       
    82 
       
    83   # Copy the the native library.
       
    84   $$(eval $$(call SetupCopyFiles, $1_COPY_LIB, \
       
    85       DEST := $$($1_TARGET_DIR), \
       
    86       MACRO := $$($1_MACRO), \
       
    87       FILES := $$(wildcard \
       
    88           $$($1_SRC_DIR)/$$($1_LIB_NAME)$(SHARED_LIBRARY_SUFFIX)), \
       
    89   ))
       
    90 
       
    91   TARGETS += $$($1_COPY_LIB)
       
    92 
       
    93   # Copy related data (debug symbols, static-build symbols file etc)
       
    94   $$(eval $$(call SetupCopyFiles, $1_COPY_FILES, \
       
    95       DEST := $$($1_TARGET_DIR), \
       
    96       FILES := $$(wildcard \
       
    97           $$(addprefix $$($1_SRC_DIR)/$$($1_LIB_NAME), \
       
    98           .diz .debuginfo .pdb .map .symbols)), \
       
    99   ))
       
   100 
       
   101   TARGETS += $$($1_COPY_FILES)
       
   102 
       
   103   ifeq ($(OPENJDK_TARGET_OS), macosx)
       
   104     # Debug symbols on macosx is a directory, not a single file, per library.
       
   105     $1_DSYM_SRC := $$($1_SRC_DIR)/$$($1_LIB_NAME)$(SHARED_LIBRARY_SUFFIX).dSYM)
       
   106     ifneq ($$(wildcard $$($1_DSYM_SRC)), )
       
   107       $$(eval $$(call SetupCopyFiles, $1_COPY_DSYM_DIR, \
       
   108           DEST := $$($1_TARGET_DIR), \
       
   109           SRC := $$($1_SRC_DIR), \
       
   110           FILES := $$(shell $(FIND) $$($1_DSYM_SRC) -type f), \
       
   111        ))
       
   112        TARGETS += $$($1_COPY_DSYM_DIR)
       
   113     endif
       
   114   endif
       
   115 endef
       
   116 
       
   117 ################################################################################
       
   118 # Copy common files, which are independent on the jvm variant(s) being built.
       
   119 # For files that were generated during the build, we assume all versions of
       
   120 # these files are identical, and just pick one arbitrarily to use as source.
       
   121 
       
   122 ANY_JVM_VARIANT := $(firstword $(JVM_VARIANTS))
       
   123 JVM_VARIANT_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/variant-$(ANY_JVM_VARIANT)
       
   124 
       
   125 ### Copy platform-independent .h files
       
   126 INCLUDE_FILES_SRC_DIR := $(HOTSPOT_TOPDIR)/src/share/vm
       
   127 $(eval $(call SetupCopyFiles, COPY_INCLUDE, \
       
   128     SRC := $(INCLUDE_FILES_SRC_DIR), \
       
   129     DEST := $(DIST_OUTPUTDIR)/include, \
       
   130     FLATTEN := true, \
       
   131     FILES := $(INCLUDE_FILES_SRC_DIR)/prims/jni.h \
       
   132         $(INCLUDE_FILES_SRC_DIR)/code/jvmticmlr.h \
       
   133         $(INCLUDE_FILES_SRC_DIR)/services/jmm.h))
       
   134 
       
   135 TARGETS += $(COPY_INCLUDE)
       
   136 
       
   137 ### Copy jni_md.h
       
   138 
       
   139 # This might have been defined in a custom extension
       
   140 ifeq ($(JNI_MD_H_SRC), )
       
   141   JNI_MD_H_SRC := $(HOTSPOT_TOPDIR)/src/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm/jni_$(HOTSPOT_TARGET_CPU_ARCH).h
       
   142 endif
       
   143 
       
   144 ifeq ($(OPENJDK_TARGET_OS), macosx)
       
   145   # NOTE: This should most likely be darwin, but the old hotspot build uses bsd
       
   146   JNI_MD_SUBDIR := bsd
       
   147 else ifeq ($(OPENJDK_TARGET_OS), windows)
       
   148   JNI_MD_SUBDIR := win32
       
   149 else
       
   150   JNI_MD_SUBDIR := $(OPENJDK_TARGET_OS)
       
   151 endif
       
   152 
       
   153 # SetupCopyFiles is not used here since it's non-trivial to copy a single
       
   154 # file with a different target name.
       
   155 $(DIST_OUTPUTDIR)/include/$(JNI_MD_SUBDIR)/jni_md.h: $(JNI_MD_H_SRC)
       
   156 	$(call LogInfo, Copying hotspot/dist/include/$(JNI_MD_SUBDIR)/jni_md.h)
       
   157 	$(install-file)
       
   158 
       
   159 TARGETS += $(DIST_OUTPUTDIR)/include/$(JNI_MD_SUBDIR)/jni_md.h
       
   160 
       
   161 $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
       
   162     DEST := $(DIST_OUTPUTDIR)/include, \
       
   163     FLATTEN := true, \
       
   164     FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.h))
       
   165 
       
   166 TARGETS += $(COPY_JVMTI_H)
       
   167 
       
   168 # NOTE: In the old build, this file was not copied on Windows.
       
   169 ifneq ($(OPENJDK_TARGET_OS), windows)
       
   170   $(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
       
   171       DEST := $(DIST_OUTPUTDIR)/docs/platform/jvmti, \
       
   172       FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.html))
       
   173 endif
       
   174 
       
   175 TARGETS += $(COPY_JVMTI_HTML)
       
   176 
       
   177 ifeq ($(OPENJDK_TARGET_OS), windows)
       
   178   $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
       
   179       DEST := $(DIST_OUTPUTDIR)/lib, \
       
   180       FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib))
       
   181 
       
   182   TARGETS += $(COPY_JVM_LIB)
       
   183 endif
       
   184 
       
   185 # Copy libjsig, if it exists
       
   186 $(eval $(call SetupDistLibFile, DIST_jsig, \
       
   187     NAME := jsig, \
       
   188 ))
       
   189 
       
   190 ################################################################################
       
   191 # Copy variant-specific files
       
   192 
       
   193 # Setup make rules to copy a single variant to dist.
       
   194 # $1: The name of the variant
       
   195 define SetupDistForVariant
       
   196   ifneq ($$(filter client minimal, $1), )
       
   197     VARIANT_TARGET_DIR := $1
       
   198   else
       
   199     # Use 'server' as default target directory name for all other variants.
       
   200     VARIANT_TARGET_DIR := server
       
   201   endif
       
   202 
       
   203   $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm, \
       
   204       NAME := jvm, \
       
   205       VARIANT := $1, \
       
   206       VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
       
   207   ))
       
   208 
       
   209   # Copy the dtrace libraries, if they exist
       
   210   $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm_db, \
       
   211       NAME := jvm_db, \
       
   212       VARIANT := $1, \
       
   213       VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
       
   214   ))
       
   215 
       
   216   $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm_dtrace, \
       
   217       NAME := jvm_dtrace, \
       
   218       VARIANT := $1, \
       
   219       VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
       
   220   ))
       
   221 
       
   222   # Copy the Xusage.txt file
       
   223   $$(eval $$(call SetupCopyFiles, DIST_$(strip $1)_Xusage, \
       
   224       DEST := $$(DIST_OUTPUTDIR)/$$(LIB_SUBDIR)/$(strip $1), \
       
   225       FILES := $$(HOTSPOT_OUTPUTDIR)/variant-$(strip $1)/support/misc/Xusage.txt, \
       
   226   ))
       
   227 
       
   228   TARGETS += $$(DIST_$(strip $1)_Xusage)
       
   229 endef
       
   230 
       
   231 $(foreach variant, $(JVM_VARIANTS), \
       
   232   $(eval $(call SetupDistForVariant, $(variant))) \
       
   233 )
       
   234 
       
   235 ################################################################################
       
   236 
       
   237 all: $(TARGETS)
       
   238 
       
   239 .PHONY: all