TCL_VERSION = 8.5.12
KITCREATOR_VERSION = 0.6.1
KITCREATOR_URL = http://www.rkeene.org/devel/kitcreator-$(KITCREATOR_VERSION).tar.gz
CC = diet gcc

all: tclkit

tclkit: kitcreator-$(KITCREATOR_VERSION) kitcreator-$(KITCREATOR_VERSION)/system
	echo 'echo "#include <strings.h>" >> generic/tclInt.h' > kitcreator-$(KITCREATOR_VERSION)/tcl/patchscripts/fixstrcasecmp.sh
	cd kitcreator-$(KITCREATOR_VERSION); KITCREATOR_PKGS='system' CC='$(CC)' ./kitcreator $(TCL_VERSION) --enable-kit-storage=cvfs --disable-load --disable-threads
	cp kitcreator-$(KITCREATOR_VERSION)/tclkit-$(TCL_VERSION) tclkit

kitcreator-$(KITCREATOR_VERSION)/system: kitcreator-$(KITCREATOR_VERSION)
	cp -rp kitcreator-modules/system kitcreator-$(KITCREATOR_VERSION)/

kitcreator-$(KITCREATOR_VERSION): kitcreator-$(KITCREATOR_VERSION).tar.gz
	tar -xf kitcreator-$(KITCREATOR_VERSION).tar.gz

kitcreator-$(KITCREATOR_VERSION).tar.gz:
	wget -O "$@.new" $(KITCREATOR_URL)
	tar -tf "$@.new" >/dev/null
	mv "$@.new" "$@"

clean:
	rm -f kitcreator-$(KITCREATOR_VERSION).tar.gz kitcreator-$(KITCREATOR_VERSION).tar.gz.new
	rm -f tclkit
	rm -rf kitcreator-$(KITCREATOR_VERSION)

distclean: clean

.PHONY: all clean distclean
