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

# Setup some commands
LN_S     = @lns@
PERL     = @perl@
RM_F     = @rm_f@
RM_RF    = @rm_rf@
PARROT   = ../../parrot@exe@
BUILD    = $(PERL) @build_dir@/tools/build/dynpmc.pl
TOOL_DIR = ../..
PGE_DIR  = ../../compilers/pge
TGE_DIR  = ../../compilers/tge
CAT      = $(PERL) -MExtUtils::Command -e cat
CP       = @cp@
O        = @o@
LOAD_EXT = @load_ext@
PARROT_DYNEXT = @build_dir@/runtime/parrot/dynext

PMCDIR   = src/pmc

# the default target
all: js.pbc #$(PMCDIR)/js_group$(LOAD_EXT)

#PMCS = \
#  jsobject \
#  jsinteger \
#  jshash \
#  jsbignum \
#  jscomplex \
#  jsfixnum \
#  jsfloat \
#  jsstring

#PMC_SOURCES = \
#  $(PMCDIR)/jsobject.pmc \
#  $(PMCDIR)/jsinteger.pmc \
#  $(PMCDIR)/jshash.pmc \
#  $(PMCDIR)/jsbignum.pmc \
#  $(PMCDIR)/jscomplex.pmc \
#  $(PMCDIR)/jsfixnum.pmc \
#  $(PMCDIR)/jsfloat.pmc \
#  $(PMCDIR)/jsstring.pmc

#BUILTINS_PIR = \
#  src/builtins/assign.pir \
#  src/builtins/cmp.pir \
#  src/builtins/io.pir

#GEN_PIR = \
#  src/js_grammar_gen.pir \
#  src/ASTGrammar.pir \
#  src/OSTGrammar.pir \
#  src/builtins_gen.pir

#GEN_PBC = \
#  src/CardinalGrammar.pbc \
#  src/PGE2AST.pbc \
#  src/AST2OST.pbc \
#  src/PAST.pbc \
#  src/POST.pbc

#js.pbc: js.pir $(GEN_PIR) $(GEN_PBC)
#	$(PARROT) -o js.pbc --output-pbc js.pir 
js.pbc: js.pir src/js_grammar_gen.pir
	$(PARROT) -o js.pbc --output-pbc js.pir 

#src/PAST.pbc: src/PAST.pir
#	$(PARROT) -o src/PAST.pbc --output-pbc src/PAST.pir 

#src/POST.pbc: src/POST.pir
#	$(PARROT) -o src/POST.pbc --output-pbc src/POST.pir 

src/js_grammar_gen.pir: src/js.pg src/js_optok.pg
  $(PARROT) $(PGE_DIR)/pgc.pir --output=src/js_grammar_gen.pir src/js.pg src/js_optok.pg

#src/js_grammar_gen.pbc: src/js_grammar_gen.pir
#	$(PARROT) -o src/js_grammar_gen.pbc --output-pbc src/js_grammar_gen.pir 

#src/CardinalGrammar.pbc: src/CardinalGrammar.pir src/js_grammar_gen.pir
#	$(PARROT) -o src/CardinalGrammar.pbc --output-pbc src/CardinalGrammar.pir 

#src/ASTGrammar.pir: src/ASTGrammar.tg
#	$(PARROT) $(TGE_DIR)/tgc.pir --output=src/ASTGrammar.pir src/ASTGrammar.tg

#src/PGE2AST.pbc: src/PGE2AST.pir src/ASTGrammar.pir src/preamble
#	$(PARROT) -o src/PGE2AST.pbc --output-pbc src/PGE2AST.pir 

#src/OSTGrammar.pir: src/OSTGrammar.tg
#	$(PARROT) $(TGE_DIR)/tgc.pir --output=src/OSTGrammar.pir src/OSTGrammar.tg

#src/AST2OST.pbc: src/AST2OST.pir src/OSTGrammar.pir src/preamble
#	$(PARROT) -o src/AST2OST.pbc --output-pbc src/AST2OST.pir 

#$(PMCDIR)/js_group$(LOAD_EXT): $(PARROT) $(PMC_SOURCES)
#	cd $(PMCDIR) && $(BUILD) generate $(PMCS)
#	cd $(PMCDIR) && $(BUILD) compile $(PMCS)
#	cd $(PMCDIR) && $(BUILD) linklibs $(PMCS)
#	cd $(PMCDIR) && $(BUILD) copy --destination=$(PARROT_DYNEXT) $(PMCS)

#src/builtins_gen.pir: $(BUILTINS_PIR)
#	$(CAT) $(BUILTINS_PIR) >src/builtins_gen.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:               js.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) -Isrc -I../../src t/harness

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

CLEANUPS = \
  js.pbc \
  $(GEN_PIR) \
  $(GEN_PBC) \
  $(PMCDIR)/*.h \
  $(PMCDIR)/*.c \
  $(PMCDIR)/*.dump \
  $(PMCDIR)/*$(O) \
  $(PMCDIR)/*$(LOAD_EXT) \
  t/*.out \
  t/*.rb

clean: 
	$(RM_RF) $(CLEANUPS)

realclean: clean
	$(RM_RF) Makefile

distclean: realclean
