# $Id: root.in 17096 2007-02-20 20:20:48Z paultcochrane $

# Setup some commands
PERL     = @perl@
RM_F     = @rm_f@
PARROT   = ../../parrot@exe@
PGE_DIR  = ../../compilers/pge
TGE_DIR  = ../../compilers/tge
CP       = @cp@

# the default target
all: pheme.pbc

lib/PhemeGrammar.pbc: lib/PhemeGrammar.pir lib/pheme_grammar_gen.pir
	$(PARROT) -o lib/PhemeGrammar.pbc lib/PhemeGrammar.pir

lib/pheme_grammar_gen.pir: lib/pheme.g
	$(PARROT) $(PGE_DIR)/pgc.pir --output=lib/pheme_grammar_gen.pir lib/pheme.g

lib/ASTGrammar.pbc: lib/pge2past.tg
	$(PARROT) $(TGE_DIR)/tgc.pir --output=lib/ASTGrammar.pir lib/pge2past.tg
	$(PARROT) -o lib/ASTGrammar.pbc lib/ASTGrammar.pir

lib/OSTGrammar.pbc: lib/past2post.tg
	$(PARROT) $(TGE_DIR)/tgc.pir --output=lib/OSTGrammar.pir lib/past2post.tg
	$(PARROT) -o lib/OSTGrammar.pbc lib/OSTGrammar.pir

lib/PIRGrammar.pbc: lib/post2pir.tg
	$(PARROT) $(TGE_DIR)/tgc.pir --output=lib/PIRGrammar.pir lib/post2pir.tg
	$(PARROT) -o lib/PIRGrammar.pbc lib/PIRGrammar.pir

lib/PhemeSymbols.pbc: lib/PhemeSymbols.pir
	$(PARROT) -o lib/PhemeSymbols.pbc lib/PhemeSymbols.pir

lib/PhemeCompiler.pbc: lib/PhemeCompiler.pir lib/POST.pbc
	$(PARROT) -o lib/PhemeCompiler.pbc lib/PhemeCompiler.pir

lib/POST.pbc: lib/POST.pir
	$(PARROT) -o lib/POST.pbc lib/POST.pir

pheme.pbc: lib/PhemeGrammar.pbc pheme.pir lib/PhemeSymbols.pbc lib/PhemeCompiler.pbc lib/ASTGrammar.pbc lib/OSTGrammar.pbc lib/PIRGrammar.pbc
	$(PARROT) -o pheme.pbc pheme.pir

# This is a listing of all targets that users can call
help:
	@echo ""
	@echo "Following targets are available for the user:"
	@echo ""
	@echo "  all:               pheme.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
	$(PERL) -Ilib t/harness

testclean:
	$(RM_F) "t/*.out"

clean: testclean
	$(RM_F) pheme.pbc
	$(RM_F) lib/pheme_grammar_gen.pir
	$(RM_F) lib/*.pbc

realclean: clean

distclean: realclean
