## soundio library and test file GNU makefile for linux.
##
## Programmer:    Craig Stuart Sapp <craig@ccrma.stanford.edu>
## Creation Date: Sun Jan 20 12:40:05 PST 2002
## Last Modified: Sun Jan 20 12:40:15 PST 2002
## Filename:      ...soundio/Makefile
##
## To run this makefile, type (without quotes) "make".
##


# Use LINUX  for linux computers
# Use VISUAL for Windows computers
# Use SUN    for Sun computers
OSTYPE = LINUX


INCDIR     = ./
LIBFILE    = libsoundio.a
LIBDIR     = ./
COMPILER   = g++
DEFINES    = $(addprefix -D,$(OSTYPE))
LIBFLAGS   = -Wall -c -g -O6 $(DEFINES) -I$(INCDIR)
PROGFLAGS  = -Wall -O6 $(DEFINES) -I$(INCDIR)


LIBFILES = FileIO.o Options.o Options_private.o SoundFileRead.o \
	   SoundFileWrite.o SoundHeader.o 

#########################################################################

all:
	@echo "make library   = creates the soundio library file"
	@echo "make tests     = create test programs"
	@echo "make writetest = create test program for writing soundfiles"
	@echo "make readtest  = create test program for reading soundfiles"
	@echo "make runtest   = write and then read a test soundfile"
	@echo "make clean     = remove object files"


library: $(LIBFILES)
	@echo Creating soundio library file for linux ...
	-rm -f $(LIBFILE)
	ar r $(LIBFILE) *.o 
	ranlib $(LIBFILE)

tests: writetest readtest

writetest: 
	g++ $(PROGFLAGS) -o writetest writetest.cpp -L$(LIBDIR) -lsoundio \
		&& strip writetest
	
readtest: 
	g++ $(PROGFLAGS) -o readtest readtest.cpp -L$(LIBDIR) -lsoundio \
		&& strip readtest

runtest: writetest readtest
	rm -f z.wav
	./writetest -n 10 -s -5 z.wav
	./readtest z.wav

cleantest:
	rm -r writetest
	rm -r readtest
clean:
	rm -rf *.o


# defining an explicit rule for object file dependencies
%.o : %.cpp
	$(COMPILER) $(LIBFLAGS) -o $(notdir $@) $<


