1 #
   2 # Copyright (c) 1999, 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 Linux.  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 overriden 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 
  43 # Get shared JDK settings
  44 include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
  45 
  46 # Part of INCREMENTAL_BUILD mechanism.
  47 #   Compiler emits things like:  path/file.o: file.h
  48 #   We want something like: relative_path/file.o relative_path/file.d: file.h
  49 CC_DEPEND        = -MM
  50 CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g'
  51 
  52 ifndef PLATFORM_SRC
  53   PLATFORM_SRC = $(BUILDDIR)/../src/solaris
  54 endif # PLATFORM_SRC
  55 
  56 # Platform specific closed sources
  57 ifndef OPENJDK
  58   ifndef CLOSED_PLATFORM_SRC
  59     CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
  60   endif
  61 endif
  62 
  63 # platform specific include files
  64 PLATFORM_INCLUDE_NAME = $(PLATFORM)
  65 PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
  66 
  67 # suffix used for make dependencies files.
  68 DEPEND_SUFFIX = d
  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 CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
  76 
  77 ENABLE_FULL_DEBUG_SYMBOLS ?= 1
  78 # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later
  79 
  80 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
  81   # Default OBJCOPY comes from GNU Binutils on Linux:
  82   DEF_OBJCOPY=/usr/bin/objcopy
  83   ifdef CROSS_COMPILE_ARCH
  84     # don't try to generate .debuginfo files when cross compiling
  85     _JUNK_ := $(shell \
  86       echo >&2 "INFO: cross compiling for ARCH $(CROSS_COMPILE_ARCH)," \
  87         "skipping .debuginfo generation.")
  88     OBJCOPY=
  89   else
  90     OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
  91     ifneq ($(ALT_OBJCOPY),)
  92       _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
  93       # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
  94       OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
  95     endif
  96   endif
  97 
  98   # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
  99   # JDK build to import .debuginfo or .diz files from the HotSpot build.
 100   # However, adding FDS support to the JDK build will occur in phases
 101   # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
 102   # is used to indicate that a particular library supports FDS.

 103 
 104   ifeq ($(OBJCOPY),)
 105     _JUNK_ := $(shell \
 106       echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
 107     ENABLE_FULL_DEBUG_SYMBOLS=0
 108   else
 109     _JUNK_ := $(shell \
 110       echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
 111 
 112     # Library stripping policies for .debuginfo configs:
 113     #   all_strip - strips everything from the library
 114     #   min_strip - strips most stuff from the library; leaves minimum symbols
 115     #   no_strip  - does not strip the library at all
 116     #
 117     # Oracle security policy requires "all_strip". A waiver was granted on
 118     # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
 119     #
 120     # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled.
 121     STRIP_POLICY ?= min_strip




 122 
 123     _JUNK_ := $(shell \
 124       echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
 125 
 126     ZIP_DEBUGINFO_FILES ?= 1
 127 
 128     _JUNK_ := $(shell \
 129       echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
 130   endif
 131 endif

 132 
 133 #
 134 # Default optimization
 135 #
 136 
 137 ifndef OPTIMIZATION_LEVEL
 138   ifeq ($(PRODUCT), java)
 139     OPTIMIZATION_LEVEL = HIGHER
 140   else
 141     OPTIMIZATION_LEVEL = LOWER
 142   endif
 143 endif
 144 ifndef FASTDEBUG_OPTIMIZATION_LEVEL
 145   FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
 146 endif
 147 
 148 CC_OPT/NONE     = 
 149 CC_OPT/LOWER    = -O2
 150 CC_OPT/HIGHER   = -O3
 151 CC_OPT/HIGHEST  = -O3
 152 
 153 CC_OPT          = $(CC_OPT/$(OPTIMIZATION_LEVEL))
 154 
 155 # For all platforms, do not omit the frame pointer register usage. 
 156 #    We need this frame pointer to make it easy to walk the stacks.
 157 #    This should be the default on X86, but ia64 and amd64 may not have this
 158 #    as the default.
 159 CFLAGS_REQUIRED_amd64   += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
 160 CFLAGS_REQUIRED_i586    += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
 161 CFLAGS_REQUIRED_ia64    += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
 162 CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
 163 LDFLAGS_COMMON_sparcv9  += -m64 -mcpu=v9
 164 CFLAGS_REQUIRED_sparc   += -m32 -mcpu=v9
 165 LDFLAGS_COMMON_sparc    += -m32 -mcpu=v9
 166 CFLAGS_REQUIRED_arm     += -fsigned-char -D_LITTLE_ENDIAN
 167 CFLAGS_REQUIRED_ppc     += -fsigned-char -D_BIG_ENDIAN
 168 ifeq ($(ZERO_BUILD), true)
 169   CFLAGS_REQUIRED       =  $(ZERO_ARCHFLAG)
 170   ifeq ($(ZERO_ENDIANNESS), little)
 171     CFLAGS_REQUIRED     += -D_LITTLE_ENDIAN
 172   endif
 173   LDFLAGS_COMMON        += $(ZERO_ARCHFLAG)
 174 else
 175   CFLAGS_REQUIRED       =  $(CFLAGS_REQUIRED_$(ARCH))
 176   LDFLAGS_COMMON        += $(LDFLAGS_COMMON_$(ARCH))
 177 endif
 178 
 179 # If this is a --hash-style=gnu system, use --hash-style=both
 180 #   The gnu .hash section won't work on some Linux systems like SuSE 10.
 181 _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
 182 ifneq ($(_HAS_HASH_STYLE_GNU),)
 183   LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
 184 endif
 185 LDFLAGS_COMMON          += $(LDFLAGS_HASH_STYLE)
 186 
 187 #
 188 # Selection of warning messages
 189 #
 190 GCC_INHIBIT     = -Wno-unused -Wno-parentheses
 191 GCC_STYLE       = 
 192 GCC_WARNINGS    = -W -Wall $(GCC_STYLE) $(GCC_INHIBIT)
 193 
 194 #
 195 # Treat compiler warnings as errors, if warnings not allowed
 196 #
 197 ifeq ($(COMPILER_WARNINGS_FATAL),true)
 198   GCC_WARNINGS += -Werror
 199 endif
 200 
 201 #
 202 # Misc compiler options
 203 #
 204 ifneq ($(ARCH),ppc)
 205   CFLAGS_COMMON   = -fno-strict-aliasing
 206 endif 
 207 PIC_CODE_LARGE = -fPIC
 208 PIC_CODE_SMALL = -fpic
 209 GLOBAL_KPIC = $(PIC_CODE_LARGE)
 210 CFLAGS_COMMON   += $(GLOBAL_KPIC) $(GCC_WARNINGS)
 211 ifeq ($(ARCH), amd64)
 212  CFLAGS_COMMON += -pipe
 213 endif
 214 
 215 # Linux 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
 216 DEBUG_FLAG = -g
 217 ifeq ($(FASTDEBUG), true)
 218   ifeq ($(ARCH_DATA_MODEL), 64)
 219     DEBUG_FLAG = -g1
 220   endif
 221 endif
 222 
 223 # DEBUG_BINARIES overrides everything, use full -g debug information
 224 ifeq ($(DEBUG_BINARIES), true)
 225   DEBUG_FLAG = -g
 226   CFLAGS_REQUIRED += $(DEBUG_FLAG)
 227 endif
 228 
 229 CFLAGS_OPT      = $(CC_OPT)
 230 CFLAGS_DBG      = $(DEBUG_FLAG)
 231 CFLAGS_COMMON += $(CFLAGS_REQUIRED)
 232 
 233 CXXFLAGS_COMMON = $(GLOBAL_KPIC) -DCC_NOEX $(GCC_WARNINGS)
 234 CXXFLAGS_OPT    = $(CC_OPT)
 235 CXXFLAGS_DBG    = $(DEBUG_FLAG)
 236 CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
 237 
 238 # FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
 239 ifeq ($(FASTDEBUG), true)
 240   CFLAGS_DBG    += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 241   CXXFLAGS_DBG  += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 242 endif
 243 
 244 CPP_ARCH_FLAGS = -DARCH='"$(ARCH)"'
 245 
 246 # Alpha arch does not like "alpha" defined (potential general arch cleanup issue here)
 247 ifneq ($(ARCH),alpha)
 248   CPP_ARCH_FLAGS += -D$(ARCH)
 249 else
 250   CPP_ARCH_FLAGS += -D_$(ARCH)_
 251 endif
 252 
 253 CPPFLAGS_COMMON = $(CPP_ARCH_FLAGS) -DLINUX $(VERSION_DEFINES) \
 254                   -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT
 255 
 256 ifeq ($(ARCH_DATA_MODEL), 64)
 257 CPPFLAGS_COMMON += -D_LP64=1
 258 endif
 259 
 260 CPPFLAGS_OPT    = -DNDEBUG
 261 CPPFLAGS_DBG    = -DDEBUG
 262 ifneq ($(PRODUCT), java)
 263   CPPFLAGS_DBG    += -DLOGGING 
 264 endif
 265 
 266 ifdef LIBRARY
 267   # Libraries need to locate other libraries at runtime, and you can tell
 268   #   a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
 269   #   buried inside the .so. The $ORIGIN says to look relative to where
 270   #   the library itself is and it can be followed with relative paths from
 271   #   that. By default we always look in $ORIGIN, optionally we add relative
 272   #   paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
 273   #   On Linux we add a flag -z origin, not sure if this is necessary, but 
 274   #   doesn't seem to hurt.
 275   #   The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
 276   #   Try: 'readelf -d lib*.so' to see these settings in a library.
 277   #
 278   Z_ORIGIN_FLAG/sparc = -Xlinker -z -Xlinker origin
 279   Z_ORIGIN_FLAG/i586  = -Xlinker -z -Xlinker origin
 280   Z_ORIGIN_FLAG/amd64 = -Xlinker -z -Xlinker origin 
 281   Z_ORIGIN_FLAG/ia64  = -Xlinker -z -Xlinker origin
 282   Z_ORIGIN_FLAG/arm   = 
 283   Z_ORIGIN_FLAG/ppc   =
 284   Z_ORIGIN_FLAG/zero  = -Xlinker -z -Xlinker origin
 285 
 286   LDFLAG_Z_ORIGIN = $(Z_ORIGIN_FLAG/$(ARCH_FAMILY))
 287 
 288   LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN
 289   LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN/%)
 290 
 291 endif
 292 
 293 EXTRA_LIBS += -lc
 294 
 295 LDFLAGS_DEFS_OPTION  = -Xlinker -z -Xlinker defs
 296 LDFLAGS_COMMON  += $(LDFLAGS_DEFS_OPTION)
 297 
 298 #
 299 # -L paths for finding and -ljava
 300 #
 301 LDFLAGS_OPT     = -Xlinker -O1
 302 LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
 303 LDFLAGS_COMMON += -Wl,-soname=$(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
 304 
 305 #
 306 # -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
 307 # statically link libgcc but will print a warning with the flag. We don't 
 308 # want the warning, so check gcc version first.
 309 #
 310 ifeq ($(CC_MAJORVER),3)
 311   OTHER_LDFLAGS  += -static-libgcc
 312 endif
 313 
 314 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
 315 #   (See Rules.gmk) The gcc 5 compiler might have an option for this?
 316 AUTOMATIC_PCH_OPTION = 
 317 
 318 #
 319 # Post Processing of libraries/executables
 320 #
 321 ifeq ($(VARIANT), OPT)
 322   ifneq ($(NO_STRIP), true)
 323     ifneq ($(DEBUG_BINARIES), true)
 324       # Debug 'strip -g' leaves local function Elf symbols (better stack
 325       # traces)
 326       POST_STRIP_PROCESS = $(STRIP) -g
 327     endif
 328   endif
 329 endif
 330 
 331 #
 332 # Use: ld $(LD_MAPFILE_FLAG) mapfile *.o
 333 #
 334 LD_MAPFILE_FLAG = -Xlinker --version-script -Xlinker
 335 
 336 #
 337 # Support for Quantify.
 338 #
 339 ifdef QUANTIFY
 340 QUANTIFY_CMD = quantify
 341 QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
 342 LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
 343 endif
 344 
 345 #
 346 # Path and option to link against the VM, if you have to.  Note that
 347 # there are libraries that link against only -ljava, but they do get
 348 # -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
 349 # the library itself should not.
 350 #
 351 VM_NAME         = server
 352 JVMLIB          = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
 353 JAVALIB         = -ljava $(JVMLIB)
 354 
 355 #
 356 # We want to privatize JVM symbols on Solaris. This is so the user can
 357 # write a function called FindClass and this should not override the 
 358 # FindClass that is inside the JVM. At this point in time we are not
 359 # concerned with other JNI libraries because we hope that there will
 360 # not be as many clashes there.
 361 #
 362 PRIVATIZE_JVM_SYMBOLS = false
 363 
 364 USE_PTHREADS = true
 365 override ALT_CODESET_KEY         = _NL_CTYPE_CODESET_NAME
 366 override AWT_RUNPATH             =
 367 override HAVE_ALTZONE            = false
 368 override HAVE_FILIOH             = false
 369 override HAVE_GETHRTIME          = false
 370 override HAVE_GETHRVTIME         = false
 371 override HAVE_SIGIGNORE          = true
 372 override LEX_LIBRARY             = -lfl
 373 ifeq ($(STATIC_CXX),true)
 374 override LIBCXX                  = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
 375 else
 376 override LIBCXX                  = -lstdc++
 377 endif
 378 override LIBPOSIX4               =
 379 override LIBSOCKET               =
 380 override LIBNSL                  =
 381 override LIBSCF                  =
 382 override LIBTHREAD               =
 383 override LIBDL                   = -ldl
 384 override MOOT_PRIORITIES         = true
 385 override NO_INTERRUPTIBLE_IO     = true
 386 ifeq ($(ARCH), amd64)
 387 override OPENWIN_LIB             = $(OPENWIN_HOME)/lib64
 388 else
 389 override OPENWIN_LIB             = $(OPENWIN_HOME)/lib
 390 endif
 391 override OTHER_M4FLAGS           = -D__GLIBC__ -DGNU_ASSEMBLER
 392 override SUN_CMM_SUBDIR          =
 393 override THREADS_FLAG            = native
 394 override USE_GNU_M4              = true
 395 override USING_GNU_TAR           = true
 396 override WRITE_LIBVERSION        = false
 397 
 398 # USE_EXECNAME forces the launcher to look up argv[0] on $PATH, and put the
 399 # resulting resolved absolute name of the executable in the environment
 400 # variable EXECNAME.  That executable name is then used that to locate the
 401 # installation area.
 402 override USE_EXECNAME            = true
 403 
 404 # If your platform has DPS, it will have Type1 fonts too, in which case
 405 # it is best to enable DPS support until such time as 2D's rasteriser
 406 # can fully handle Type1 fonts in all cases. Default is "yes".
 407 # HAVE_DPS should only be "no" if the platform has no DPS headers or libs
 408 # DPS (Displayable PostScript) is available on Solaris machines
 409 HAVE_DPS = no
 410 
 411 #
 412 # Japanese manpages
 413 #
 414 JA_SOURCE_ENCODING = eucJP
 415 JA_TARGET_ENCODINGS = UTF-8
 416 
 417 # Settings for the JDI - Serviceability Agent binding.
 418 HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
 419 SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
 420 SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
 421 SA_DIZ_NAME = $(LIB_PREFIX)saproc.diz
 422 
 423 # The JDI - Serviceability Agent binding is not currently supported
 424 # on Linux-ia64.
 425 ifeq ($(ARCH), ia64)
 426   INCLUDE_SA = false
 427 else
 428   INCLUDE_SA = true
 429 endif
 430 
 431 ifdef CROSS_COMPILE_ARCH
 432   # X11 headers are not under /usr/include
 433   OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
 434   OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
 435   OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
 436 endif
--- EOF ---