1 #
   2 # Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3 # Copyright (c) 2012, 2015 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 which comes as VV.RR.MMMM.LLLL where 'VV' is the version,
  38 # 'RR' is the release, 'MMMM' is the modification and 'LLLL' is the level.
  39 # We only use 'VV.RR.LLLL' to avoid integer overflows in bash when comparing
  40 # the version numbers (some shells only support 32-bit integer compares!).
  41 CXX_VERSION := $(shell $(CXX) -qversion 2>&1 | \
  42                    sed -n 's/.*Version: \([0-9]\{2\}\).\([0-9]\{2\}\).[0-9]\{4\}.\([0-9]\{4\}\)/\1\2\3/p')
  43 
  44 # xlc 08.00.0000.0023 and higher supports -qtune=balanced
  45 CXX_SUPPORTS_BALANCED_TUNING := $(shell if [ $(CXX_VERSION) -ge 08000023 ] ; then echo "true" ; fi)
  46 # xlc 10.01 is used with aggressive optimizations to boost performance
  47 CXX_IS_V10 := $(shell if [ $(CXX_VERSION) -ge 10010000 ] ; then echo "true" ; fi)
  48 
  49 # check for precompiled headers support
  50 
  51 # Switch off the precompiled header support. Neither xlC 8.0 nor xlC 10.0
  52 # support precompiled headers. Both "understand" the command line switches "-qusepcomp" and 
  53 # "-qgenpcomp" but when we specify them the following message is printed:
  54 # "1506-755 (W) The -qusepcomp option is not supported in this release."
  55 USE_PRECOMPILED_HEADER = 0
  56 ifneq ($(USE_PRECOMPILED_HEADER),0)
  57 PRECOMPILED_HEADER_DIR=.
  58 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
  59 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
  60 endif
  61 
  62 
  63 #------------------------------------------------------------------------
  64 # Compiler flags
  65 
  66 # position-independent code
  67 PICFLAG = -qpic=large
  68 
  69 VM_PICFLAG/LIBJVM = $(PICFLAG)
  70 VM_PICFLAG/AOUT   =
  71 VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
  72 
  73 CFLAGS += $(VM_PICFLAG)
  74 CFLAGS += -qnortti
  75 CFLAGS += -qnoeh
  76 
  77 CFLAGS += -D_REENTRANT
  78 # no xlc counterpart for -fcheck-new
  79 # CFLAGS += -fcheck-new
  80 
  81 # We need to define this on the command line if we want to use the the
  82 # predefined format specifiers from "inttypes.h". Otherwise system headrs
  83 # can indirectly include inttypes.h before we define __STDC_FORMAT_MACROS
  84 # in globalDefinitions.hpp
  85 CFLAGS += -D__STDC_FORMAT_MACROS
  86 
  87 ARCHFLAG = -q64
  88 
  89 CFLAGS     += $(ARCHFLAG)
  90 AOUT_FLAGS += $(ARCHFLAG)
  91 LFLAGS     += $(ARCHFLAG)
  92 ASFLAGS    += $(ARCHFLAG)
  93 
  94 # Use C++ Interpreter
  95 ifdef CC_INTERP
  96   CFLAGS += -DCC_INTERP
  97 endif
  98 
  99 # Keep temporary files (.ii, .s)
 100 # no counterpart on xlc for -save-temps, -pipe
 101 
 102 # Compiler warnings are treated as errors
 103 # Do not treat warnings as errors
 104 # WARNINGS_ARE_ERRORS = -Werror
 105 # Except for a few acceptable ones
 106 # ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
 107 # CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
 108 CFLAGS_WARN/COMMON = 
 109 CFLAGS_WARN/DEFAULT = $(CFLAGS_WARN/COMMON) $(EXTRA_WARNINGS)
 110 # Special cases
 111 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 112 
 113 # The flags to use for an optimized build
 114 OPT_CFLAGS += -O3
 115 
 116 # Hotspot uses very unstrict aliasing turn this optimization off
 117 OPT_CFLAGS += -qalias=noansi
 118 
 119 OPT_CFLAGS/NOOPT=-qnoopt
 120 
 121 DEPFLAGS = -qmakedep=gcc -MF $(DEP_DIR)/$(@:%=%.d)
 122 
 123 #------------------------------------------------------------------------
 124 # Linker flags
 125 
 126 # statically link libstdc++.so, work with gcc but ignored by g++
 127 STATIC_STDCXX = -Wl,-lC_r
 128 
 129 # Enable linker optimization
 130 # no counterpart on xlc for this 
 131 # LFLAGS += -Xlinker -O1
 132 
 133 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 134 # MAPFLAG = -Xlinker --version-script=FILENAME
 135 
 136 # Build shared library
 137 SHARED_FLAG = -q64 -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok
 138 
 139 #------------------------------------------------------------------------
 140 # Debug flags
 141 
 142 # Always compile with '-g' to get symbols in the stacktraces in the hs_err file
 143 DEBUG_CFLAGS += -g
 144 FASTDEBUG_CFLAGS += -g
 145 OPT_CFLAGS += -g
 146 
 147 # DEBUG_BINARIES overrides everything, use full -g debug information
 148 ifeq ($(DEBUG_BINARIES), true)
 149   DEBUG_CFLAGS = -g
 150   CFLAGS += $(DEBUG_CFLAGS)
 151 endif
 152 
 153 # If we are building HEADLESS, pass on to VM
 154 # so it can set the java.awt.headless property
 155 ifdef HEADLESS
 156 CFLAGS += -DHEADLESS
 157 endif
 158 
 159 # We are building Embedded for a small device
 160 # favor code space over speed
 161 ifdef MINIMIZE_RAM_USAGE
 162 CFLAGS += -DMINIMIZE_RAM_USAGE
 163 endif
 164 
 165 ifdef CROSS_COMPILE_ARCH
 166   STRIP = $(ALT_COMPILER_PATH)/strip
 167 else
 168   STRIP = strip
 169 endif