1 #
   2 # Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
   3 # Copyright (c) 2012, 2013 SAP. All rights reserved.
   4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 #
   6 # This code is free software; you can redistribute it and/or modify it
   7 # under the terms of the GNU General Public License version 2 only, as
   8 # published by the Free Software Foundation.
   9 #
  10 # This code is distributed in the hope that it will be useful, but WITHOUT
  11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13 # version 2 for more details (a copy is included in the LICENSE file that
  14 # accompanied this code).
  15 #
  16 # You should have received a copy of the GNU General Public License version
  17 # 2 along with this work; if not, write to the Free Software Foundation,
  18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19 #
  20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21 # or visit www.oracle.com if you need additional information or have any
  22 # questions.
  23 #  
  24 #
  25 
  26 #------------------------------------------------------------------------
  27 # CC, CXX & AS
  28 
  29 # Set compiler explicitly
  30 CXX = $(COMPILER_PATH)xlC_r
  31 CC  = $(COMPILER_PATH)xlc_r
  32 HOSTCXX = $(CXX)
  33 HOSTCC  = $(CC)
  34 
  35 AS  = $(CC) -c
  36 
  37 # get xlc version
  38 CXX_VERSION   := $(shell $(CXX) -qversion 2>&1 | sed -n 's/.*Version: \([0-9.]*\)/\1/p')
  39 
  40 # xlc 08.00.0000.0023 and higher supports -qtune=balanced
  41 CXX_SUPPORTS_BALANCED_TUNING=$(shell if [ $(subst .,,$(CXX_VERSION)) -ge 080000000023 ] ; then echo "true" ; fi)
  42 # xlc 10.01 is used with aggressive optimizations to boost performance
  43 CXX_IS_V10=$(shell if [ $(subst .,,$(CXX_VERSION)) -ge 100100000000 ] ; then echo "true" ; fi)
  44 
  45 # check for precompiled headers support
  46 
  47 # Switch off the precompiled header support. Neither xlC 8.0 nor xlC 10.0
  48 # support precompiled headers. Both "understand" the command line switches "-qusepcomp" and 
  49 # "-qgenpcomp" but when we specify them the following message is printed:
  50 # "1506-755 (W) The -qusepcomp option is not supported in this release."
  51 USE_PRECOMPILED_HEADER = 0
  52 ifneq ($(USE_PRECOMPILED_HEADER),0)
  53 PRECOMPILED_HEADER_DIR=.
  54 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
  55 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
  56 endif
  57 
  58 
  59 #------------------------------------------------------------------------
  60 # Compiler flags
  61 
  62 # position-independent code
  63 PICFLAG = -qpic=large
  64 
  65 VM_PICFLAG/LIBJVM = $(PICFLAG)
  66 VM_PICFLAG/AOUT   =
  67 VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
  68 
  69 CFLAGS += $(VM_PICFLAG)
  70 CFLAGS += -qnortti
  71 CFLAGS += -qnoeh
  72 
  73 CFLAGS += -D_REENTRANT
  74 # no xlc counterpart for -fcheck-new
  75 # CFLAGS += -fcheck-new
  76 
  77 ARCHFLAG = -q64
  78 
  79 CFLAGS     += $(ARCHFLAG)
  80 AOUT_FLAGS += $(ARCHFLAG)
  81 LFLAGS     += $(ARCHFLAG)
  82 ASFLAGS    += $(ARCHFLAG)
  83 
  84 # Use C++ Interpreter
  85 ifdef CC_INTERP
  86   CFLAGS += -DCC_INTERP
  87 endif
  88 
  89 # Keep temporary files (.ii, .s)
  90 # no counterpart on xlc for -save-temps, -pipe
  91 
  92 # Compiler warnings are treated as errors
  93 # Do not treat warnings as errors
  94 # WARNINGS_ARE_ERRORS = -Werror
  95 # Except for a few acceptable ones
  96 # ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
  97 # CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
  98 CFLAGS_WARN/COMMON = 
  99 CFLAGS_WARN/DEFAULT = $(CFLAGS_WARN/COMMON) $(EXTRA_WARNINGS)
 100 # Special cases
 101 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 102 
 103 # The flags to use for an optimized build
 104 OPT_CFLAGS += -O3
 105 
 106 # Hotspot uses very unstrict aliasing turn this optimization off
 107 OPT_CFLAGS += -qalias=noansi
 108 
 109 OPT_CFLAGS/NOOPT=-qnoopt
 110 
 111 DEPFLAGS = -qmakedep=gcc -MF $(DEP_DIR)/$(@:%=%.d)
 112 
 113 #------------------------------------------------------------------------
 114 # Linker flags
 115 
 116 # statically link libstdc++.so, work with gcc but ignored by g++
 117 STATIC_STDCXX = -Wl,-lC_r
 118 
 119 # Enable linker optimization
 120 # no counterpart on xlc for this 
 121 # LFLAGS += -Xlinker -O1
 122 
 123 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 124 # MAPFLAG = -Xlinker --version-script=FILENAME
 125 
 126 # Build shared library
 127 SHARED_FLAG = -q64 -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath
 128 
 129 #------------------------------------------------------------------------
 130 # Debug flags
 131 
 132 # Always compile with '-g' to get symbols in the stacktraces in the hs_err file
 133 DEBUG_CFLAGS += -g
 134 FASTDEBUG_CFLAGS += -g
 135 OPT_CFLAGS += -g
 136 
 137 # DEBUG_BINARIES overrides everything, use full -g debug information
 138 ifeq ($(DEBUG_BINARIES), true)
 139   DEBUG_CFLAGS = -g
 140   CFLAGS += $(DEBUG_CFLAGS)
 141 endif
 142 
 143 # If we are building HEADLESS, pass on to VM
 144 # so it can set the java.awt.headless property
 145 ifdef HEADLESS
 146 CFLAGS += -DHEADLESS
 147 endif
 148 
 149 # We are building Embedded for a small device
 150 # favor code space over speed
 151 ifdef MINIMIZE_RAM_USAGE
 152 CFLAGS += -DMINIMIZE_RAM_USAGE
 153 endif
 154 
 155 ifdef CROSS_COMPILE_ARCH
 156   STRIP = $(ALT_COMPILER_PATH)/strip
 157 else
 158   STRIP = strip
 159 endif