HAXE	= /usr/bin/haxe
TEMPLATE	= $(CURDIR)/template/template.hxml
TEMPLATE_STRING	= "@BASENAME@"

SRCS	= $(wildcard *.hx) $(wildcard tinylib/*.hx)

SAMPLE_DIR	= samples
SAMPLES_XML	= $(wildcard $(SAMPLE_DIR)/*.xml)
SAMPLES_SWF = $(foreach file, $(SAMPLES_XML), $(file:.xml=.swf) )
##########################################
all:
	@echo "usage: make (target swf file)"
	@echo "       (target.swf%.xml).xml is required to build swf file"
%.swf : %.hxml %.xml $(SRCS)
	$(HAXE) $<
%.hxml : %.xml
	sed -e s/$(TEMPLATE_STRING)/`echo $< | sed -e "s/\\//\\\\\\\\\//g" -e "s/.xml$$//"`/ $(TEMPLATE) > $@
samples: $(SAMPLES_SWF)
clean-samples:
	rm -f $(SAMPLE_DIR)/*.swf
