# $Id: tge.in 17095 2007-02-20 20:11:27Z paultcochrane $

# Setup some commands
LN_S     = @lns@
PERL     = @perl@
RM_RF    = @rm_rf@
PARROT   = ../../parrot@exe@
PGE_DIR   = ../../compilers/pge
CP       = @cp@

# Where to put things
PARROT_LIBRARY    = ../../runtime/parrot/library

# the default target
all: $(PARROT_LIBRARY)/TGE.pbc

$(PARROT_LIBRARY)/TGE.pbc: TGE.pbc
	$(CP) TGE.pbc $(PARROT_LIBRARY)

TGE.pbc: TGE.pir TGE/Rule.pbc TGE/Parser.pbc TGE/Grammar.pbc TGE/Compiler.pbc TGE/Tree.pbc
	$(PARROT) -o TGE.pbc --output-pbc TGE.pir

TGE/Rule.pbc: TGE/Rule.pir
	$(PARROT) -o TGE/Rule.pbc --output-pbc TGE/Rule.pir

TGE/Tree.pbc: TGE/Tree.pir
	$(PARROT) -o TGE/Tree.pbc --output-pbc TGE/Tree.pir

TGE/Grammar.pbc: TGE/Grammar.pir
	$(PARROT) -o TGE/Grammar.pbc --output-pbc TGE/Grammar.pir

TGE/Compiler.pbc: TGE/Compiler.pir
	$(PARROT) -o TGE/Compiler.pbc --output-pbc TGE/Compiler.pir

TGE/Parser.pbc: TGE/Parser.pir
	$(PARROT) -o TGE/Parser.pbc --output-pbc TGE/Parser.pir

TGE/Parser.pir: TGE/Parser.pg
	$(PARROT) $(PGE_DIR)/pgc.pir --output=TGE//Parser.pir TGE//Parser.pg

# This is a listing of all targets, that are meant to be called by users
help:
	@echo ""
	@echo "Following targets are available for the user:"
	@echo ""
	@echo "  all:               TGE.pbc"
	@echo "                     This is the default."
	@echo "Testing:"
	@echo "  test:              Run the test suite."
	@echo "  testclean:         Clean up test results."
	@echo ""
	@echo "Cleaning:"
	@echo "  clean:             Basic cleaning up."
	@echo "  realclean:         Removes also files generated by 'Configure.pl'"
	@echo "  distclean:         Removes also anything built, in theory"
	@echo ""
	@echo "Misc:"
	@echo "  help:              Print this help message."
	@echo ""

test: all
	prove -r ../../t/compilers/tge

testclean:
	$(RM_RF) "../../t/compilers/tge/*.pir"

clean: testclean
	$(RM_RF) TGE.pbc \
	TGE/Rule.pbc \
	TGE/Parser.pir \
	TGE/Parser.pbc \
	TGE/Tree.pbc \
	TGE/Grammar.pbc \
	TGE/Compiler.pbc \
	$(PARROT_LIBRARY)/TGE.pbc

realclean: clean
	$(RM_RF) Makefile

distclean: realclean
