1 #
   2 # Copyright (c) 1995, 2012, 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 # Makefile to specify compiler flags for programs and libraries
  28 # targeted to Solaris.  Should not contain any rules.
  29 #
  30 # WARNING: This file is shared with other workspaces. 
  31 #          So when it includes other files, it must use JDK_TOPDIR.
  32 #
  33 
  34 # Warning: the following variables are overridden by Defs.gmk. Set
  35 # values will be silently ignored:
  36 #   CFLAGS        (set $(OTHER_CFLAGS) instead)
  37 #   CPPFLAGS      (set $(OTHER_CPPFLAGS) instead)
  38 #   CXXFLAGS      (set $(OTHER_CXXFLAGS) instead)
  39 #   LDFLAGS       (set $(OTHER_LDFAGS) instead)
  40 #   LDLIBS        (set $(EXTRA_LIBS) instead)
  41 #   LDLIBS_COMMON (set $(EXTRA_LIBS) instead)
  42 #   LINTFLAGS     (set $(OTHER_LINTFLAGS) instead)
  43 #
  44 # Note: CPPFLAGS are used in C and C++ compiles.
  45 #
  46 
  47 # Get shared JDK settings
  48 include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
  49 
  50 ifndef PLATFORM_SRC
  51 PLATFORM_SRC = $(BUILDDIR)/../src/solaris
  52 endif # PLATFORM_SRC
  53 
  54 # Location of the various .properties files specific to Solaris platform
  55 ifndef PLATFORM_PROPERTIES
  56   PLATFORM_PROPERTIES  = $(BUILDDIR)/../src/solaris/lib
  57 endif # PLATFORM_SRC
  58 
  59 # Platform specific closed sources
  60 ifndef OPENJDK
  61   ifndef CLOSED_PLATFORM_SRC
  62     CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
  63   endif
  64 endif
  65 
  66 # platform specific include files
  67 PLATFORM_INCLUDE_NAME = $(PLATFORM)
  68 PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
  69 
  70 # suffix used for make dependencies files
  71 DEPEND_SUFFIX = d
  72 # suffix used for lint files
  73 LINT_SUFFIX = ln
  74 # The suffix applied to the library name for FDLIBM
  75 FDDLIBM_SUFFIX = a
  76 # The suffix applied to scripts (.bat for windows, nothing for unix)
  77 SCRIPT_SUFFIX =
  78 # CC compiler object code output directive flag value
  79 CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
  80 
  81 # The Full Debug Symbols (FDS) default for VARIANT == OPT builds is
  82 # enabled with debug info files ZIP'ed to save space. For VARIANT !=
  83 # OPT builds, FDS is always enabled, after all a debug build without
  84 # debug info isn't very useful. The ZIP_DEBUGINFO_FILES option only has
  85 # meaning when FDS is enabled.
  86 #
  87 # If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
  88 # disabled for a VARIANT == OPT build.
  89 #
  90 # Note: Use of a different variable name for the FDS override option
  91 # versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
  92 # versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
  93 # in options via environment variables, use of distinct variables
  94 # prevents strange behaviours. For example, in a VARIANT != OPT build,
  95 # the FULL_DEBUG_SYMBOLS environment variable will be 0, but the
  96 # ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If the same
  97 # variable name is used, then different values can be picked up by
  98 # different parts of the build. Just to be clear, we only need two
  99 # variable names because the incoming option value can be overridden
 100 # in some situations, e.g., a VARIANT != OPT build.
 101 
 102 ADD_GNU_DEBUGLINK = $(ABS_BUILDTOOLBINDIR)/add_gnu_debuglink
 103 FIX_EMPTY_SEC_HDR_FLAGS = $(ABS_BUILDTOOLBINDIR)/fix_empty_sec_hdr_flags
 104 
 105 ifeq ($(VARIANT), OPT)
 106   FULL_DEBUG_SYMBOLS ?= 1
 107   ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
 108 else
 109   # debug variants always get Full Debug Symbols (if available)
 110   ENABLE_FULL_DEBUG_SYMBOLS = 1
 111 endif
 112 _JUNK_ := $(shell \
 113   echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
 114 # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
 115 
 116 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 117   # Default OBJCOPY comes from the SUNWbinutils package:
 118   DEF_OBJCOPY=/usr/sfw/bin/gobjcopy
 119   OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
 120   ifneq ($(ALT_OBJCOPY),)
 121     _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
 122     # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
 123     OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
 124   endif
 125 
 126   # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
 127   # JDK build to import .debuginfo or .diz files from the HotSpot build.
 128   # However, adding FDS support to the JDK build will occur in phases
 129   # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
 130   # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
 131   # particular library or program supports FDS.
 132 
 133   ifeq ($(OBJCOPY),)
 134     _JUNK_ := $(shell \
 135       echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
 136     ENABLE_FULL_DEBUG_SYMBOLS=0
 137   else
 138     _JUNK_ := $(shell \
 139       echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
 140 
 141     # Library stripping policies for .debuginfo configs:
 142     #   all_strip - strips everything from the library
 143     #   min_strip - strips most stuff from the library; leaves minimum symbols
 144     #   no_strip  - does not strip the library at all
 145     #
 146     # Oracle security policy requires "all_strip". A waiver was granted on
 147     # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
 148     #
 149     #
 150     # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
 151     STRIP_POLICY ?= min_strip
 152 
 153     _JUNK_ := $(shell \
 154       echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
 155 
 156     ZIP_DEBUGINFO_FILES ?= 1
 157 
 158     _JUNK_ := $(shell \
 159       echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
 160   endif
 161 endif
 162 
 163 #
 164 # Java default optimization (-x04/-O2) etc.  Applies to the VM.
 165 #
 166 ifndef OPTIMIZATION_LEVEL
 167   ifeq ($(PRODUCT), java)
 168     OPTIMIZATION_LEVEL = HIGHER
 169   else
 170     OPTIMIZATION_LEVEL = LOWER
 171   endif
 172 endif
 173 ifndef FASTDEBUG_OPTIMIZATION_LEVEL
 174   FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
 175 endif
 176 
 177 #
 178 # If -Xa is in CFLAGS_COMMON it will end up ahead of $(CC_OPT) for the
 179 # optimized build, and that ordering of the flags completely freaks
 180 # out cc.  Hence, -Xa is instead in each CFLAGS variant.
 181 #
 182 # The more unusual options to the Sun C compiler:
 183 #       -v              Stricter type checking, more error checking
 184 #                       (To turn ALL warnings into fatals, use -errwarn=%all)
 185 #       -xstrconst      Place string literals and constants in read-only area
 186 #                       (means you can't write on your string literals)
 187 #       -xs             Force debug information (stabs) into the .so or a.out
 188 #                       (makes the library/executable debuggable without the
 189 #                       .o files needing to be around, but at a space cost)
 190 #       -g & -O             If you add the -g option to the optimized compiles
 191 #                       you will get better stack retraces, the code is
 192 #                       still optimized. This includes a space cost too.
 193 #       -xc99=%none     Do NOT allow for c99 extensions to be used.
 194 #                       e.g. declarations must precede statements
 195 #       -xCC            Allow the C++ style of comments in C: //
 196 #                       Required with many of the source files.
 197 #       -mt             Assume multi-threaded (important)
 198 #
 199 # The more unusual options to the Sun C compiler:
 200 #       +w              Print more warnings
 201 #       +w2             Maximum warnings
 202 #
 203 
 204 #
 205 # Debug flag for C and C++ compiler
 206 #
 207 CFLAGS_DEBUG_OPTION    = -g $(CC_OPT/NONE)
 208 CXXFLAGS_DEBUG_OPTION  = -g $(CXX_OPT/NONE)
 209 
 210 # Turn off -g if we are doing tcov build
 211 ifdef TCOV_BUILD
 212   CFLAGS_DEBUG_OPTION=
 213   CXXFLAGS_DEBUG_OPTION=
 214 endif
 215 
 216 # FASTDEBUG: Optimize the -g builds, gives us a faster debug java
 217 #        If true adds -O to the debug compiles. This allows for any assert
 218 #        tests to remain and debug checking. The resulting code is faster
 219 #        but less debuggable.  Stack traces are still valid, although only
 220 #        approximate line numbers are given. Printing of local variables
 221 #        during a debugging session is not possible, but stepping and
 222 #        printing of global or static variables should be possible.
 223 #        Performance/size of files should be about the same, maybe smaller.
 224 #
 225 ifeq ($(FASTDEBUG), true)
 226   CFLAGS_DEBUG_OPTION    = -g  $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 227   CXXFLAGS_DEBUG_OPTION  = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 228 endif
 229 
 230 # If Full Debug Symbols is enabled, then we want the same debug and
 231 # optimization flags as used by FASTDEBUG. We also want all the
 232 # debug info in one place (-xs).
 233 #
 234 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 235   ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
 236     ifeq ($(VARIANT), OPT)
 237       CC_OPT   = -g  -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 238       CXX_OPT  = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 239     endif
 240     CFLAGS_DEBUG_OPTION    += -xs
 241     CXXFLAGS_DEBUG_OPTION  += -xs
 242   endif
 243 endif
 244 
 245 CFLAGS_COMMON   = -L$(OBJDIR)
 246 
 247 # Do not allow C99 language features like declarations in code etc.
 248 CFLAGS_COMMON  += -xc99=%none
 249 
 250 # Allow C++ comments in C code
 251 CFLAGS_COMMON  += -xCC
 252 
 253 # Show error message tags on errors
 254 CFLAGS_COMMON   += -errshort=tags
 255 CXXFLAGS_COMMON += -errtags=yes
 256 
 257 # Optimization flags
 258 CFLAGS_OPT      = $(CC_OPT)
 259 
 260 # Debug version flags
 261 CFLAGS_DBG      = $(CFLAGS_DEBUG_OPTION)
 262 
 263 # Required C compiler flags
 264 CFLAGS_COMMON  += -Xa $(CFLAGS_REQUIRED)
 265 
 266 # Maximum warnings all the time
 267 CXXFLAGS_COMMON += +w
 268 CFLAGS_COMMON   += -v
 269 
 270 # Assume MT behavior all the time (important)
 271 CXXFLAGS_COMMON += -mt
 272 CFLAGS_COMMON   += -mt
 273 
 274 # Assume no C++ exceptions are used
 275 CXXFLAGS_COMMON += -features=no%except -DCC_NOEX
 276 
 277 # For C++, these options tell it to assume nothing about locating libraries
 278 #    either at compile time, or at runtime. Use of these options will likely
 279 #    require the use of -L and -R options to indicate where libraries will
 280 #    be found at compile time (-L) and at runtime (-R).
 281 #    The /usr/lib location comes for free, so no need to specify that one.
 282 #    Note: C is much simplier and there is no need for these options. This
 283 #          is mostly needed to avoid dependencies on libraries in the
 284 #          Compiler install area, also see LIBCXX and LIBM.
 285 CXXFLAGS_COMMON += -norunpath -xnolib
 286 
 287 #
 288 # Treat compiler warnings as errors, if requested
 289 #
 290 ifeq ($(COMPILER_WARNINGS_FATAL),true)
 291   CFLAGS_COMMON += -errwarn=%all
 292   CXXFLAGS_COMMON += -errwarn=%all
 293 endif
 294 
 295 CXXFLAGS_OPT    = $(CXX_OPT)
 296 CXXFLAGS_DBG    = $(CXXFLAGS_DEBUG_OPTION)
 297 CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
 298 
 299 # Add -xstrconst to the library compiles. This forces all string
 300 #  literals into the read-only data section, which prevents them from
 301 #  being written to and increases the runtime pages shared on the system.
 302 #
 303 ifdef LIBRARY
 304   CFLAGS_COMMON +=-xstrconst
 305 endif
 306 
 307 # Source browser database
 308 #
 309 # COMPILE_WITH_SB    
 310 #        If defined adds -xsb to compiles and creates a
 311 #        source browsing database during compilation.
 312 #
 313 ifdef COMPILE_WITH_SB
 314   ifeq ($(LIBRARY), java)
 315     CFLAGS_DBG +=   -xsb
 316   endif
 317 endif
 318 
 319 # Lint Flags:
 320 #       -Xa                     ANSI C plus K&R, favor ANSI rules
 321 #       -fd                     report on old style func defs
 322 #       -errchk=structarg       report on 64bit struct args by value
 323 #       -errchk=longptr64       report on 64bit to 32bit issues (ignores casts)
 324 #       -errchk=parentheses     report on suggested use of extra parens
 325 #       -v                      suppress unused args
 326 #       -x                      suppress unused externs
 327 #       -u                      suppress extern func/vars used/defined
 328 #       -errfmt=simple          use one line errors with position info
 329 #       $(LINT_XARCH_OPTION)    See Compiler-sun.gwk
 330 
 331 LINTFLAGS_COMMON  = -Xa
 332 LINTFLAGS_COMMON += -fd 
 333 LINTFLAGS_COMMON += -errchk=structarg,longptr64,parentheses
 334 LINTFLAGS_COMMON += -v
 335 LINTFLAGS_COMMON += -x 
 336 LINTFLAGS_COMMON += -u
 337 LINTFLAGS_COMMON += -errfmt=simple 
 338 LINTFLAGS_OPT   = 
 339 LINTFLAGS_DBG   =
 340 
 341 # The -W0,-noglobal tells the compiler to NOT generate mangled global
 342 #    ELF data symbols for file local static data.
 343 #    This can break fix&continue, but we'd rather do the same compilations
 344 #    for deliverable bits as we do for non-deliverable bits
 345 #    Tell the compilers to never generate globalized names, all the time.
 346 CFLAGS_COMMON += -W0,-noglobal
 347 
 348 # If we have a specific arch value to use, add it
 349 CFLAGS_COMMON    += $(XARCH_OPTION)
 350 CXXFLAGS_COMMON  += $(XARCH_OPTION)
 351 ASFLAGS_COMMON   += $(AS_XARCH_OPTION)
 352 EXTRA_LIBS       += $(XARCH_OPTION)
 353 LINTFLAGS_COMMON += $(LINT_XARCH_OPTION)
 354 
 355 #
 356 # uncomment the following to build with PERTURBALOT set
 357 #
 358 # OTHER_CFLAGS += -DPERTURBALOT
 359 #
 360 
 361 CPPFLAGS_COMMON = -D__solaris__  -D$(ARCH_FAMILY)
 362 CPPFLAGS_OPT    = -DNDEBUG
 363 CPPFLAGS_DBG    = -DDEBUG
 364 
 365 ifneq ($(PRODUCT), java)
 366   CPPFLAGS_DBG    += -DLOGGING -DDBINFO
 367 endif
 368 
 369 ifeq ($(ARCH_FAMILY), i586)
 370   # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 371   #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 372   #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 373   #   Note: -Dmacro         is the same as    #define macro 1
 374   #         -Dmacro=        is the same as    #define macro
 375   #
 376   CPPFLAGS_COMMON +=  -DcpuIntel -D_LITTLE_ENDIAN= -D$(LIBARCH)
 377   # Turn off a superfluous compiler error message on Intel
 378   CFLAGS_COMMON += -erroff=E_BAD_PRAGMA_PACK_VALUE
 379 endif
 380 
 381 # Java memory management is based on memory mapping by default, but a
 382 # system only assuming malloc/free can be built by adding -DUSE_MALLOC 
 383 
 384 CPPFLAGS_COMMON += -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS
 385 CPPFLAGS_OPT    += -DTRIMMED
 386 
 387 LDFLAGS_DEFS_OPTION  = -z defs
 388 LDFLAGS_COMMON  += $(LDFLAGS_DEFS_OPTION)
 389 
 390 #
 391 # -L paths for finding and -ljava
 392 #
 393 LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
 394 LDFLAGS_OPT     =
 395 LDFLAGS_DBG     =
 396 
 397 #
 398 # We never really want the incremental linker, ever
 399 #    The -xildoff option tells Sun's compilers to NOT use incremental linker
 400 #
 401 LDFLAGS_COMMON  += -xildoff
 402 
 403 ifdef LIBRARY
 404   # Libraries need to locate other libraries at runtime, and you can tell
 405   #   a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
 406   #   buried inside the .so. The $ORIGIN says to look relative to where
 407   #   the library itself is and it can be followed with relative paths from
 408   #   that. By default we always look in $ORIGIN, optionally we add relative
 409   #   paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
 410   #   The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
 411   #   Try: 'dump -Lv lib*.so' to see these settings in a library.
 412   #
 413   LDFLAGS_COMMON += -R\$$ORIGIN
 414   LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-R\$$ORIGIN/%)
 415 endif
 416 
 417 EXTRA_LIBS += -lc
 418 
 419 # Postprocessing is done on the images directories only
 420 #
 421 ifeq ($(VARIANT), OPT)
 422   ifeq ($(PARTIAL_GPROF), true)
 423     NO_STRIP = true
 424   endif
 425   ifeq ($(GPROF), true)
 426     NO_STRIP = true
 427   endif
 428   ifneq ($(NO_STRIP), true)
 429     # Debug 'strip -x' leaves local function Elf symbols (better stack traces)
 430     POST_STRIP_PROCESS = $(STRIP) -x
 431   endif
 432 endif
 433 POST_MCS_PROCESS=$(MCS) -d -a "JDK $(FULL_VERSION)"
 434 
 435 #
 436 # Sun C compiler will take -M and pass it on to ld.
 437 # Usage: ld $(LD_MAPFILE_FLAG) mapfile *.o
 438 #
 439 ifeq ($(CC_VERSION),gcc)
 440 LD_MAPFILE_FLAG = -Xlinker -M -Xlinker
 441 else
 442 LD_MAPFILE_FLAG = -M
 443 endif
 444 
 445 #
 446 # Variables globally settable from the make command line (default
 447 # values in brackets):
 448 #       GPROF (false)
 449 # Eg:   % gnumake GPROF=true
 450 GPROF = false
 451 ifeq ($(GPROF), true)
 452     CFLAGS_COMMON += -DGPROF -xpg
 453     EXTRA_LIBS += -xpg
 454 endif
 455 
 456 # PARTIAL_GPROF is to be used ONLY during compilation - it should not
 457 # appear during linking of libraries or programs.  It also should
 458 # prevent linking with -z defs to allow a symbol to remain undefined.
 459 #
 460 PARTIAL_GPROF = false
 461 ifeq ($(PARTIAL_GPROF), true)
 462   CFLAGS_GPROF += -xpg
 463   LDFLAGS_DEFS_OPTION  = -z nodefs
 464 endif
 465 
 466 #
 467 # For a TCOV build we add in the TCOV_OPTION
 468 #
 469 ifdef TCOV_BUILD
 470   TCOV_OPTION           = -xprofile=tcov
 471   LDFLAGS_COMMON        += $(TCOV_OPTION) -Kpic
 472   CFLAGS_COMMON         += $(TCOV_OPTION)
 473   CXXFLAGS_COMMON       += $(TCOV_OPTION)
 474   EXTRA_LIBS    += $(TCOV_OPTION)
 475   LDNOMAP=true
 476 endif
 477 
 478 #
 479 # Solaris only uses native threads. 
 480 #
 481 THREADS_FLAG=   native
 482 THREADS_DIR=    threads
 483 
 484 #
 485 # Support for Quantify.
 486 #
 487 ifdef QUANTIFY
 488   QUANTIFY_CMD = quantify
 489   QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
 490   LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
 491   ifdef LIBRARY
 492     CFLAGS_COMMON += -K PIC
 493   endif
 494 endif
 495 
 496 #
 497 # Support for Purify.
 498 #
 499 ifdef PURIFY
 500   PURIFY_CMD = /net/suntools.eng/export/tools/sparc/bin/purify
 501   PURIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
 502   LINK_PRE_CMD = $(PURIFY_CMD) $(PURIFY_OPTIONS)
 503   ifdef LIBRARY
 504     CFLAGS_COMMON += -K PIC
 505   endif
 506 endif
 507 
 508 #
 509 # Different "levels" of optimization.
 510 #
 511 ifeq ($(CC_VERSION),gcc)
 512   
 513   CC_OPT/NONE     =
 514   CC_OPT/LOWER    = -O2
 515   CC_OPT/HIGHER   = -O3
 516   CC_OPT/HIGHEST  = -O3
 517 
 518   CXX_OPT/NONE    =
 519   CXX_OPT/LOWER   = -O2
 520   CXX_OPT/HIGHER  = -O3
 521   CXX_OPT/HIGHEST = -O3
 522 
 523   CFLAGS_REQUIRED_i586  += -fno-omit-frame-pointer
 524   CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer
 525   
 526   # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
 527   #   (See Rules.gmk) May need to wait for gcc 5?
 528   AUTOMATIC_PCH_OPTION = 
 529 
 530 else
 531   
 532   # Highest could be -xO5, but indications are that -xO5 should be reserved
 533   #    for a per-file use, on sources with known performance impacts.
 534   OPT_LEVEL/LOWER    = 2
 535   OPT_LEVEL/HIGHER   = 4
 536   OPT_LEVEL/HIGHEST  = 4
 537   
 538   CC_OPT/NONE     =
 539   CC_OPT/LOWER    = $(OPT_LEVEL/LOWER:%=-xO%)
 540   CC_OPT/HIGHER   = $(OPT_LEVEL/HIGHER:%=-xO%)
 541   CC_OPT/HIGHEST  = $(OPT_LEVEL/HIGHEST:%=-xO%)
 542   
 543   CXX_OPT/NONE    =
 544   CXX_OPT/LOWER   = $(OPT_LEVEL/LOWER:%=-xO%)
 545   CXX_OPT/HIGHER  = $(OPT_LEVEL/HIGHER:%=-xO%)
 546   CXX_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%)
 547     
 548   # We need stack frames at all times
 549   USE_XKEEPFRAME_OPTION = false
 550   ifeq ($(USE_XKEEPFRAME_OPTION),true)
 551     
 552     # Unknown spelling on this option at this time (Maybe in SS13?)
 553     CC_XKEEPFRAME_OPTIONS  = -xkeepframe
 554     CXX_XKEEPFRAME_OPTIONS = -xkeepframe
 555   
 556   else
 557   
 558     # On X86, make sure tail call optimization is off
 559     #    The z and y are the tail call optimizations.
 560     ifeq ($(ARCH_FAMILY), i586)
 561       CC_NEWER_THAN_58 := \
 562         $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
 563             \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 8 \) )
 564       ifeq ($(CC_NEWER_THAN_58),1)
 565         #    Somehow, tail call optimization is creeping in.
 566         #    Make sure it is off.
 567         # WARNING: These may cause compiler warnings about duplicate -O options
 568         CC_XKEEPFRAME_OPTIONS  += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
 569         CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
 570       endif
 571     endif
 572   
 573     #  On i586 we need to tell the code generator to ALWAYS use a
 574     #   frame pointer.
 575     ifeq ($(ARCH_FAMILY), i586)
 576       # Note that in 5.7, this is done with -xregs=no%frameptr
 577       ifeq ($(CC_VER), 5.5)
 578         # It's not exactly clear when this optimization kicks in, the
 579         #   current assumption is -xO4 or greater and for C++ with
 580         #   the -features=no%except option and -xO4 and greater.
 581         #   Bottom line is, we ALWAYS want a frame pointer!
 582         CC_XKEEPFRAME_OPTIONS  += -Wu,-Z~B
 583         CXX_XKEEPFRAME_OPTIONS += -Qoption ube -Z~B
 584       endif
 585 
 586       CC_NEWER_THAN_56 := \
 587         $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
 588             \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 6 \) )
 589       ifeq ($(CC_NEWER_THAN_56),1)
 590         # Do NOT use frame pointer register as a general purpose opt register
 591         CC_OPT/NONE            += -xregs=no%frameptr
 592         CXX_OPT/NONE           += -xregs=no%frameptr
 593         CC_XKEEPFRAME_OPTIONS  += -xregs=no%frameptr
 594         CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
 595       endif
 596     endif
 597   
 598     #  Optimizer for sparc needs to be told not to do certain things
 599     #   related to frames or save instructions.
 600     ifeq ($(ARCH_FAMILY), sparc)
 601       #  Do not use save instructions instead of add instructions
 602       #  This was an optimization starting in SC5.0 that made it hard for us to
 603       #    find the "save" instruction (which got turned into an "add")
 604       CC_XKEEPFRAME_OPTIONS  += -Wc,-Qrm-s
 605       CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qrm-s
 606       # Don't allow tail call code optimization. Started in SC5.0.
 607       #    We don't like code of this form:
 608       # save
 609       # <code>
 610       # call foo
 611       #    restore
 612       #   because we can't tell if the method will have a stack frame
 613       #   and register windows or not.
 614       CC_XKEEPFRAME_OPTIONS  += -Wc,-Qiselect-T0
 615       CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qiselect-T0
 616     endif
 617   
 618   endif
 619 
 620   # Extra options used with HIGHEST
 621   #
 622   # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 623   #          done with care, there are some assumptions below that need to
 624   #          be understood about the use of pointers, and IEEE behavior.
 625   #
 626   # Use non-standard floating point mode (not IEEE 754)
 627   CC_HIGHEST_EXTRAS += -fns
 628   # Do some simplification of floating point arithmetic (not IEEE 754)
 629   CC_HIGHEST_EXTRAS += -fsimple
 630   # Use single precision floating point with 'float'
 631   CC_HIGHEST_EXTRAS += -fsingle
 632   # Assume memory references via basic pointer types do not alias
 633   #   (Source with excessing pointer casting and data access with mixed 
 634   #    pointer types are not recommended)
 635   CC_HIGHEST_EXTRAS += -xalias_level=basic
 636   # Use intrinsic or inline versions for math/std functions
 637   #   (If you expect perfect errno behavior, do not use this)
 638   CC_HIGHEST_EXTRAS += -xbuiltin=%all
 639   # Loop data dependency optimizations (need -xO3 or higher)
 640   CC_HIGHEST_EXTRAS += -xdepend
 641   # Pointer parameters to functions do not overlap
 642   #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 643   #    If you pass in multiple pointers to the same data, do not use this)
 644   CC_HIGHEST_EXTRAS += -xrestrict
 645   # Inline some library routines
 646   #   (If you expect perfect errno behavior, do not use this)
 647   CC_HIGHEST_EXTRAS += -xlibmil
 648   # Use optimized math routines
 649   #   (If you expect perfect errno behavior, do not use this)
 650   #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
 651   #  CC_HIGHEST_EXTRAS += -xlibmopt
 652   ifeq ($(ARCH_FAMILY), sparc)
 653     # Assume at most 8byte alignment, raise SIGBUS on error
 654     ### Presents an ABI issue with customer JNI libs?
 655     ####CC_HIGHEST_EXTRAS  += -xmemalign=8s
 656     # Automatic prefetch instructions, explicit prefetch macros
 657     CC_HIGHEST_EXTRAS += -xprefetch=auto,explicit
 658     # Pick ultra as the chip to optimize to
 659     CC_HIGHEST_EXTRAS += -xchip=ultra
 660   endif
 661   ifeq ($(ARCH), i586)
 662     # Pick pentium as the chip to optimize to
 663     CC_HIGHEST_EXTRAS += -xchip=pentium
 664   endif
 665   ifdef LIBRARY
 666     # The Solaris CBE (Common Build Environment) requires that the use
 667     # of appl registers be disabled when compiling a public library (or
 668     # a library that's loaded by a public library) on sparc.
 669     CFLAGS_REQUIRED_sparc    += -xregs=no%appl
 670     CFLAGS_REQUIRED_sparcv9  += -xregs=no%appl
 671   endif
 672   CC_NEWER_THAN_56 := \
 673     $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
 674          \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 6 \) )
 675   ifeq ($(CC_NEWER_THAN_56),1)
 676     #     Presents an ABI issue with customer JNI libs? We must be able to
 677     #     to handle 4byte aligned objects? (rare occurance, but possible?)
 678     CFLAGS_REQUIRED_sparc += -xmemalign=4s
 679   endif
 680   # Just incase someone trys to use the SOS9 compilers
 681   ifeq ($(CC_VER), 5.6)
 682     # We MUST allow data alignment of 4 for sparc (sparcv9 is ok at 8s)
 683     CFLAGS_REQUIRED_sparc += -xmemalign=4s
 684   endif
 685   # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
 686   #   (See Rules.gmk) The SS11 -xpch=auto* options appear to be broken.
 687   AUTOMATIC_PCH_OPTION =
 688   
 689   # Add in keep frame options
 690   CC_OPT/LOWER    += $(CC_XKEEPFRAME_OPTIONS)
 691   CC_OPT/HIGHER   += $(CC_XKEEPFRAME_OPTIONS)
 692   CC_OPT/HIGHEST  += $(CC_XKEEPFRAME_OPTIONS)
 693   CXX_OPT/LOWER   += $(CXX_XKEEPFRAME_OPTIONS)
 694   CXX_OPT/HIGHER  += $(CXX_XKEEPFRAME_OPTIONS)
 695   CXX_OPT/HIGHEST += $(CXX_XKEEPFRAME_OPTIONS)
 696  
 697   # Add in highest optimization settings
 698   CC_OPT/HIGHEST  += $(CC_HIGHEST_EXTRAS)
 699   CXX_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS)
 700   
 701 endif
 702 
 703 # Default optimization settings based on level.
 704 CC_OPT  = $(CC_OPT/$(OPTIMIZATION_LEVEL))
 705 CXX_OPT = $(CXX_OPT/$(OPTIMIZATION_LEVEL))
 706 
 707 # Flags required all the time
 708 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
 709 
 710 #
 711 # Path and option to link against the VM, if you have to.  Note that
 712 # there are libraries that link against only -ljava, but they do get
 713 # -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
 714 # the library itself should not.
 715 #
 716 VM_NAME         = server
 717 JVMLIB          = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
 718 JAVALIB         = -ljava $(JVMLIB)
 719 
 720 # Part of INCREMENTAL_BUILD mechanism.
 721 #   Compiler emits things like:  path/file.o: file.h
 722 #   We want something like: relative_path/file.o relative_path/file.d: file.h
 723 #   In addition on Solaris, any include file starting with / is deleted,
 724 #   this gets rid of things like /usr/include files, which never change.
 725 CC_DEPEND        = -xM1
 726 CC_DEPEND_FILTER = $(SED) -e '/:[       ]*[/]/d' -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g' | $(SORT) -u
 727 
 728 # Location of openwin libraries (do we really need this anymore?)
 729 OPENWIN_HOME    = /usr/openwin
 730 OPENWIN_LIB     = $(OPENWIN_HOME)/lib$(ISA_DIR)
 731 
 732 # Runtime graphics library search paths...
 733 OPENWIN_RUNTIME_LIB = /usr/openwin/lib$(ISA_DIR)
 734 AWT_RUNPATH = -R/usr/dt/lib$(ISA_DIR) -R$(OPENWIN_RUNTIME_LIB)
 735 
 736 # C++ Runtime library (libCrun.so), use instead of -lCrun.
 737 #    Originally used instead of -lCrun to guarantee use of the system
 738 #    .so version and not the .a or .so that came with the compilers.
 739 #    With the newer compilers this could probably change back to -lCrun but
 740 #    in general this is ok to continue to do.
 741 LIBCXX = /usr/lib$(ISA_DIR)/libCrun.so.1
 742 
 743 # JDK now requires Solaris 10, so pick up libm.so.2
 744 LIBM = /usr/lib$(ISA_DIR)/libm.so.2
 745 
 746 # Socket library
 747 LIBSOCKET = -lsocket
 748 
 749 # Network Services library
 750 LIBNSL = -lnsl
 751 
 752 # service configuration facility library
 753 LIBSCF = -lscf
 754 
 755 # Dynamic Loading library
 756 LIBDL = -ldl
 757 
 758 # GLOBAL_KPIC: If set means all libraries are PIC, position independent code
 759 #    EXCEPT for select compiles
 760 #    If a .o file is compiled non-PIC then it should be forced
 761 #          into the RW data segment with a mapfile option. This is done
 762 #    with object files which generated from .s files.
 763 #    The -ztext enforces that no relocations remain in the text segment
 764 #    so that it remains purely read-only for optimum system performance.
 765 #    Some libraries may use a smaller size (13bit -Kpic) on sparc instead of 
 766 #    (32 bit -KPIC) and will override GLOBAL_KPIC appropriately.
 767 #
 768 PIC_CODE_LARGE   = -KPIC
 769 PIC_CODE_SMALL   = -Kpic
 770 ifndef TCOV_BUILD
 771     GLOBAL_KPIC      = $(PIC_CODE_LARGE)
 772     CXXFLAGS_COMMON += $(GLOBAL_KPIC)
 773     CFLAGS_COMMON   += $(GLOBAL_KPIC)
 774     LDFLAGS_COMMON  += -ztext
 775 endif # TCOV_BUILD
 776 
 777 # If your platform has DPS, it will have Type1 fonts too, in which case
 778 # it is best to enable DPS support until such time as 2D's rasteriser
 779 # can fully handle Type1 fonts in all cases. Default is "yes".
 780 # HAVE_DPS should only be "no" if the platform has no DPS headers or libs
 781 # DPS (Displayable PostScript) is available on Solaris machines
 782 
 783 HAVE_DPS = yes
 784 
 785 #
 786 # Japanese manpages
 787 #
 788 JA_SOURCE_ENCODING = eucJP
 789 JA_TARGET_ENCODINGS = eucJP UTF-8 PCK
 790 
 791 # Settings for the JDI - Serviceability Agent binding.
 792 HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
 793 SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
 794 SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
 795 SA_DIZ_NAME = $(LIB_PREFIX)saproc.diz
 796 INCLUDE_SA=true
 797