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 # We need to define this on the command line if we want to use the the
  78 # predefined format specifiers from "inttypes.h". Otherwise system headrs
  79 # can indirectly include inttypes.h before we define __STDC_FORMAT_MACROS
  80 # in globalDefinitions.hpp
  81 CFLAGS += -D__STDC_FORMAT_MACROS
  82 
  83 ARCHFLAG = -q64
  84 
  85 CFLAGS     += $(ARCHFLAG)
  86 AOUT_FLAGS += $(ARCHFLAG)
  87 LFLAGS     += $(ARCHFLAG)
  88 ASFLAGS    += $(ARCHFLAG)
  89 
  90 # Use C++ Interpreter
  91 ifdef CC_INTERP
  92   CFLAGS += -DCC_INTERP
  93 endif
  94 
  95 # Keep temporary files (.ii, .s)
  96 # no counterpart on xlc for -save-temps, -pipe
  97 
  98 # Compiler warnings are treated as errors
  99 # Do not treat warnings as errors
 100 # WARNINGS_ARE_ERRORS = -Werror
 101 # Except for a few acceptable ones
 102 # ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
 103 # CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
 104 CFLAGS_WARN/COMMON = 
 105 CFLAGS_WARN/DEFAULT = $(CFLAGS_WARN/COMMON) $(EXTRA_WARNINGS)
 106 # Special cases
 107 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 108 
 109 # The flags to use for an optimized build
 110 OPT_CFLAGS += -O3
 111 
 112 # Hotspot uses very unstrict aliasing turn this optimization off
 113 OPT_CFLAGS += -qalias=noansi
 114 
 115 OPT_CFLAGS/NOOPT=-qnoopt
 116 
 117 DEPFLAGS = -qmakedep=gcc -MF $(DEP_DIR)/$(@:%=%.d)
 118 
 119 #------------------------------------------------------------------------
 120 # Linker flags
 121 
 122 # statically link libstdc++.so, work with gcc but ignored by g++
 123 STATIC_STDCXX = -Wl,-lC_r
 124 
 125 # Enable linker optimization
 126 # no counterpart on xlc for this 
 127 # LFLAGS += -Xlinker -O1
 128 
 129 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 130 # MAPFLAG = -Xlinker --version-script=FILENAME
 131 
 132 # Build shared library
 133 SHARED_FLAG = -q64 -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok
 134 
 135 #------------------------------------------------------------------------
 136 # Debug flags
 137 
 138 # Always compile with '-g' to get symbols in the stacktraces in the hs_err file
 139 DEBUG_CFLAGS += -g
 140 FASTDEBUG_CFLAGS += -g
 141 OPT_CFLAGS += -g
 142 
 143 # DEBUG_BINARIES overrides everything, use full -g debug information
 144 ifeq ($(DEBUG_BINARIES), true)
 145   DEBUG_CFLAGS = -g
 146   CFLAGS += $(DEBUG_CFLAGS)
 147 endif
 148 
 149 # If we are building HEADLESS, pass on to VM
 150 # so it can set the java.awt.headless property
 151 ifdef HEADLESS
 152 CFLAGS += -DHEADLESS
 153 endif
 154 
 155 # We are building Embedded for a small device
 156 # favor code space over speed
 157 ifdef MINIMIZE_RAM_USAGE
 158 CFLAGS += -DMINIMIZE_RAM_USAGE
 159 endif
 160 
 161 ifdef CROSS_COMPILE_ARCH
 162   STRIP = $(ALT_COMPILER_PATH)/strip
 163 else
 164   STRIP = strip
 165 endif