Defs-solaris.gmk 28.1 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6
# 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
7
# published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
10 11 12 13 14 15 16 17 18 19 20
#
# 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.
#
21 22 23
# 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.
D
duke 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#

#
# Makefile to specify compiler flags for programs and libraries
# targeted to Solaris.  Should not contain any rules.
#
# WARNING: This file is shared with other workspaces. 
#          So when it includes other files, it must use JDK_TOPDIR.
#

# Warning: the following variables are overridden by Defs.gmk. Set
# values will be silently ignored:
#   CFLAGS        (set $(OTHER_CFLAGS) instead)
#   CPPFLAGS      (set $(OTHER_CPPFLAGS) instead)
#   CXXFLAGS      (set $(OTHER_CXXFLAGS) instead)
#   LDFLAGS       (set $(OTHER_LDFAGS) instead)
#   LDLIBS        (set $(EXTRA_LIBS) instead)
#   LDLIBS_COMMON (set $(EXTRA_LIBS) instead)
#   LINTFLAGS     (set $(OTHER_LINTFLAGS) instead)
43 44 45
#
# Note: CPPFLAGS are used in C and C++ compiles.
#
D
duke 已提交
46 47 48 49 50

# Get shared JDK settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk

ifndef PLATFORM_SRC
51
PLATFORM_SRC = $(BUILDDIR)/../src/solaris
D
duke 已提交
52 53
endif # PLATFORM_SRC

54 55 56 57 58
# Location of the various .properties files specific to Solaris platform
ifndef PLATFORM_PROPERTIES
  PLATFORM_PROPERTIES  = $(BUILDDIR)/../src/solaris/lib
endif # PLATFORM_SRC

D
duke 已提交
59 60 61
# Platform specific closed sources
ifndef OPENJDK
  ifndef CLOSED_PLATFORM_SRC
62
    CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
D
duke 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
  endif
endif

# platform specific include files
PLATFORM_INCLUDE_NAME = $(PLATFORM)
PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)

# suffix used for make dependencies files
DEPEND_SUFFIX = d
# suffix used for lint files
LINT_SUFFIX = ln
# The suffix applied to the library name for FDLIBM
FDDLIBM_SUFFIX = a
# The suffix applied to scripts (.bat for windows, nothing for unix)
SCRIPT_SUFFIX =
# CC compiler object code output directive flag value
CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
# The Full Debug Symbols (FDS) default for VARIANT == OPT builds is
# enabled with debug info files ZIP'ed to save space. For VARIANT !=
# OPT builds, FDS is always enabled, after all a debug build without
# debug info isn't very useful. The ZIP_DEBUGINFO_FILES option only has
# meaning when FDS is enabled.
#
# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
# disabled for a VARIANT == OPT build.
#
# Note: Use of a different variable name for the FDS override option
# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
# in options via environment variables, use of distinct variables
# prevents strange behaviours. For example, in a VARIANT != OPT build,
# the FULL_DEBUG_SYMBOLS environment variable will be 0, but the
# ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If the same
# variable name is used, then different values can be picked up by
# different parts of the build. Just to be clear, we only need two
# variable names because the incoming option value can be overridden
# in some situations, e.g., a VARIANT != OPT build.
101

102 103 104
ifeq ($(VARIANT), OPT)
  FULL_DEBUG_SYMBOLS ?= 1
  ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
105
else
106 107
  # debug variants always get Full Debug Symbols (if available)
  ENABLE_FULL_DEBUG_SYMBOLS = 1
108
endif
109 110
_JUNK_ := $(shell \
  echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
# since objcopy is optional, we set ZIP_DEBUGINFO_FILES later

ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
  # Default OBJCOPY comes from the SUNWbinutils package:
  DEF_OBJCOPY=/usr/sfw/bin/gobjcopy
  ifeq ($(PLATFORM)-$(LIBARCH), solaris-amd64)
    # On Solaris AMD64/X64, gobjcopy is not happy and fails:
    #
    # usr/sfw/bin/gobjcopy --add-gnu-debuglink=<lib>.debuginfo <lib>.so
    # BFD: stKPaiop: Not enough room for program headers, try linking with -N
    # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
    # BFD: stKPaiop: Not enough room for program headers, try linking with -N
    # /usr/sfw/bin/gobjcopy: libsaproc.debuginfo: Bad value
    # BFD: stKPaiop: Not enough room for program headers, try linking with -N
    # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
    _JUNK_ := $(shell \
      echo >&2 "INFO: $(DEF_OBJCOPY) is not working on Solaris AMD64/X64")
    OBJCOPY=
  else
    OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
    ifneq ($(ALT_OBJCOPY),)
      _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
      # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
      OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
    endif
136 137
  endif

138 139 140
  # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
  # JDK build to import .debuginfo or .diz files from the HotSpot build.
  # However, adding FDS support to the JDK build will occur in phases
D
dcubed 已提交
141 142 143
  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
  # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
  # particular library or program supports FDS.
144

145 146 147 148
  ifeq ($(OBJCOPY),)
    _JUNK_ := $(shell \
      echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
    ENABLE_FULL_DEBUG_SYMBOLS=0
149
  else
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
    _JUNK_ := $(shell \
      echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")

    # Library stripping policies for .debuginfo configs:
    #   all_strip - strips everything from the library
    #   min_strip - strips most stuff from the library; leaves minimum symbols
    #   no_strip  - does not strip the library at all
    #
    # Oracle security policy requires "all_strip". A waiver was granted on
    # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
    #
    #
    # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
    STRIP_POLICY ?= min_strip

    _JUNK_ := $(shell \
      echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")

168
    ZIP_DEBUGINFO_FILES ?= 1
169 170 171

    _JUNK_ := $(shell \
      echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
172 173 174
  endif
endif

D
duke 已提交
175 176 177
#
# Java default optimization (-x04/-O2) etc.  Applies to the VM.
#
178 179 180 181 182 183
ifndef OPTIMIZATION_LEVEL
  ifeq ($(PRODUCT), java)
    OPTIMIZATION_LEVEL = HIGHER
  else
    OPTIMIZATION_LEVEL = LOWER
  endif
D
duke 已提交
184
endif
185 186 187
ifndef FASTDEBUG_OPTIMIZATION_LEVEL
  FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
endif
D
duke 已提交
188 189

#
190
# If -Xa is in CFLAGS_COMMON it will end up ahead of $(CC_OPT) for the
D
duke 已提交
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
# optimized build, and that ordering of the flags completely freaks
# out cc.  Hence, -Xa is instead in each CFLAGS variant.
#
# The more unusual options to the Sun C compiler:
#	-v		Stricter type checking, more error checking
#			(To turn ALL warnings into fatals, use -errwarn=%all)
#	-xstrconst	Place string literals and constants in read-only area
#			(means you can't write on your string literals)
#	-xs		Force debug information (stabs) into the .so or a.out
#			(makes the library/executable debuggable without the
#			.o files needing to be around, but at a space cost)
#	-g & -O		If you add the -g option to the optimized compiles
#			you will get better stack retraces, the code is
#			still optimized. This includes a space cost too.
#       -xc99=%none     Do NOT allow for c99 extensions to be used.
#                       e.g. declarations must precede statements
#       -xCC            Allow the C++ style of comments in C: //
#                       Required with many of the source files.
#       -mt             Assume multi-threaded (important)
#
211 212 213 214
# The more unusual options to the Sun C compiler:
#       +w              Print more warnings
#       +w2             Maximum warnings
#
D
duke 已提交
215 216 217 218

#
# Debug flag for C and C++ compiler
#
219 220
CFLAGS_DEBUG_OPTION    = -g $(CC_OPT/NONE)
CXXFLAGS_DEBUG_OPTION  = -g $(CXX_OPT/NONE)
D
duke 已提交
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237

# Turn off -g if we are doing tcov build
ifdef TCOV_BUILD
  CFLAGS_DEBUG_OPTION=
  CXXFLAGS_DEBUG_OPTION=
endif

# FASTDEBUG: Optimize the -g builds, gives us a faster debug java
#        If true adds -O to the debug compiles. This allows for any assert
#        tests to remain and debug checking. The resulting code is faster
#        but less debuggable.  Stack traces are still valid, although only
#        approximate line numbers are given. Printing of local variables
#        during a debugging session is not possible, but stepping and
#        printing of global or static variables should be possible.
#        Performance/size of files should be about the same, maybe smaller.
#
ifeq ($(FASTDEBUG), true)
238 239
  CFLAGS_DEBUG_OPTION    = -g  $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
  CXXFLAGS_DEBUG_OPTION  = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
D
duke 已提交
240 241
endif

D
dcubed 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
# If Full Debug Symbols is enabled, then we want the same debug and
# optimization flags as used by FASTDEBUG. We also want all the
# debug info in one place (-xs).
#
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
  ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
    ifeq ($(VARIANT), OPT)
      CC_OPT   = -g  -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
      CXX_OPT  = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
    endif
    CFLAGS_DEBUG_OPTION    += -xs
    CXXFLAGS_DEBUG_OPTION  += -xs
  endif
endif

257 258 259 260 261 262
CFLAGS_COMMON   = -L$(OBJDIR)

# Do not allow C99 language features like declarations in code etc.
CFLAGS_COMMON  += -xc99=%none

# Allow C++ comments in C code
D
duke 已提交
263
CFLAGS_COMMON  += -xCC
264 265 266 267 268 269

# Show error message tags on errors
CFLAGS_COMMON   += -errshort=tags
CXXFLAGS_COMMON += -errtags=yes

# Optimization flags
270
CFLAGS_OPT      = $(CC_OPT)
271 272

# Debug version flags
D
duke 已提交
273
CFLAGS_DBG      = $(CFLAGS_DEBUG_OPTION)
274 275 276 277 278 279 280

# Required C compiler flags
CFLAGS_COMMON  += -Xa $(CFLAGS_REQUIRED)

# Maximum warnings all the time
CXXFLAGS_COMMON += +w
CFLAGS_COMMON   += -v
D
duke 已提交
281 282

# Assume MT behavior all the time (important)
283 284
CXXFLAGS_COMMON += -mt
CFLAGS_COMMON   += -mt
D
duke 已提交
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306

# Assume no C++ exceptions are used
CXXFLAGS_COMMON += -features=no%except -DCC_NOEX

# For C++, these options tell it to assume nothing about locating libraries
#    either at compile time, or at runtime. Use of these options will likely
#    require the use of -L and -R options to indicate where libraries will
#    be found at compile time (-L) and at runtime (-R).
#    The /usr/lib location comes for free, so no need to specify that one.
#    Note: C is much simplier and there is no need for these options. This
#          is mostly needed to avoid dependencies on libraries in the
#          Compiler install area, also see LIBCXX and LIBM.
CXXFLAGS_COMMON += -norunpath -xnolib

#
# Treat compiler warnings as errors, if requested
#
ifeq ($(COMPILER_WARNINGS_FATAL),true)
  CFLAGS_COMMON += -errwarn=%all
  CXXFLAGS_COMMON += -errwarn=%all
endif

307
CXXFLAGS_OPT	= $(CXX_OPT)
D
duke 已提交
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
CXXFLAGS_DBG	= $(CXXFLAGS_DEBUG_OPTION)
CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)

# Add -xstrconst to the library compiles. This forces all string
#  literals into the read-only data section, which prevents them from
#  being written to and increases the runtime pages shared on the system.
#
ifdef LIBRARY
  CFLAGS_COMMON +=-xstrconst
endif

# Source browser database
#
# COMPILE_WITH_SB    
#        If defined adds -xsb to compiles and creates a
#        source browsing database during compilation.
#
ifdef COMPILE_WITH_SB
  ifeq ($(LIBRARY), java)
    CFLAGS_DBG +=   -xsb
  endif
endif

# Lint Flags:
#	-Xa			ANSI C plus K&R, favor ANSI rules
#	-fd			report on old style func defs
#	-errchk=structarg	report on 64bit struct args by value
#	-errchk=longptr64	report on 64bit to 32bit issues (ignores casts)
#	-errchk=parentheses	report on suggested use of extra parens
#	-v 			suppress unused args
#	-x			suppress unused externs
#	-u			suppress extern func/vars used/defined
#	-errfmt=simple		use one line errors with position info
341
#       $(LINT_XARCH_OPTION)    See Compiler-sun.gwk
D
duke 已提交
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359

LINTFLAGS_COMMON  = -Xa
LINTFLAGS_COMMON += -fd 
LINTFLAGS_COMMON += -errchk=structarg,longptr64,parentheses
LINTFLAGS_COMMON += -v
LINTFLAGS_COMMON += -x 
LINTFLAGS_COMMON += -u
LINTFLAGS_COMMON += -errfmt=simple 
LINTFLAGS_OPT   = 
LINTFLAGS_DBG   =

# The -W0,-noglobal tells the compiler to NOT generate mangled global
#    ELF data symbols for file local static data.
#    This can break fix&continue, but we'd rather do the same compilations
#    for deliverable bits as we do for non-deliverable bits
#    Tell the compilers to never generate globalized names, all the time.
CFLAGS_COMMON += -W0,-noglobal

360 361 362 363 364 365
# If we have a specific arch value to use, add it
CFLAGS_COMMON    += $(XARCH_OPTION)
CXXFLAGS_COMMON  += $(XARCH_OPTION)
ASFLAGS_COMMON   += $(AS_XARCH_OPTION)
EXTRA_LIBS       += $(XARCH_OPTION)
LINTFLAGS_COMMON += $(LINT_XARCH_OPTION)
D
duke 已提交
366 367 368 369 370 371 372

#
# uncomment the following to build with PERTURBALOT set
#
# OTHER_CFLAGS += -DPERTURBALOT
#

373 374
CPPFLAGS_COMMON = -D__solaris__  -D$(ARCH_FAMILY)
CPPFLAGS_OPT    = -DNDEBUG
D
duke 已提交
375 376
CPPFLAGS_DBG    = -DDEBUG

377 378 379 380
ifneq ($(PRODUCT), java)
  CPPFLAGS_DBG    += -DLOGGING -DDBINFO
endif

D
duke 已提交
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
ifeq ($(ARCH_FAMILY), i586)
  # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
  #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
  #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
  #   Note: -Dmacro         is the same as    #define macro 1
  #         -Dmacro=	    is the same as    #define macro
  #
  CPPFLAGS_COMMON +=  -DcpuIntel -D_LITTLE_ENDIAN= -D$(LIBARCH)
  # Turn off a superfluous compiler error message on Intel
  CFLAGS_COMMON += -erroff=E_BAD_PRAGMA_PACK_VALUE
endif

# Java memory management is based on memory mapping by default, but a
# system only assuming malloc/free can be built by adding -DUSE_MALLOC 

CPPFLAGS_COMMON	+= -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS
CPPFLAGS_OPT	+= -DTRIMMED

LDFLAGS_DEFS_OPTION  = -z defs
LDFLAGS_COMMON  += $(LDFLAGS_DEFS_OPTION)

#
# -L paths for finding and -ljava
#
LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
LDFLAGS_OPT     =
LDFLAGS_DBG     =

#
# We never really want the incremental linker, ever
#    The -xildoff option tells Sun's compilers to NOT use incremental linker
#
LDFLAGS_COMMON  += -xildoff

ifdef LIBRARY
  # Libraries need to locate other libraries at runtime, and you can tell
  #   a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
  #   buried inside the .so. The $ORIGIN says to look relative to where
  #   the library itself is and it can be followed with relative paths from
  #   that. By default we always look in $ORIGIN, optionally we add relative
  #   paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
  #   The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
  #   Try: 'dump -Lv lib*.so' to see these settings in a library.
  #
  LDFLAGS_COMMON += -R\$$ORIGIN
  LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-R\$$ORIGIN/%)
endif

EXTRA_LIBS += -lc

# Postprocessing is done on the images directories only
#
ifeq ($(VARIANT), OPT)
  ifeq ($(PARTIAL_GPROF), true)
    NO_STRIP = true
  endif
  ifeq ($(GPROF), true)
    NO_STRIP = true
  endif
  ifneq ($(NO_STRIP), true)
    # Debug 'strip -x' leaves local function Elf symbols (better stack traces)
    POST_STRIP_PROCESS = $(STRIP) -x
  endif
endif
POST_MCS_PROCESS=$(MCS) -d -a "JDK $(FULL_VERSION)"

#
# Sun C compiler will take -M and pass it on to ld.
# Usage: ld $(LD_MAPFILE_FLAG) mapfile *.o
#
ifeq ($(CC_VERSION),gcc)
LD_MAPFILE_FLAG = -Xlinker -M -Xlinker
else
LD_MAPFILE_FLAG = -M
endif

#
# Variables globally settable from the make command line (default
# values in brackets):
#	GPROF (false)
# Eg: 	% gnumake GPROF=true
GPROF = false
ifeq ($(GPROF), true)
    CFLAGS_COMMON += -DGPROF -xpg
    EXTRA_LIBS += -xpg
endif

# PARTIAL_GPROF is to be used ONLY during compilation - it should not
# appear during linking of libraries or programs.  It also should
# prevent linking with -z defs to allow a symbol to remain undefined.
#
PARTIAL_GPROF = false
ifeq ($(PARTIAL_GPROF), true)
  CFLAGS_GPROF += -xpg
  LDFLAGS_DEFS_OPTION  = -z nodefs
endif

#
# For a TCOV build we add in the TCOV_OPTION
#
ifdef TCOV_BUILD
  TCOV_OPTION		= -xprofile=tcov
  LDFLAGS_COMMON 	+= $(TCOV_OPTION) -Kpic
  CFLAGS_COMMON  	+= $(TCOV_OPTION)
  CXXFLAGS_COMMON 	+= $(TCOV_OPTION)
  EXTRA_LIBS 	+= $(TCOV_OPTION)
  LDNOMAP=true
endif

#
# Solaris only uses native threads. 
#
THREADS_FLAG=	native
THREADS_DIR=	threads

#
# Support for Quantify.
#
ifdef QUANTIFY
  QUANTIFY_CMD = quantify
  QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
  LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
  ifdef LIBRARY
    CFLAGS_COMMON += -K PIC
  endif
endif

#
# Support for Purify.
#
ifdef PURIFY
  PURIFY_CMD = /net/suntools.eng/export/tools/sparc/bin/purify
  PURIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
  LINK_PRE_CMD = $(PURIFY_CMD) $(PURIFY_OPTIONS)
  ifdef LIBRARY
    CFLAGS_COMMON += -K PIC
  endif
endif

#
# Different "levels" of optimization.
#
ifeq ($(CC_VERSION),gcc)
524 525 526 527 528 529 530 531 532 533 534
  
  CC_OPT/NONE     =
  CC_OPT/LOWER    = -O2
  CC_OPT/HIGHER   = -O3
  CC_OPT/HIGHEST  = -O3

  CXX_OPT/NONE    =
  CXX_OPT/LOWER   = -O2
  CXX_OPT/HIGHER  = -O3
  CXX_OPT/HIGHEST = -O3

D
duke 已提交
535 536
  CFLAGS_REQUIRED_i586  += -fno-omit-frame-pointer
  CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer
537
  
D
duke 已提交
538 539 540
  # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
  #   (See Rules.gmk) May need to wait for gcc 5?
  AUTOMATIC_PCH_OPTION = 
541

D
duke 已提交
542
else
543
  
D
duke 已提交
544 545
  # Highest could be -xO5, but indications are that -xO5 should be reserved
  #    for a per-file use, on sources with known performance impacts.
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
  OPT_LEVEL/LOWER    = 2
  OPT_LEVEL/HIGHER   = 4
  OPT_LEVEL/HIGHEST  = 4
  
  CC_OPT/NONE     =
  CC_OPT/LOWER    = $(OPT_LEVEL/LOWER:%=-xO%)
  CC_OPT/HIGHER   = $(OPT_LEVEL/HIGHER:%=-xO%)
  CC_OPT/HIGHEST  = $(OPT_LEVEL/HIGHEST:%=-xO%)
  
  CXX_OPT/NONE    =
  CXX_OPT/LOWER   = $(OPT_LEVEL/LOWER:%=-xO%)
  CXX_OPT/HIGHER  = $(OPT_LEVEL/HIGHER:%=-xO%)
  CXX_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%)
    
  # We need stack frames at all times
  USE_XKEEPFRAME_OPTION = false
  ifeq ($(USE_XKEEPFRAME_OPTION),true)
    
    # Unknown spelling on this option at this time (Maybe in SS13?)
    CC_XKEEPFRAME_OPTIONS  = -xkeepframe
    CXX_XKEEPFRAME_OPTIONS = -xkeepframe
  
  else
  
    # On X86, make sure tail call optimization is off
    #    The z and y are the tail call optimizations.
    ifeq ($(ARCH_FAMILY), i586)
573 574 575 576 577 578 579 580 581
      CC_NEWER_THAN_58 := \
        $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
	    \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 8 \) )
      ifeq ($(CC_NEWER_THAN_58),1)
        #    Somehow, tail call optimization is creeping in.
        #    Make sure it is off.
        # WARNING: These may cause compiler warnings about duplicate -O options
        CC_XKEEPFRAME_OPTIONS  += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
        CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
      endif
    endif
  
    #  On i586 we need to tell the code generator to ALWAYS use a
    #   frame pointer.
    ifeq ($(ARCH_FAMILY), i586)
      # Note that in 5.7, this is done with -xregs=no%frameptr
      ifeq ($(CC_VER), 5.5)
        # It's not exactly clear when this optimization kicks in, the
        #   current assumption is -xO4 or greater and for C++ with
        #   the -features=no%except option and -xO4 and greater.
        #   Bottom line is, we ALWAYS want a frame pointer!
        CC_XKEEPFRAME_OPTIONS  += -Wu,-Z~B
        CXX_XKEEPFRAME_OPTIONS += -Qoption ube -Z~B
      endif
597

598 599 600 601 602 603 604 605 606
      CC_NEWER_THAN_56 := \
        $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
	    \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 6 \) )
      ifeq ($(CC_NEWER_THAN_56),1)
        # Do NOT use frame pointer register as a general purpose opt register
        CC_OPT/NONE            += -xregs=no%frameptr
        CXX_OPT/NONE           += -xregs=no%frameptr
        CC_XKEEPFRAME_OPTIONS  += -xregs=no%frameptr
        CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
      endif
    endif
  
    #  Optimizer for sparc needs to be told not to do certain things
    #   related to frames or save instructions.
    ifeq ($(ARCH_FAMILY), sparc)
      #  Do not use save instructions instead of add instructions
      #  This was an optimization starting in SC5.0 that made it hard for us to
      #    find the "save" instruction (which got turned into an "add")
      CC_XKEEPFRAME_OPTIONS  += -Wc,-Qrm-s
      CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qrm-s
      # Don't allow tail call code optimization. Started in SC5.0.
      #    We don't like code of this form:
      #	save
      #	<code>
      #	call foo
      #	   restore
      #   because we can't tell if the method will have a stack frame
      #   and register windows or not.
      CC_XKEEPFRAME_OPTIONS  += -Wc,-Qiselect-T0
      CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qiselect-T0
    endif
  
  endif

  # Extra options used with HIGHEST
D
duke 已提交
633
  #
634
  # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
D
duke 已提交
635 636 637 638
  #          done with care, there are some assumptions below that need to
  #          be understood about the use of pointers, and IEEE behavior.
  #
  # Use non-standard floating point mode (not IEEE 754)
639
  CC_HIGHEST_EXTRAS += -fns
D
duke 已提交
640
  # Do some simplification of floating point arithmetic (not IEEE 754)
641
  CC_HIGHEST_EXTRAS += -fsimple
D
duke 已提交
642
  # Use single precision floating point with 'float'
643
  CC_HIGHEST_EXTRAS += -fsingle
D
duke 已提交
644 645 646
  # Assume memory references via basic pointer types do not alias
  #   (Source with excessing pointer casting and data access with mixed 
  #    pointer types are not recommended)
647
  CC_HIGHEST_EXTRAS += -xalias_level=basic
D
duke 已提交
648 649
  # Use intrinsic or inline versions for math/std functions
  #   (If you expect perfect errno behavior, do not use this)
650
  CC_HIGHEST_EXTRAS += -xbuiltin=%all
D
duke 已提交
651
  # Loop data dependency optimizations (need -xO3 or higher)
652
  CC_HIGHEST_EXTRAS += -xdepend
D
duke 已提交
653 654 655
  # Pointer parameters to functions do not overlap
  #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
  #    If you pass in multiple pointers to the same data, do not use this)
656
  CC_HIGHEST_EXTRAS += -xrestrict
D
duke 已提交
657 658
  # Inline some library routines
  #   (If you expect perfect errno behavior, do not use this)
659
  CC_HIGHEST_EXTRAS += -xlibmil
D
duke 已提交
660 661 662
  # Use optimized math routines
  #   (If you expect perfect errno behavior, do not use this)
  #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
663
  #  CC_HIGHEST_EXTRAS += -xlibmopt
D
duke 已提交
664 665 666
  ifeq ($(ARCH_FAMILY), sparc)
    # Assume at most 8byte alignment, raise SIGBUS on error
    ### Presents an ABI issue with customer JNI libs?
667
    ####CC_HIGHEST_EXTRAS  += -xmemalign=8s
D
duke 已提交
668
    # Automatic prefetch instructions, explicit prefetch macros
669
    CC_HIGHEST_EXTRAS += -xprefetch=auto,explicit
D
duke 已提交
670
    # Pick ultra as the chip to optimize to
671
    CC_HIGHEST_EXTRAS += -xchip=ultra
D
duke 已提交
672 673 674
  endif
  ifeq ($(ARCH), i586)
    # Pick pentium as the chip to optimize to
675
    CC_HIGHEST_EXTRAS += -xchip=pentium
D
duke 已提交
676 677 678 679 680 681 682 683
  endif
  ifdef LIBRARY
    # The Solaris CBE (Common Build Environment) requires that the use
    # of appl registers be disabled when compiling a public library (or
    # a library that's loaded by a public library) on sparc.
    CFLAGS_REQUIRED_sparc    += -xregs=no%appl
    CFLAGS_REQUIRED_sparcv9  += -xregs=no%appl
  endif
684 685 686 687
  CC_NEWER_THAN_56 := \
    $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
         \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 6 \) )
  ifeq ($(CC_NEWER_THAN_56),1)
D
duke 已提交
688 689 690 691 692 693 694 695 696 697 698 699
    #     Presents an ABI issue with customer JNI libs? We must be able to
    #     to handle 4byte aligned objects? (rare occurance, but possible?)
    CFLAGS_REQUIRED_sparc += -xmemalign=4s
  endif
  # Just incase someone trys to use the SOS9 compilers
  ifeq ($(CC_VER), 5.6)
    # We MUST allow data alignment of 4 for sparc (sparcv9 is ok at 8s)
    CFLAGS_REQUIRED_sparc += -xmemalign=4s
  endif
  # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
  #   (See Rules.gmk) The SS11 -xpch=auto* options appear to be broken.
  AUTOMATIC_PCH_OPTION =
700 701 702 703 704 705 706 707 708 709 710 711 712
  
  # Add in keep frame options
  CC_OPT/LOWER    += $(CC_XKEEPFRAME_OPTIONS)
  CC_OPT/HIGHER   += $(CC_XKEEPFRAME_OPTIONS)
  CC_OPT/HIGHEST  += $(CC_XKEEPFRAME_OPTIONS)
  CXX_OPT/LOWER   += $(CXX_XKEEPFRAME_OPTIONS)
  CXX_OPT/HIGHER  += $(CXX_XKEEPFRAME_OPTIONS)
  CXX_OPT/HIGHEST += $(CXX_XKEEPFRAME_OPTIONS)
 
  # Add in highest optimization settings
  CC_OPT/HIGHEST  += $(CC_HIGHEST_EXTRAS)
  CXX_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS)
  
D
duke 已提交
713 714
endif

715 716 717
# Default optimization settings based on level.
CC_OPT  = $(CC_OPT/$(OPTIMIZATION_LEVEL))
CXX_OPT = $(CXX_OPT/$(OPTIMIZATION_LEVEL))
D
duke 已提交
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754

# Flags required all the time
CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))

#
# Path and option to link against the VM, if you have to.  Note that
# there are libraries that link against only -ljava, but they do get
# -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
# the library itself should not.
#
VM_NAME         = server
JVMLIB          = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
JAVALIB         = -ljava $(JVMLIB)

# Part of INCREMENTAL_BUILD mechanism.
#   Compiler emits things like:  path/file.o: file.h
#   We want something like: relative_path/file.o relative_path/file.d: file.h
#   In addition on Solaris, any include file starting with / is deleted,
#   this gets rid of things like /usr/include files, which never change.
CC_DEPEND	 = -xM1
CC_DEPEND_FILTER = $(SED) -e '/:[ 	]*[/]/d' -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g' | $(SORT) -u

# Location of openwin libraries (do we really need this anymore?)
OPENWIN_HOME    = /usr/openwin
OPENWIN_LIB     = $(OPENWIN_HOME)/lib$(ISA_DIR)

# Runtime graphics library search paths...
OPENWIN_RUNTIME_LIB = /usr/openwin/lib$(ISA_DIR)
AWT_RUNPATH = -R/usr/dt/lib$(ISA_DIR) -R$(OPENWIN_RUNTIME_LIB)

# C++ Runtime library (libCrun.so), use instead of -lCrun.
#    Originally used instead of -lCrun to guarantee use of the system
#    .so version and not the .a or .so that came with the compilers.
#    With the newer compilers this could probably change back to -lCrun but
#    in general this is ok to continue to do.
LIBCXX = /usr/lib$(ISA_DIR)/libCrun.so.1

755 756
# JDK now requires Solaris 10, so pick up libm.so.2
LIBM = /usr/lib$(ISA_DIR)/libm.so.2
D
duke 已提交
757 758 759 760

# Socket library
LIBSOCKET = -lsocket

761 762 763
# Network Services library
LIBNSL = -lnsl

764 765 766
# service configuration facility library
LIBSCF = -lscf

767 768 769
# Dynamic Loading library
LIBDL = -ldl

D
duke 已提交
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
# GLOBAL_KPIC: If set means all libraries are PIC, position independent code
#    EXCEPT for select compiles
#    If a .o file is compiled non-PIC then it should be forced
#	   into the RW data segment with a mapfile option. This is done
#    with object files which generated from .s files.
#    The -ztext enforces that no relocations remain in the text segment
#    so that it remains purely read-only for optimum system performance.
#    Some libraries may use a smaller size (13bit -Kpic) on sparc instead of 
#    (32 bit -KPIC) and will override GLOBAL_KPIC appropriately.
#
PIC_CODE_LARGE   = -KPIC
PIC_CODE_SMALL   = -Kpic
ifndef TCOV_BUILD
    GLOBAL_KPIC      = $(PIC_CODE_LARGE)
    CXXFLAGS_COMMON += $(GLOBAL_KPIC)
    CFLAGS_COMMON   += $(GLOBAL_KPIC)
    LDFLAGS_COMMON  += -ztext
endif # TCOV_BUILD

# If your platform has DPS, it will have Type1 fonts too, in which case
# it is best to enable DPS support until such time as 2D's rasteriser
# can fully handle Type1 fonts in all cases. Default is "yes".
# HAVE_DPS should only be "no" if the platform has no DPS headers or libs
# DPS (Displayable PostScript) is available on Solaris machines

HAVE_DPS = yes

#
# Japanese manpages
#
JA_SOURCE_ENCODING = eucJP
JA_TARGET_ENCODINGS = eucJP UTF-8 PCK

# Settings for the JDI - Serviceability Agent binding.
HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
806
SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
807
SA_DIZ_NAME = $(LIB_PREFIX)saproc.diz
D
duke 已提交
808 809
INCLUDE_SA=true