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