1 #
   2 # Copyright 1997-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20 # CA 95054 USA or visit www.sun.com if you need additional information or
  21 # have any questions.
  22 #  
  23 #
  24 
  25 # This makefile (adlc.make) is included from the adlc.make in the
  26 # build directories.
  27 # It knows how to compile, link, and run the adlc.
  28 
  29 include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
  30 
  31 # #########################################################################
  32 
  33 # OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
  34 GENERATED = ../generated
  35 OUTDIR  = $(GENERATED)/adfiles
  36 
  37 ARCH = $(Platform_arch)
  38 OS = $(Platform_os_family)
  39 
  40 SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
  41 
  42 SOURCES.AD = $(GAMMADIR)/src/cpu/$(ARCH)/vm/$(Platform_arch_model).ad \
  43              $(GAMMADIR)/src/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad 
  44 
  45 Src_Dirs += $(GAMMADIR)/src/share/vm/adlc
  46 
  47 EXEC    = $(OUTDIR)/adlc
  48 
  49 # set VPATH so make knows where to look for source files
  50 Src_Dirs_V = ${Src_Dirs} $(GENERATED)/incls
  51 VPATH    += $(Src_Dirs_V:%=%:)
  52 
  53 # set INCLUDES for C preprocessor
  54 Src_Dirs_I = ${Src_Dirs} $(GENERATED)
  55 INCLUDES += $(Src_Dirs_I:%=-I%)
  56 
  57 # set flags for adlc compilation
  58 CPPFLAGS = $(SYSDEFS) $(INCLUDES)
  59 
  60 # Force assertions on.
  61 CPPFLAGS += -DASSERT
  62 
  63 ifndef USE_GCC
  64   # We need libCstd.so for adlc 
  65   CFLAGS += -library=Cstd -g
  66   LFLAGS += -library=Cstd -g
  67 endif
  68 
  69 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
  70 CFLAGS += $(CFLAGS_WARN)
  71 
  72 ifeq ("${Platform_compiler}", "sparcWorks")
  73 # Enable the following CFLAGS addition if you need to compare the
  74 # built ELF objects.
  75 #
  76 # The -g option makes static data global and the "-Qoption ccfe
  77 # -xglobalstatic" option tells the compiler to not globalize static
  78 # data using a unique globalization prefix. Instead force the use
  79 # of a static globalization prefix based on the source filepath so
  80 # the objects from two identical compilations are the same.
  81 #CFLAGS += -Qoption ccfe -xglobalstatic
  82 endif # Platform_compiler == sparcWorks
  83 
  84 OBJECTNAMES = \
  85         adlparse.o \
  86         archDesc.o \
  87         arena.o \
  88         dfa.o \
  89         dict2.o \
  90         filebuff.o \
  91         forms.o \
  92         formsopt.o \
  93         formssel.o \
  94         main.o \
  95         adlc-opcodes.o \
  96         output_c.o \
  97         output_h.o \
  98 
  99 OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
 100 
 101 GENERATEDNAMES = \
 102         ad_$(Platform_arch_model).cpp \
 103         ad_$(Platform_arch_model).hpp \
 104         ad_$(Platform_arch_model)_clone.cpp \
 105         ad_$(Platform_arch_model)_expand.cpp \
 106         ad_$(Platform_arch_model)_format.cpp \
 107         ad_$(Platform_arch_model)_gen.cpp \
 108         ad_$(Platform_arch_model)_misc.cpp \
 109         ad_$(Platform_arch_model)_peephole.cpp \
 110         ad_$(Platform_arch_model)_pipeline.cpp \
 111         adGlobals_$(Platform_arch_model).hpp \
 112         dfa_$(Platform_arch_model).cpp \
 113 
 114 GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
 115 
 116 # #########################################################################
 117 
 118 all: $(EXEC)
 119 
 120 $(EXEC) : $(OBJECTS)
 121         @echo Making adlc
 122         $(QUIETLY) $(LINK_NOPROF.CC) -o $(EXEC) $(OBJECTS)
 123 
 124 # Random dependencies:
 125 $(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
 126 
 127 # The source files refer to ostream.h, which sparcworks calls iostream.h
 128 $(OBJECTS): ostream.h
 129 
 130 ostream.h :
 131         @echo >$@ '#include <iostream.h>'
 132 
 133 dump:
 134         : OUTDIR=$(OUTDIR)
 135         : OBJECTS=$(OBJECTS)
 136         : products = $(GENERATEDFILES)
 137 
 138 all: $(GENERATEDFILES)
 139 
 140 $(GENERATEDFILES): refresh_adfiles
 141 
 142 # Get a unique temporary directory name, so multiple makes can run in parallel.
 143 # Note that product files are updated via "mv", which is atomic.
 144 TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
 145 
 146 # Pass -D flags into ADLC.
 147 ADLCFLAGS += $(SYSDEFS)
 148 
 149 # Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
 150 ADLCFLAGS += -q -T
 151 
 152 # Normally, debugging is done directly on the ad_<arch>*.cpp files.
 153 # But -g will put #line directives in those files pointing back to <arch>.ad.
 154 #ADLCFLAGS += -g
 155 
 156 ifdef LP64
 157 ADLCFLAGS += -D_LP64
 158 else
 159 ADLCFLAGS += -U_LP64
 160 endif
 161 
 162 #
 163 # adlc_updater is a simple sh script, under sccs control. It is
 164 # used to selectively update generated adlc files. This should
 165 # provide a nice compilation speed improvement.
 166 #
 167 ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
 168 ADLC_UPDATER = adlc_updater
 169 $(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
 170         $(QUIETLY) cp $< $@; chmod +x $@
 171 
 172 # This action refreshes all generated adlc files simultaneously.
 173 # The way it works is this:
 174 # 1) create a scratch directory to work in.
 175 # 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
 176 # 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
 177 # 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
 178 # 5) If we actually updated any files, echo a notice.
 179 #
 180 refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
 181         @rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
 182         $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
 183  -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
 184             || { rm -rf $(TEMPDIR); exit 1; }
 185         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
 186         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
 187         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
 188         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
 189         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
 190         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
 191         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
 192         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
 193         $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
 194         $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
 195         $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
 196         $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
 197                 || echo "Rescanned $(SOURCE.AD) but encountered no changes."
 198         $(QUIETLY) rm -rf $(TEMPDIR)
 199 
 200 
 201 # #########################################################################
 202 
 203 $(SOURCE.AD): $(SOURCES.AD)
 204         $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
 205 
 206 #PROCESS_AD_FILES = cat
 207 # Pass through #line directives, in case user enables -g option above:
 208 PROCESS_AD_FILES = awk '{ \
 209     if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
 210     if (need_lineno && $$0 !~ /\/\//) \
 211       { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
 212     print }'
 213 
 214 $(OUTDIR)/%.o: %.cpp
 215         @echo Compiling $<
 216         $(QUIETLY) $(REMOVE_TARGET)
 217         $(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE)
 218 
 219 # Some object files are given a prefix, to disambiguate
 220 # them from objects of the same name built for the VM.
 221 $(OUTDIR)/adlc-%.o: %.cpp
 222         @echo Compiling $<
 223         $(QUIETLY) $(REMOVE_TARGET)
 224         $(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE)
 225 
 226 # #########################################################################
 227 
 228 clean   :
 229         rm $(OBJECTS)
 230 
 231 cleanall :
 232         rm $(OBJECTS) $(EXEC)
 233 
 234 # #########################################################################
 235 
 236 .PHONY: all dump refresh_adfiles clean cleanall