1 #
   2 # Copyright (c) 2003, 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.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #  
  23 #
  24 
  25 # Common rules/macros for the vm, adlc.
  26 
  27 # Tell make that .cpp is important
  28 .SUFFIXES: .cpp $(SUFFIXES)
  29 
  30 DEMANGLER       = c++filt
  31 DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
  32 
  33 # $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
  34 CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
  35 CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
  36 
  37 AS.S            = $(AS) $(ASFLAGS)
  38 
  39 COMPILE.CC       = $(CC_COMPILE) -c
  40 GENASM.CC        = $(CC_COMPILE) -S
  41 LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
  42 LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
  43 PREPROCESS.CC    = $(CC_COMPILE) -E
  44 
  45 COMPILE.CXX      = $(CXX_COMPILE) -c
  46 GENASM.CXX       = $(CXX_COMPILE) -S
  47 LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
  48 LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
  49 LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
  50 PREPROCESS.CXX   = $(CXX_COMPILE) -E
  51 
  52 # cross compiling the jvm with c2 requires host compilers to build
  53 # adlc tool
  54 
  55 HOST.CXX_COMPILE      = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS)
  56 HOST.COMPILE.CXX      = $(HOST.CXX_COMPILE) -c
  57 HOST.LINK_NOPROF.CXX  = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS)
  58 
  59 
  60 # Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
  61 REMOVE_TARGET   = rm -f $@
  62 
  63 # Note use of ALT_BOOTDIR to explicitly specify location of java and
  64 # javac; this is the same environment variable used in the J2SE build
  65 # process for overriding the default spec, which is BOOTDIR.
  66 # Note also that we fall back to using JAVA_HOME if neither of these is
  67 # specified.
  68 
  69 ifdef ALT_BOOTDIR
  70 
  71 RUN.JAVA  = $(ALT_BOOTDIR)/bin/java
  72 RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap
  73 RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah
  74 RUN.JAR   = $(ALT_BOOTDIR)/bin/jar
  75 COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac
  76 COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic
  77 BOOT_JAVA_HOME = $(ALT_BOOTDIR)
  78 
  79 else
  80 
  81 ifdef BOOTDIR
  82 
  83 RUN.JAVA  = $(BOOTDIR)/bin/java
  84 RUN.JAVAP = $(BOOTDIR)/bin/javap
  85 RUN.JAVAH = $(BOOTDIR)/bin/javah
  86 RUN.JAR   = $(BOOTDIR)/bin/jar
  87 COMPILE.JAVAC = $(BOOTDIR)/bin/javac
  88 COMPILE.RMIC  = $(BOOTDIR)/bin/rmic
  89 BOOT_JAVA_HOME = $(BOOTDIR)
  90 
  91 else
  92 
  93 ifdef JAVA_HOME
  94 
  95 RUN.JAVA  = $(JAVA_HOME)/bin/java
  96 RUN.JAVAP = $(JAVA_HOME)/bin/javap
  97 RUN.JAVAH = $(JAVA_HOME)/bin/javah
  98 RUN.JAR   = $(JAVA_HOME)/bin/jar
  99 COMPILE.JAVAC = $(JAVA_HOME)/bin/javac
 100 COMPILE.RMIC  = $(JAVA_HOME)/bin/rmic
 101 BOOT_JAVA_HOME = $(JAVA_HOME)
 102 
 103 else
 104 
 105 # take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined
 106 # note that this is to support hotspot build without SA. To build
 107 # SA along with hotspot, you need to define ALT_BOOTDIR, BOOTDIR or JAVA_HOME
 108 
 109 RUN.JAVA  = java
 110 RUN.JAVAP = javap
 111 RUN.JAVAH = javah
 112 RUN.JAR   = jar
 113 COMPILE.JAVAC = javac
 114 COMPILE.RMIC  = rmic
 115 
 116 endif
 117 endif
 118 endif
 119 
 120 COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS)
 121 
 122 SUM = /usr/bin/sum
 123 
 124 # 'gmake MAKE_VERBOSE=y' gives all the gory details.
 125 QUIETLY$(MAKE_VERBOSE)  = @
 126 RUN.JAR$(MAKE_VERBOSE) += >/dev/null
 127 
 128 # Settings for javac
 129 BOOT_SOURCE_LANGUAGE_VERSION = 6
 130 BOOT_TARGET_CLASS_VERSION = 6
 131 JAVAC_FLAGS = -g -encoding ascii
 132 BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) -source $(BOOT_SOURCE_LANGUAGE_VERSION) -target $(BOOT_TARGET_CLASS_VERSION)
 133 
 134 # With parallel makes, print a message at the end of compilation.
 135 ifeq    ($(findstring j,$(MFLAGS)),j)
 136 COMPILE_DONE    = && { echo Done with $<; }
 137 endif
 138 
 139 ifdef LP64
 140 GENPIC = yes
 141 endif
 142 
 143 ifeq ($(BUILDARCH), aarch32)
 144 GENPIC = yes
 145 endif
 146 
 147 # Include $(NONPIC_OBJ_FILES) definition
 148 ifndef GENPIC
 149 include $(GAMMADIR)/make/pic.make
 150 endif
 151 
 152 include $(GAMMADIR)/make/altsrc.make
 153 
 154 # The non-PIC object files are only generated for 32 bit platforms.
 155 ifdef GENPIC
 156 %.o: %.cpp
 157         @echo Compiling $<
 158         $(QUIETLY) $(REMOVE_TARGET)
 159         $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
 160 else
 161 %.o: %.cpp
 162         @echo Compiling $<
 163         $(QUIETLY) $(REMOVE_TARGET)
 164         $(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
 165            $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
 166            $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
 167 endif
 168 
 169 %.o: %.s
 170         @echo Assembling $<
 171         $(QUIETLY) $(REMOVE_TARGET)
 172         $(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
 173 
 174 %.s: %.cpp
 175         @echo Generating assembly for $<
 176         $(QUIETLY) $(GENASM.CXX) -o $@ $<
 177         $(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
 178 
 179 # Intermediate files (for debugging macros)
 180 %.i: %.cpp
 181         @echo Preprocessing $< to $@
 182         $(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
 183 
 184 #  Override gnumake built-in rules which do sccs get operations badly.
 185 #  (They put the checked out code in the current directory, not in the
 186 #  directory of the original file.)  Since this is a symptom of a teamware
 187 #  failure, and since not all problems can be detected by gnumake due
 188 #  to incomplete dependency checking... just complain and stop.
 189 %:: s.%
 190         @echo "========================================================="
 191         @echo File $@
 192         @echo is out of date with respect to its SCCS file.
 193         @echo This file may be from an unresolved Teamware conflict.
 194         @echo This is also a symptom of a Teamware bringover/putback failure
 195         @echo in which SCCS files are updated but not checked out.
 196         @echo Check for other out of date files in your workspace.
 197         @echo "========================================================="
 198         @exit 666
 199 
 200 %:: SCCS/s.%
 201         @echo "========================================================="
 202         @echo File $@
 203         @echo is out of date with respect to its SCCS file.
 204         @echo This file may be from an unresolved Teamware conflict.
 205         @echo This is also a symptom of a Teamware bringover/putback failure
 206         @echo in which SCCS files are updated but not checked out.
 207         @echo Check for other out of date files in your workspace.
 208         @echo "========================================================="
 209         @exit 666
 210 
 211 .PHONY: default