# Copyright (C) 2005, The Perl Foundation.
# $Id: root.in 13153 2006-07-04 22:59:35Z bernhard $

# Makefile for languages/scheme

# Setup of some commands
PERL       = @perl@
RM_F       = @rm_f@

DIR        = languages/scheme
TOOL_DIR   = ../..
ASM        = ../../parrot
SCHEMEC    = $(PERL) schemec
INTERP     = ./@test_prog@

default: build

help :
	@echo ""
	@echo "Following targets are available for the user:"
	@echo ""
	@echo "  build:             Just check whether 'schemec' compiles"
	@echo "                     This is the default."
	@echo ""
	@echo "  test:              run the test suite,"
	@echo ""
	@echo "  clean:             clean up temporary files"
	@echo ""
	@echo "  realclean:         clean up generated files"
	@echo ""
	@echo "  help:              print this help message"

foo: foo.scheme schemec
	$(SCHEMEC) foo.scheme > foo.pasm
	$(ASM) -o foo.pbc foo.pasm
	cd $(TOOL_DIR); $(INTERP) $(DIR)/foo.pbc
	cat foo.pasm

#
# Compilation:
#

build:
	$(PERL) -c schemec

test.pasm: test.scheme schemec
	$(SCHEMEC) test.scheme > test.pasm

and.pasm: and.scheme schemec
	$(SCHEMEC) and.scheme > and.pasm

foo.pasm: foo.scheme schemec
	$(SCHEMEC) foo.scheme > foo.pasm

#
# Assembly:
#

test.pbc: test.pasm
	$(ASM) -o $@ $?

and.pbc: and.pasm
	$(ASM) -o $@ $?

foo.pbc: foo.pasm
	$(ASM) -o $@ $?

#
# Other targets:
#

all: test.pbc and.pbc foo.pbc

clean:
	$(RM_F) foo.pasm foo.pbc \
	        "t/*/*.pasm" \
	        "t/*/*.pbc" \
	        "t/*/*.scheme" \
	        "t/*/*.out"

realclean: clean
	$(RM_RF) Makefile

over:
	@$(MAKE) clean
	@$(MAKE) all

test:
	cd .. && $(PERL) scheme/t/harness
#	cd $(TOOL_DIR); $(INTERP) $(DIR)/test.pbc
#	cd $(TOOL_DIR); $(INTERP) $(DIR)/and.pbc
#	cd $(TOOL_DIR); $(INTERP) $(DIR)/foo.pbc

#
# End of file.
#
