CC=gcc -ansi -Wall

CFLAGS=-O -g -I/usr/include/python2.4 -I/usr/lib/python2.4/config
#CFLAGS=-DDEBUG -O -g -I/usr/include/python2.4
#CFLAGS=-O3 -I/usr/include/python2.4

test: perform-c-test perform-python-low-level-test perform-python-comparison-test perform-python-bufsock-test perform-cxx-test good-news
	/bin/true

perform-python-bufsock-test: python-bufsock-test odirect.py _odirectcmodule.so
	find /boot -type f -perm +004 -print0 | ./python-bufsock-test
	touch perform-python-bufsock-test

perform-python-comparison-test: python-comparison-test odirect.py _odirectcmodule.so
	find /boot -type f -perm +004 -print0 | ./python-comparison-test
	touch perform-python-comparison-test

perform-python-low-level-test: python-low-level-test odirect.py _odirectcmodule.so
	./python-low-level-test `find /boot -type f -perm +004 -print`
	touch perform-python-low-level-test

perform-c-test: c-test
	./c-test `find /boot -type f -perm +004 -print`
	touch perform-c-test

# this cxx support is far from complete!  Sat Aug 19 12:36:52 PDT 2006
perform-cxx-test: cxx-test
	./cxx-test `find /boot -type f -perm +004 -print`
	touch perform-cxx-test

cxx-test.o: cxx-test.cxx
	$(CXX) -c cxx-test.cxx

cxx-test: odirect-cxx.o cxx-test.o
	$(CXX) -o cxx-test cxx-test.o odirect-cxx.o odirect.o

odirect-cxx.o: odirect-cxx.cxx odirect-cxx.H
	$(CXX) -c odirect-cxx.cxx

odirectcmodule.c: odirectcmodule.swg odirect.h
	swig -python -o odirectcmodule.c odirectcmodule.swg

odirectcmodule.o: odirectcmodule.c
	$(CC) -fpic $(CFLAGS) -c odirectcmodule.c

_odirectcmodule.so: odirectcmodule.o odirect.o
	$(CC) `./do-not-toast-functions` -shared odirectcmodule.o odirect.o -o _odirectcmodule.so

c-test: libodirect.a c-test.o
	$(CC) $(CFLAGS) -o c-test c-test.o -L. -lodirect

libodirect.a: odirect.o
	rm -f libodirect.a
	ar cqv libodirect.a odirect.o

odirect.o: odirect.c odirect.h sizes
	$(CC) -c $(CFLAGS) `./sizes` odirect.c

sizes: sizes.c
	$(CC) $(CFLAGS) -o sizes sizes.c

clean:
	rm -f c-test sizes *.o *.a odirectcmodule.c *.so perform-python-*-test perform-cxx-test cxx-test

good-news:
	echo All tests passed ':)'