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 bsd 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 ARCH:=$(shell uname -m)
  39 PATH_SEP = :
  40 ifeq ($(LP64), 1)
  41   ARCH_DATA_MODEL ?= 64
  42 else
  43   ARCH_DATA_MODEL ?= 32
  44 endif
  45 
  46 # zero
  47 ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
  48   ifeq ($(ARCH_DATA_MODEL), 64)
  49     MAKE_ARGS      += LP64=1
  50   endif
  51   PLATFORM         = bsd-zero
  52   VM_PLATFORM      = bsd_$(subst i386,i486,$(ZERO_LIBARCH))
  53   HS_ARCH          = zero
  54   ARCH             = zero
  55 endif
  56 
  57 # ia64
  58 ifeq ($(ARCH), ia64)
  59   ARCH_DATA_MODEL = 64
  60   MAKE_ARGS      += LP64=1
  61   PLATFORM        = bsd-ia64
  62   VM_PLATFORM     = bsd_ia64
  63   HS_ARCH         = ia64
  64 endif
  65 
  66 # sparc
  67 ifeq ($(ARCH), sparc64)
  68   ifeq ($(ARCH_DATA_MODEL), 64)
  69     ARCH_DATA_MODEL  = 64
  70     MAKE_ARGS        += LP64=1
  71     PLATFORM         = bsd-sparcv9
  72     VM_PLATFORM      = bsd_sparcv9
  73   else
  74     ARCH_DATA_MODEL  = 32
  75     PLATFORM         = bsd-sparc
  76     VM_PLATFORM      = bsd_sparc
  77   endif
  78   HS_ARCH            = sparc
  79 endif
  80 
  81 # amd64
  82 ifneq (,$(findstring $(ARCH), amd64 x86_64))
  83   ifeq ($(ARCH_DATA_MODEL), 64)
  84     ARCH_DATA_MODEL = 64
  85     MAKE_ARGS       += LP64=1
  86     PLATFORM        = bsd-amd64
  87     VM_PLATFORM     = bsd_amd64
  88     HS_ARCH         = x86
  89   else
  90     ARCH_DATA_MODEL = 32
  91     PLATFORM        = bsd-i586
  92     VM_PLATFORM     = bsd_i486
  93     HS_ARCH         = x86
  94     # We have to reset ARCH to i386 since SRCARCH relies on it
  95     ARCH            = i386
  96   endif
  97 endif
  98 
  99 # i386
 100 ifeq ($(ARCH), i386)
 101   ifeq ($(ARCH_DATA_MODEL), 64)
 102     ARCH_DATA_MODEL = 64
 103     MAKE_ARGS       += LP64=1
 104     PLATFORM        = bsd-amd64
 105     VM_PLATFORM     = bsd_amd64
 106     HS_ARCH         = x86
 107     # We have to reset ARCH to amd64 since SRCARCH relies on it
 108     ARCH            = amd64
 109   else
 110     ARCH_DATA_MODEL  = 32
 111     PLATFORM         = bsd-i586
 112     VM_PLATFORM      = bsd_i486
 113     HS_ARCH          = x86
 114   endif
 115 endif
 116 
 117 # ARM
 118 ifeq ($(ARCH), arm)
 119   ARCH_DATA_MODEL  = 32
 120   PLATFORM         = bsd-arm
 121   VM_PLATFORM      = bsd_arm
 122   HS_ARCH          = arm
 123 endif
 124 
 125 # PPC
 126 ifeq ($(ARCH), ppc)
 127   ARCH_DATA_MODEL  = 32
 128   PLATFORM         = bsd-ppc
 129   VM_PLATFORM      = bsd_ppc
 130   HS_ARCH          = ppc
 131 endif
 132 
 133 # On 32 bit bsd we build server and client, on 64 bit just server.
 134 ifeq ($(JVM_VARIANTS),)
 135   ifeq ($(ARCH_DATA_MODEL), 32)
 136     JVM_VARIANTS:=client,server
 137     JVM_VARIANT_CLIENT:=true
 138     JVM_VARIANT_SERVER:=true
 139   else
 140     JVM_VARIANTS:=server
 141     JVM_VARIANT_SERVER:=true
 142   endif
 143 endif
 144 
 145 OS_VENDOR:=$(shell uname -s)
 146 
 147 # The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product
 148 # builds is enabled with debug info files ZIP'ed to save space. For
 149 # BUILD_FLAVOR != product builds, FDS is always enabled, after all a
 150 # debug build without debug info isn't very useful.
 151 # The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled.
 152 #
 153 # If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
 154 # disabled for a BUILD_FLAVOR == product build.
 155 #
 156 # Note: Use of a different variable name for the FDS override option
 157 # versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
 158 # versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
 159 # in options via environment variables, use of distinct variables
 160 # prevents strange behaviours. For example, in a BUILD_FLAVOR !=
 161 # product build, the FULL_DEBUG_SYMBOLS environment variable will be
 162 # 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If
 163 # the same variable name is used, then different values can be picked
 164 # up by different parts of the build. Just to be clear, we only need
 165 # two variable names because the incoming option value can be
 166 # overridden in some situations, e.g., a BUILD_FLAVOR != product
 167 # build.
 168 
 169 # Due to the multiple sub-make processes that occur this logic gets
 170 # executed multiple times. We reduce the noise by at least checking that
 171 # BUILD_FLAVOR has been set.
 172 ifneq ($(BUILD_FLAVOR),)
 173   # FULL_DEBUG_SYMBOLS not created for individual static libraries
 174   ifeq ($(STATIC_BUILD),false)
 175     ifeq ($(BUILD_FLAVOR), product)
 176       FULL_DEBUG_SYMBOLS ?= 1
 177       ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
 178     else
 179       # debug variants always get Full Debug Symbols (if available)
 180       ENABLE_FULL_DEBUG_SYMBOLS = 1
 181     endif
 182   endif
 183   $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
 184   # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
 185 
 186   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 187     ifeq ($(OS_VENDOR), Darwin)
 188         # MacOS X doesn't use OBJCOPY or STRIP_POLICY
 189         OBJCOPY=
 190         STRIP_POLICY=
 191         ZIP_DEBUGINFO_FILES ?= 1
 192     else
 193       # Default OBJCOPY comes from GNU Binutils on BSD
 194       ifeq ($(CROSS_COMPILE_ARCH),)
 195         DEF_OBJCOPY=/usr/bin/objcopy
 196       else
 197         # Assume objcopy is part of the cross-compilation toolset
 198         ifneq ($(ALT_COMPILER_PATH),)
 199           DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy
 200         endif
 201       endif
 202       OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
 203       ifneq ($(ALT_OBJCOPY),)
 204         $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)"))
 205         OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
 206       endif
 207 
 208       ifeq ($(COPY_DEBUG_SYMBOLS), true)
 209         ifeq ($(OBJCOPY),)
 210           $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo" \
 211               "files. You may need to set ALT_OBJCOPY."))
 212           ENABLE_FULL_DEBUG_SYMBOLS=0
 213           COPY_DEBUG_SYMBOLS=false
 214           $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)"))
 215         else
 216           $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo" \
 217               "files."))
 218 
 219           # Library stripping policies for .debuginfo configs:
 220           #   all_strip - strips everything from the library
 221           #   min_strip - strips most stuff from the library; leaves
 222           #               minimum symbols
 223           #   no_strip  - does not strip the library at all
 224           #
 225           # Oracle security policy requires "all_strip". A waiver was
 226           # granted on 2011.09.01 that permits using "min_strip" in the
 227           # Java JDK and Java JRE.
 228           #
 229           # Currently, STRIP_POLICY is only used when Full Debug Symbols
 230           # is enabled.
 231           #
 232           STRIP_POLICY ?= min_strip
 233 
 234           $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)"))
 235 
 236           ZIP_DEBUGINFO_FILES ?= 1
 237         endif
 238 
 239         $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)"))
 240       endif
 241     endif # COPY_DEBUG_SYMBOLS=true
 242   endif # ENABLE_FULL_DEBUG_SYMBOLS=1
 243 endif # BUILD_FLAVOR
 244 
 245 JDK_INCLUDE_SUBDIR=bsd
 246 
 247 # Library suffix
 248 ifneq ($(STATIC_BUILD),true)
 249 ifeq ($(OS_VENDOR),Darwin)
 250   LIBRARY_SUFFIX=dylib
 251 else
 252   LIBRARY_SUFFIX=so
 253 endif
 254 else
 255   LIBRARY_SUFFIX=a
 256 endif
 257 
 258 
 259 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 260 
 261 # jsig library not needed for static builds
 262 ifneq ($(STATIC_BUILD),true)
 263   # client and server subdirectories have symbolic links to ../libjsig.so
 264   EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
 265 endif
 266 
 267 ifeq ($(COPY_DEBUG_SYMBOLS),true)
 268   ifeq ($(ZIP_DEBUGINFO_FILES),1)
 269       EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz
 270   else
 271     ifeq ($(OS_VENDOR), Darwin)
 272         EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX).dSYM
 273     else
 274         EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo
 275     endif
 276   endif
 277 endif
 278 
 279 EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server
 280 EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client
 281 EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal
 282 
 283 ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
 284   EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
 285   EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
 286   ifeq ($(STATIC_BUILD),true)
 287     EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.symbols
 288   endif
 289 
 290   ifeq ($(COPY_DEBUG_SYMBOLS),true)
 291     ifeq ($(ZIP_DEBUGINFO_FILES),1)
 292         EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz
 293     else
 294       ifeq ($(OS_VENDOR), Darwin)
 295           EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX).dSYM
 296       else
 297           EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
 298       endif
 299     endif
 300   endif
 301 endif
 302 
 303 ifeq ($(JVM_VARIANT_CLIENT),true)
 304   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
 305   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
 306   ifeq ($(STATIC_BUILD),true)
 307     EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.symbols
 308   endif
 309 
 310   ifeq ($(COPY_DEBUG_SYMBOLS),true)
 311     ifeq ($(ZIP_DEBUGINFO_FILES),1)
 312         EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz
 313     else
 314       ifeq ($(OS_VENDOR), Darwin)
 315           EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX).dSYM
 316       else
 317           EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
 318       endif
 319     endif
 320   endif
 321 endif
 322 
 323 ifeq ($(JVM_VARIANT_MINIMAL1),true)
 324   EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/Xusage.txt
 325   EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX)
 326   ifeq ($(STATIC_BUILD),true)
 327     EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.symbols
 328   endif
 329 endif
 330 
 331 # Universal build settings
 332 ifeq ($(OS_VENDOR), Darwin)
 333   # Build universal binaries by default on Mac OS X
 334   MACOSX_UNIVERSAL = true
 335   ifneq ($(ALT_MACOSX_UNIVERSAL),)
 336     MACOSX_UNIVERSAL = $(ALT_MACOSX_UNIVERSAL)
 337   endif
 338   MAKE_ARGS += MACOSX_UNIVERSAL=$(MACOSX_UNIVERSAL)
 339 
 340   # Universal settings
 341   ifeq ($(MACOSX_UNIVERSAL), true)
 342 
 343     # Set universal export path but avoid using ARCH or PLATFORM subdirs
 344     EXPORT_PATH=$(OUTPUTDIR)/export-universal$(EXPORT_SUBDIR)
 345     ifneq ($(ALT_EXPORT_PATH),)
 346       EXPORT_PATH=$(ALT_EXPORT_PATH)
 347     endif
 348 
 349     # Set universal image dir
 350     JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-universal$(EXPORT_SUBDIR)
 351     ifneq ($(ALT_JDK_IMAGE_DIR),)
 352       JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR)
 353     endif
 354 
 355     # Binaries to 'universalize' if built
 356     ifneq ($(STATIC_BUILD),true)
 357     UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX)
 358     endif
 359     UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX)
 360     UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX)
 361 
 362     # Files to simply copy in place
 363     UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/Xusage.txt
 364     UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/Xusage.txt
 365 
 366     ifeq ($(STATIC_BUILD),true)
 367       UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.symbols
 368       UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.symbols
 369       UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/minimal/libjvm.symbols
 370     endif
 371 
 372     ifeq ($(COPY_DEBUG_SYMBOLS),true)
 373       ifeq ($(ZIP_DEBUGINFO_FILES),1)
 374           UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.diz
 375           UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.diz
 376           UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/libjsig.diz
 377       else
 378           UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX).dSYM
 379           UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX).dSYM
 380           UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX).dSYM
 381       endif
 382     endif
 383 
 384   endif
 385 endif