# $Id: /mirror/trunk/config/gen/makefiles/pge.in 35434 2009-01-11T10:42:49.818630Z fperrad  $

# Setup some commands
PERL     = @perl@
RM_F     = @rm_f@
CP       = @cp@
PARROT   = ../../parrot@exe@

TOOL_DIR = ../..

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

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

SOURCES = \
  PGE.pir \
  PGE/Exp.pir \
  PGE/Match.pir \
  PGE/Regex.pir \
  PGE/Perl6Regex.pir \
  PGE/OPTable.pir \
  PGE/P5Regex.pir \
  PGE/builtins.pg \

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

PGE.pbc: $(PARROT) $(SOURCES)
	$(RM_F) PGE.pbc $(PARROT_LIBRARY)/PGE.pbc
	$(PERL) -e "" >PGE/builtins_gen.pir
	$(PARROT) -o PGE.pbc --output-pbc PGE.pir
	$(PARROT) $(PARROT_LIBRARY)/PGE/Perl6Grammar.pir  --output=PGE/builtins_gen.pir PGE/builtins.pg
	$(RM_F) PGE.pbc
	$(PARROT) -o PGE.pbc --output-pbc PGE.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:               PGE.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
	cd $(TOOL_DIR) && prove -r t/compilers/pge

testclean:
	$(RM_F) "../../t/compilers/pge/*.pir" \
	    "../../t/compilers/pge/p5regex/*.pir" \
	    "../../t/compilers/pge/perl6regex/*.pir" \
	    "../../t/compilers/pge/*.pbc" \
	    "../../t/compilers/pge/p5regex/*.pbc" \
	    "../../t/compilers/pge/perl6regex/*.pbc"

clean: testclean
	$(RM_F) \
	    PGE.pbc \
	    $(PARROT_LIBRARY)/PGE.pbc \
	    PGE/builtins_gen.pir

realclean: clean
	$(RM_F) Makefile

distclean: realclean
