CFLAGS=-Wall -fPIC -g -O2 -mcpu=power4
CC=gcc

all: libtclient.so beth tetrinet_ai

tcommon.o: tcommon.h

tclient.c: tcommon.h

libtclient.so: tclient.o tcommon.o
	ld -g -shared -o libtclient.so tclient.o tcommon.o -ldl

beth.o: tclient.h tetris.h move.h field.h
move.o: tclient.h tetris.h move.h field.h specials.h
tetris.o: tetris.h
field.o: tclient.h tetris.h field.h
specials.o: tclient.h field.h specials.h

beth: beth.o move.o libtclient.so tetris.o field.o specials.o
	$(CC) $(CFLAGS) -ltclient -L . -o beth beth.o move.o tetris.o field.o specials.o

test-move.o: tclient.h tetris.h move.h field.h specials.h
test-move: test-move.o move.o tetris.o field.o specials.o
	$(CC) $(CFLAGS) -o test-move test-move.o move.o tetris.o field.o specials.o

test-specials.o: tclient.h tetris.h specials.h field.h
test-specials: test-specials.o specials.o tetris.o field.o tclient.o
	$(CC) $(CFLAGS) -o test-specials test-specials.o specials.o tetris.o field.o

tetrinet_ai:
	ln -s beth tetrinet_ai

clean:
	rm -f *.o *.so beth test-move tetrinet_ai
