duke@435: # twisti@1038: # Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. duke@435: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: # duke@435: # This code is free software; you can redistribute it and/or modify it duke@435: # under the terms of the GNU General Public License version 2 only, as duke@435: # published by the Free Software Foundation. duke@435: # duke@435: # This code is distributed in the hope that it will be useful, but WITHOUT duke@435: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: # version 2 for more details (a copy is included in the LICENSE file that duke@435: # accompanied this code). duke@435: # duke@435: # You should have received a copy of the GNU General Public License version duke@435: # 2 along with this work; if not, write to the Free Software Foundation, duke@435: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: # duke@435: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: # CA 95054 USA or visit www.sun.com if you need additional information or duke@435: # have any questions. duke@435: # duke@435: # duke@435: duke@435: # This makefile (adlc.make) is included from the adlc.make in the duke@435: # build directories. duke@435: # It knows how to compile, link, and run the adlc. duke@435: kamg@526: include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make duke@435: duke@435: # ######################################################################### duke@435: duke@435: # OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make: duke@435: GENERATED = ../generated duke@435: OUTDIR = $(GENERATED)/adfiles duke@435: duke@435: ARCH = $(Platform_arch) duke@435: OS = $(Platform_os_family) duke@435: duke@435: SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad duke@435: duke@435: SOURCES.AD = $(GAMMADIR)/src/cpu/$(ARCH)/vm/$(Platform_arch_model).ad \ duke@435: $(GAMMADIR)/src/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad duke@435: duke@435: Src_Dirs += $(GAMMADIR)/src/share/vm/adlc duke@435: duke@435: EXEC = $(OUTDIR)/adlc duke@435: duke@435: # set VPATH so make knows where to look for source files duke@435: Src_Dirs_V = ${Src_Dirs} $(GENERATED)/incls duke@435: VPATH += $(Src_Dirs_V:%=%:) duke@435: duke@435: # set INCLUDES for C preprocessor duke@435: Src_Dirs_I = ${Src_Dirs} $(GENERATED) duke@435: INCLUDES += $(Src_Dirs_I:%=-I%) duke@435: jrose@910: # set flags for adlc compilation jrose@910: CPPFLAGS = $(SYSDEFS) $(INCLUDES) jrose@910: duke@435: # Force assertions on. jrose@910: CPPFLAGS += -DASSERT duke@435: duke@435: # CFLAGS_WARN holds compiler options to suppress/enable warnings. twisti@1038: # Compiler warnings are treated as errors twisti@1038: CFLAGS_WARN = -Werror duke@435: CFLAGS += $(CFLAGS_WARN) duke@435: duke@435: OBJECTNAMES = \ duke@435: adlparse.o \ duke@435: archDesc.o \ duke@435: arena.o \ duke@435: dfa.o \ duke@435: dict2.o \ duke@435: filebuff.o \ duke@435: forms.o \ duke@435: formsopt.o \ duke@435: formssel.o \ duke@435: main.o \ duke@435: adlc-opcodes.o \ duke@435: output_c.o \ duke@435: output_h.o \ duke@435: duke@435: OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%) duke@435: duke@435: GENERATEDNAMES = \ duke@435: ad_$(Platform_arch_model).cpp \ duke@435: ad_$(Platform_arch_model).hpp \ duke@435: ad_$(Platform_arch_model)_clone.cpp \ duke@435: ad_$(Platform_arch_model)_expand.cpp \ duke@435: ad_$(Platform_arch_model)_format.cpp \ duke@435: ad_$(Platform_arch_model)_gen.cpp \ duke@435: ad_$(Platform_arch_model)_misc.cpp \ duke@435: ad_$(Platform_arch_model)_peephole.cpp \ duke@435: ad_$(Platform_arch_model)_pipeline.cpp \ duke@435: adGlobals_$(Platform_arch_model).hpp \ duke@435: dfa_$(Platform_arch_model).cpp \ duke@435: duke@435: GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%) duke@435: duke@435: # ######################################################################### duke@435: duke@435: all: $(EXEC) duke@435: duke@435: $(EXEC) : $(OBJECTS) duke@435: @echo Making adlc duke@435: $(QUIETLY) $(LINK_NOPROF.CC) -o $(EXEC) $(OBJECTS) duke@435: duke@435: # Random dependencies: duke@435: $(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 duke@435: duke@435: # The source files refer to ostream.h, which sparcworks calls iostream.h duke@435: $(OBJECTS): ostream.h duke@435: duke@435: ostream.h : duke@435: @echo >$@ '#include ' duke@435: duke@435: dump: duke@435: : OUTDIR=$(OUTDIR) duke@435: : OBJECTS=$(OBJECTS) duke@435: : products = $(GENERATEDFILES) duke@435: duke@435: all: $(GENERATEDFILES) duke@435: duke@435: $(GENERATEDFILES): refresh_adfiles duke@435: duke@435: # Get a unique temporary directory name, so multiple makes can run in parallel. duke@435: # Note that product files are updated via "mv", which is atomic. duke@435: TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) duke@435: jrose@910: # Pass -D flags into ADLC. jrose@910: ADLCFLAGS += $(SYSDEFS) jrose@910: jrose@910: # Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. jrose@910: ADLCFLAGS += -q -T jrose@910: jrose@910: # Normally, debugging is done directly on the ad_*.cpp files. jrose@910: # But -g will put #line directives in those files pointing back to .ad. jrose@910: #ADLCFLAGS += -g duke@435: duke@435: ifdef LP64 duke@435: ADLCFLAGS += -D_LP64 duke@435: else duke@435: ADLCFLAGS += -U_LP64 duke@435: endif duke@435: duke@435: # duke@435: # adlc_updater is a simple sh script, under sccs control. It is duke@435: # used to selectively update generated adlc files. This should duke@435: # provide a nice compilation speed improvement. duke@435: # kamg@526: ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) duke@435: ADLC_UPDATER = adlc_updater jrose@910: $(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) jrose@910: $(QUIETLY) cp $< $@; chmod +x $@ duke@435: duke@435: # This action refreshes all generated adlc files simultaneously. duke@435: # The way it works is this: duke@435: # 1) create a scratch directory to work in. duke@435: # 2) if the current working directory does not have $(ADLC_UPDATER), copy it. duke@435: # 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. duke@435: # 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. duke@435: # 5) If we actually updated any files, echo a notice. duke@435: # jrose@910: refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) duke@435: @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) duke@435: $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ duke@435: -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 \ duke@435: || { rm -rf $(TEMPDIR); exit 1; } duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) duke@435: $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \ duke@435: || echo "Rescanned $(SOURCE.AD) but encountered no changes." duke@435: $(QUIETLY) rm -rf $(TEMPDIR) duke@435: duke@435: duke@435: # ######################################################################### duke@435: duke@435: $(SOURCE.AD): $(SOURCES.AD) jrose@910: $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) jrose@910: jrose@910: #PROCESS_AD_FILES = cat jrose@910: # Pass through #line directives, in case user enables -g option above: jrose@910: PROCESS_AD_FILES = awk '{ \ jrose@910: if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ jrose@910: if (need_lineno && $$0 !~ /\/\//) \ jrose@910: { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ jrose@910: print }' duke@435: duke@435: $(OUTDIR)/%.o: %.cpp duke@435: @echo Compiling $< duke@435: $(QUIETLY) $(REMOVE_TARGET) duke@435: $(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE) duke@435: duke@435: # Some object files are given a prefix, to disambiguate duke@435: # them from objects of the same name built for the VM. duke@435: $(OUTDIR)/adlc-%.o: %.cpp duke@435: @echo Compiling $< duke@435: $(QUIETLY) $(REMOVE_TARGET) duke@435: $(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE) duke@435: duke@435: # ######################################################################### duke@435: duke@435: clean : duke@435: rm $(OBJECTS) duke@435: duke@435: cleanall : duke@435: rm $(OBJECTS) $(EXEC) duke@435: duke@435: # ######################################################################### duke@435: duke@435: .PHONY: all dump refresh_adfiles clean cleanall