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

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

# the default target
all: punie.pbc

lib/PunieGrammar.pbc: lib/PunieGrammar.pir lib/punie.pg
	$(PARROT) $(PGE_DIR)/pgc.pir --output=lib/punie_grammar_gen.pir lib/punie.pg
	$(PARROT) -o lib/PunieGrammar.pbc --output-pbc lib/PunieGrammar.pir 

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

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

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

punie.pbc: punie.pir lib/PunieGrammar.pbc lib/ASTGrammar.pbc lib/OSTGrammar.pbc lib/PIRGrammar.pbc
	$(PARROT) -o punie.pbc --output-pbc punie.pir 

# 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:               punie.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 -I../../lib t/harness

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

clean: testclean
	$(RM_F) punie.pbc \
	lib/punie_grammar_gen.pir \
	lib/PunieGrammar.pbc \
	lib/ASTGrammar.pbc \
	lib/ASTGrammar.pir \
	lib/OSTGrammar.pbc \
	lib/OSTGrammar.pir \
	lib/PIRGrammar.pbc \
	lib/PIRGrammar.pir

realclean: clean
	$(RM_F) Makefile

distclean: realclean
