CC=gcc
CXX=g++
CFLAGS=-D_ISOC99_SOURCE  -fPIC -Wshadow -Wall -W -Wbad-function-cast -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wimplicit-function-declaration -Waggregate-return -Winline -Wpointer-arith -fno-common -ansi -Wredundant-decls -Wno-unused 
DEFS=
TEST_PROGS=testreverb testda testmulti testalut testtime  \
           testmultialut testalinitexit                 \
	   testsingle testnothread \
	   testmath           \
	   testmultinothread testpitch testdoppler 		 \
	   testsourcestop 	    testext teststream \
	   testcallback testorient testrelative testchannel     \
	   testpause \
	   testpitchnothread testpitch2 testpitchnothread2 \
	   testgain testchannel2 testloop testlistener testbufferuniq    \
	   testsourceuniq testgendelbuffer_error testgendelsource_error        \
	   testmultichannel testlistener2 testlistener3      \
	   testlistener4 testmp3 testvorbis testgainlinear \
	   testmultimp3 testpitch3 testpitch4 testqueue testqueue2       \
	   testqueue3 testcapture testmp32 testleak testmulticontext      \
	   testleak2 testmulticontext2 teststartstop testdevice \
	   teststrings testcpp testattributes

INC=-I../src -I../include -I../../include -I../audioconvert 
LIBOPENAL=../src/libopenal.a
LIBS=testlib.o -L../src $(LIBOPENAL)  -ldl -lm -lpthread -lvorbis -lvorbisfile

SUBDIRS :=
RM_RF := $(RM) -r
CLEAN_FILES := testlib.o $(TEST_PROGS)
DISTCLEAN_FILES := Makefile
MAINTAINER_CLEAN_FILES :=
REPO_CLEAN_FILES :=

% : %.c ../config.h testlib.o
	$(CC) $(INC) $(DEFS) $(CFLAGS) $< -o $@ $(LIBS)

% : %.cc ../config.h testlib.o
	$(CXX) $(INC) $(DEFS) $(CFLAGS) $< -o $@ $(LIBS)

all: testlib.o $(LIBOPENAL) $(TEST_PROGS) ../src/libopenal.a

testlib.o : testlib.c testlib.h ../config.h
	$(CC) $(INC) $(DEFS) $(CFLAGS) -c testlib.c -o testlib.o

libopenal: $(LIBOPENAL)

$(LIBOPENAL):
	(cd ../src && make all)

clean:
	for i in "" $(SUBDIRS) ; do test -z "$$i" || ( cd $$i && $(MAKE) clean ) done
	$(RM_RF) __rm_food $(CLEAN_FILES)

distclean:
	for i in "" $(SUBDIRS) ; do test -z "$$i" || ( cd $$i && $(MAKE) distclean ) done
	$(RM_RF) __rm_food $(CLEAN_FILES) $(DISTCLEAN_FILES)

maintainer-clean:
	for i in "" $(SUBDIRS) ; do test -z "$$i" || ( cd $$i && $(MAKE) maintainer-clean ) done
	$(RM_RF) __rm_food $(CLEAN_FILES) $(DISTCLEAN_FILES) $(MAINTAINER_CLEAN_FILES)

repo-clean:
	for i in "" $(SUBDIRS) ; do test -z "$$i" || ( cd $$i && $(MAKE) repo-clean ) done
	$(RM_RF) __rm_food $(CLEAN_FILES) $(DISTCLEAN_FILES) $(MAINTAINER_CLEAN_FILES) $(REPO_CLEAN_FILES)

.PHONY: all clean distclean maintainer-clean repo-clean
