duke@435: # mikael@6198: # Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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: # trims@1907: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: # or visit www.oracle.com if you need additional information or have any trims@1907: # 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: kvn@3390: ifeq ("${Platform_arch_model}", "${Platform_arch}") kvn@3390: SOURCES.AD = \ adlertz@5510: $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) kvn@3390: else kvn@3390: SOURCES.AD = \ kvn@3390: $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \ adlertz@5510: $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) kvn@3390: endif duke@435: duke@435: EXEC = $(OUTDIR)/adlc duke@435: duke@435: # set VPATH so make knows where to look for source files stefank@2314: Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc stefank@2314: VPATH += $(Src_Dirs_V:%=%:) duke@435: duke@435: # set INCLUDES for C preprocessor stefank@2314: Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED) duke@435: INCLUDES += $(Src_Dirs_I:%=-I%) duke@435: jrose@910: # set flags for adlc compilation erikj@3518: CXXFLAGS = $(SYSDEFS) $(INCLUDES) jrose@910: duke@435: # Force assertions on. erikj@3518: CXXFLAGS += -DASSERT duke@435: duke@435: # CFLAGS_WARN holds compiler options to suppress/enable warnings. twisti@1038: # Compiler warnings are treated as errors simonis@5230: CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) 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: kevinw@9516: ADLC_LD_FLAGS= kevinw@9516: ifeq ($(STATIC_CXX), true) kevinw@9516: ADLC_LD_FLAGS = $(STATIC_LIBGCC) $(ADLC_STATIC_STDCXX) kevinw@9516: endif kevinw@9516: kevinw@9516: duke@435: $(EXEC) : $(OBJECTS) duke@435: @echo Making adlc kevinw@9516: $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.LINK_NOPROF.CXX)) $(ADLC_LD_FLAGS) -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: dcubed@3989: ifneq ($(DEBUG_BINARIES), true) dcubed@3989: # Debuggable by default (unless already done by DEBUG_BINARIES) dcubed@3989: CFLAGS += -g dcubed@3989: endif never@1831: 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. never@1961: # Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives never@1961: # so skip it for 3.2 and ealier. never@1961: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" never@1831: ADLCFLAGS += -g never@1961: endif 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) dholmes@4095: $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -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) dholmes@4095: $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -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