1 #
   2 # Copyright (c) 2006, 2015, 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.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #
  23 #
  24 
  25 # The common definitions for hotspot linux builds.
  26 # Include the top level defs.make under make directory instead of this one.
  27 # This file is included into make/defs.make.
  28 
  29 SLASH_JAVA ?= /java
  30 
  31 define print_info
  32   ifneq ($$(LOG_LEVEL), warn)
  33     $$(shell echo >&2 "INFO: $1")
  34   endif
  35 endef
  36 
  37 # Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
  38 
  39 # ARCH can be set explicitly in spec.gmk
  40 ifndef ARCH
  41   ARCH := $(shell uname -m)
  42   # Fold little endian PowerPC64 into big-endian (if ARCH is set in
  43   # hotspot-spec.gmk, this will be done by the configure script).
  44   ifeq ($(ARCH),ppc64le)
  45     ARCH := ppc64
  46   endif
  47 endif
  48 
  49 PATH_SEP ?= :
  50 
  51 ifeq ($(LP64), 1)
  52   ARCH_DATA_MODEL ?= 64
  53 else
  54   ARCH_DATA_MODEL ?= 32
  55 endif
  56 
  57 # zero
  58 ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
  59   ifeq ($(ARCH_DATA_MODEL), 64)
  60     MAKE_ARGS      += LP64=1
  61   endif
  62   PLATFORM         = linux-zero
  63   VM_PLATFORM      = linux_$(subst i386,i486,$(ZERO_LIBARCH))
  64   HS_ARCH          = zero
  65   ARCH             = zero
  66 endif
  67 
  68 # ia64
  69 ifeq ($(ARCH), ia64)
  70   ARCH_DATA_MODEL = 64
  71   MAKE_ARGS      += LP64=1
  72   PLATFORM        = linux-ia64
  73   VM_PLATFORM     = linux_ia64
  74   HS_ARCH         = ia64
  75 endif
  76 
  77 # sparc
  78 ifneq (,$(findstring $(ARCH), sparc))
  79   ifeq ($(ARCH_DATA_MODEL), 64)
  80     ARCH_DATA_MODEL  = 64
  81     MAKE_ARGS        += LP64=1
  82     PLATFORM         = linux-sparcv9
  83     VM_PLATFORM      = linux_sparcv9
  84   else
  85     ARCH_DATA_MODEL  = 32
  86     PLATFORM         = linux-sparc
  87     VM_PLATFORM      = linux_sparc
  88   endif
  89   HS_ARCH            = sparc
  90 endif
  91 
  92 # i686/i586 and amd64/x86_64
  93 ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586))
  94   ifeq ($(ARCH_DATA_MODEL), 64)
  95     ARCH_DATA_MODEL = 64
  96     MAKE_ARGS       += LP64=1
  97     PLATFORM        = linux-amd64
  98     VM_PLATFORM     = linux_amd64
  99   else
 100     ARCH_DATA_MODEL = 32
 101     PLATFORM        = linux-i586
 102     VM_PLATFORM     = linux_i486
 103   endif
 104 
 105   HS_ARCH           = x86
 106 endif
 107 
 108 # PPC
 109 # Notice: after 8046471 ARCH will be 'ppc' for top-level ppc64 builds but
 110 # 'ppc64' for HotSpot-only ppc64 builds. Need to detect both variants here!
 111 ifneq (,$(findstring $(ARCH), ppc ppc64))
 112   ifeq ($(ARCH_DATA_MODEL), 64)
 113     MAKE_ARGS        += LP64=1
 114     PLATFORM         = linux-ppc64
 115     VM_PLATFORM      = linux_ppc64
 116   endif
 117 
 118   HS_ARCH = ppc
 119 endif
 120 
 121 # AARCH64
 122 ifeq ($(ARCH), aarch64)
 123   ARCH_DATA_MODEL  = 64
 124   MAKE_ARGS        += LP64=1
 125   PLATFORM         = linux-aarch64
 126   VM_PLATFORM      = linux_aarch64
 127   HS_ARCH          = aarch64
 128 endif
 129 
 130 # On 32 bit linux we build server and client, on 64 bit just server.
 131 ifeq ($(JVM_VARIANTS),)
 132   ifeq ($(ARCH_DATA_MODEL), 32)
 133     JVM_VARIANTS:=client,server
 134     JVM_VARIANT_CLIENT:=true
 135     JVM_VARIANT_SERVER:=true
 136   else
 137     JVM_VARIANTS:=server
 138     JVM_VARIANT_SERVER:=true
 139   endif
 140 endif
 141 
 142 # determine if HotSpot is being built in JDK6 or earlier version
 143 JDK6_OR_EARLIER=0
 144 ifeq "$(shell expr \( '$(JDK_MAJOR_VERSION)' != '' \& '$(JDK_MINOR_VERSION)' != '' \& '$(JDK_MICRO_VERSION)' != '' \))" "1"
 145   # if the longer variable names (newer build style) are set, then check those
 146   ifeq "$(shell expr \( $(JDK_MAJOR_VERSION) = 1 \& $(JDK_MINOR_VERSION) \< 7 \))" "1"
 147     JDK6_OR_EARLIER=1
 148   endif
 149 else
 150   # the longer variables aren't set so check the shorter variable names
 151   ifeq "$(shell expr \( '$(JDK_MAJOR_VER)' = 1 \& '$(JDK_MINOR_VER)' \< 7 \))" "1"
 152     JDK6_OR_EARLIER=1
 153   endif
 154 endif
 155 
 156 ifeq ($(JDK6_OR_EARLIER),0)
 157   # Full Debug Symbols is supported on JDK7 or newer.
 158   # The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
 159   # builds is enabled with debug info files ZIP'ed to save space. For
 160   # BUILD_FLAVOR != product builds, FDS is always enabled, after all a
 161   # debug build without debug info isn't very useful.
 162   # The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
 163   #
 164   # If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
 165   # disabled for a BUILD_FLAVOR == product build.
 166   #
 167   # Note: Use of a different variable name for the FDS override option
 168   # versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
 169   # versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
 170   # in options via environment variables, use of distinct variables
 171   # prevents strange behaviours. For example, in a BUILD_FLAVOR !=
 172   # product build, the FULL_DEBUG_SYMBOLS environment variable will be
 173   # 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
 174   # the same variable name is used, then different values can be picked
 175   # up by different parts of the build. Just to be clear, we only need
 176   # two variable names because the incoming option value can be
 177   # overridden in some situations, e.g., a BUILD_FLAVOR != product
 178   # build.
 179 
 180   # Due to the multiple sub-make processes that occur this logic gets
 181   # executed multiple times. We reduce the noise by at least checking that
 182   # BUILD_FLAVOR has been set.
 183   ifneq ($(BUILD_FLAVOR),)
 184     ifeq ($(BUILD_FLAVOR), product)
 185       FULL_DEBUG_SYMBOLS ?= 1
 186       ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
 187     else
 188       # debug variants always get Full Debug Symbols (if available)
 189       ENABLE_FULL_DEBUG_SYMBOLS = 1
 190     endif
 191     $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
 192     # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
 193 
 194     ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 195       # Default OBJCOPY comes from GNU Binutils on Linux
 196       ifeq ($(CROSS_COMPILE_ARCH),)
 197         DEF_OBJCOPY=/usr/bin/objcopy
 198       else
 199         # Assume objcopy is part of the cross-compilation toolset
 200         ifneq ($(ALT_COMPILER_PATH),)
 201           DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy
 202         endif
 203       endif
 204       OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
 205       ifneq ($(ALT_OBJCOPY),)
 206         $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)"))
 207         OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
 208       endif
 209 
 210       ifeq ($(OBJCOPY),)
 211         $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files. You may need to set ALT_OBJCOPY."))
 212         ENABLE_FULL_DEBUG_SYMBOLS=0
 213         $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
 214       else
 215         $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files."))
 216 
 217         # Library stripping policies for .debuginfo configs:
 218         #   all_strip - strips everything from the library
 219         #   min_strip - strips most stuff from the library; leaves minimum symbols
 220         #   no_strip  - does not strip the library at all
 221         #
 222         # Oracle security policy requires "all_strip". A waiver was granted on
 223         # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
 224         #
 225         # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
 226         #
 227         STRIP_POLICY ?= min_strip
 228 
 229         $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)"))
 230 
 231         ZIP_DEBUGINFO_FILES ?= 1
 232 
 233         $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)"))
 234       endif
 235     endif # ENABLE_FULL_DEBUG_SYMBOLS=1
 236   endif # BUILD_FLAVOR
 237 endif # JDK_6_OR_EARLIER
 238 
 239 JDK_INCLUDE_SUBDIR=linux
 240 
 241 # Library suffix
 242 LIBRARY_SUFFIX=so
 243 
 244 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 245 
 246 # client and server subdirectories have symbolic links to ../libjsig.so
 247 EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
 248 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 249   ifeq ($(ZIP_DEBUGINFO_FILES),1)
 250     EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.diz
 251   else
 252     EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.debuginfo
 253   endif
 254 endif
 255 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
 256 EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
 257 EXPORT_MINIMAL_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/minimal
 258 
 259 ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK) $(JVM_VARIANT_CORE)), true)
 260   EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
 261   EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
 262   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 263     ifeq ($(ZIP_DEBUGINFO_FILES),1)
 264       EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz
 265     else
 266       EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
 267     endif
 268   endif
 269 endif
 270 
 271 ifeq ($(JVM_VARIANT_CLIENT),true)
 272   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
 273   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
 274   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 275     ifeq ($(ZIP_DEBUGINFO_FILES),1)
 276       EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz
 277     else
 278       EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
 279     endif
 280   endif
 281 endif
 282 
 283 ifeq ($(JVM_VARIANT_MINIMAL1),true)
 284   EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/Xusage.txt
 285   EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX)
 286 
 287   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 288     ifeq ($(ZIP_DEBUGINFO_FILES),1)
 289         EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.diz
 290     else
 291         EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo
 292     endif
 293   endif
 294 endif
 295 
 296 # Serviceability Binaries
 297 
 298 ADD_SA_BINARIES/DEFAULT = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
 299                           $(EXPORT_LIB_DIR)/sa-jdi.jar
 300 
 301 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 302   ifeq ($(ZIP_DEBUGINFO_FILES),1)
 303     ADD_SA_BINARIES/DEFAULT += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz
 304   else
 305     ADD_SA_BINARIES/DEFAULT += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
 306   endif
 307 endif
 308 
 309 ADD_SA_BINARIES/$(HS_ARCH) = $(ADD_SA_BINARIES/DEFAULT)
 310 
 311 # No SA Support for zero
 312 ADD_SA_BINARIES/zero  =
 313 
 314 -include $(HS_ALT_MAKE)/linux/makefiles/defs.make
 315 
 316 EXPORT_LIST += $(ADD_SA_BINARIES/$(HS_ARCH))