# Makefile for Kim Oldfield's tetribot client.

CC=gcc
#CFLAGS=-Wall -Itclient -O2 -ffast-math -funroll-loops
CFLAGS=-Wall -Itclient -ggdb -ffast-math -funroll-loops
# -ggdb - debugging
# -pg   - profiling

default: tetrinet_ai

# Use this on hackfest.linux.conf.au:
tetrinet_ai: kimo.o
	$(CC) $(CFLAGS) -ltclient -L /usr/local/lib -lm -o $@ $<

# Use this when tclient is in the sub-directory tclient:
#tetrinet_ai: kimo.o tclient/tclient.o tclient/tcommon.o
#	$(CC) $(CFLAGS) -lm -o $@ $^

# Get the RCS version out of kimo.c:
DISTDIR=kimo-$(shell grep '^$$Revision: ' kimo.c | sed -e 's/$$Revision: \(.*\) $$$$/\1/')

upload: dist
	cp $(DISTDIR).tar.gz kimo.tar.gz
	rsync kimo.tar.gz kimo@hackfest.linux.conf.au::kimo/

dist: clean
	echo "Making distribution for $(DISTDIR)"
	-rm -r $(DISTDIR)
	mkdir $(DISTDIR)
	cp README $(DISTDIR)
	cp Makefile $(DISTDIR)
	cp kimo.c $(DISTDIR)
	cp GPL $(DISTDIR)
	mkdir $(DISTDIR)/tclient
	cp tclient/* $(DISTDIR)/tclient
	tar czvf $(DISTDIR).tar.gz $(DISTDIR)
	echo "The package file is: $(DISTDIR).tar.gz"

clean:
	-rm *.o *.so tetrinet_ai core
	#-$(MAKE) -C tclient clean
