# $Id: /mirror/trunk/languages/perl6/config/makefiles/utils.in 25407 2008-02-01T07:32:20.072018Z chromatic  $

## arguments we want to run parrot with
PARROT_ARGS =

## configuration settings
BUILD_DIR     = @build_dir@
LOAD_EXT      = @load_ext@
O             = @o@

## Setup some commands
LN_S          = @lns@
PERL          = @perl@
RM_RF         = @rm_rf@
CP            = @cp@
MAKE          = @make_c@
PARROT        = ../../../../parrot@exe@
CAT           = $(PERL) -MExtUtils::Command -e cat
BUILD_DYNPMC  = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
RECONFIGURE   = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl

## places to look for things
PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
PGE_LIBRARY   = $(BUILD_DIR)/runtime/parrot/library/PGE
PERL6GRAMMAR  = $(PGE_LIBRARY)/Perl6Grammar.pbc
NQP           = $(BUILD_DIR)/compilers/nqp/nqp.pbc
PCT           = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
PBC_TO_EXE    = $(BUILD_DIR)/pbc_to_exe@exe@


all: perl6doc.pbc

PERL6DOC_SOURCES = \
  perl6doc.pir \
  perl6doc/gen_grammar.pir \
  perl6doc/gen_actions.pir \


perl6doc@exe@: perl6doc.pbc
	$(PBC_TO_EXE) perl6doc.pbc

perl6doc.pbc: $(PARROT) $(PERL6DOC_SOURCES)
	$(PARROT) $(PARROT_ARGS) -o perl6doc.pbc perl6doc.pir

perl6doc/gen_grammar.pir: $(PERL6GRAMMAR) perl6doc/grammar.pg
	$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
	    --output=perl6doc/gen_grammar.pir \
	    perl6doc/grammar.pg

perl6doc/gen_actions.pir: $(NQP) $(PCT) perl6doc/actions.pm
	$(PARROT) $(PARROT_ARGS) $(NQP) --output=perl6doc/gen_actions.pir \
	    --target=pir perl6doc/actions.pm


# regenerate the Makefile
Makefile: ../../config/makefiles/root.in ../../config/makefiles/utils.in
	cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=perl6

# 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:               perl6doc.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) t/harness t/01-sanity

# this target has nothing to do
testclean:

CLEANUPS = \
  perl6doc.pbc \
  perl6doc@exe@ \
  perl6doc.c \
  perl6doc/gen_grammar.pir \
  perl6doc/gen_actions.pir \


clean:
	$(RM_RF) $(CLEANUPS)

realclean: clean
	$(RM_RF) Makefile

distclean: realclean
