#Alex Cohn and Jordan Shkolnick's makefile
#The library contains methods necessary to run and test a quicksort(String) method

CFLAGS = -I.
LIBDIRS = -L.
LIBS = -lcsc323
objects=array-utils.o quicksort.o
PREFIX=/tmp

all: qsort

clean:
	rm -f *.o *~ qsort qstest libcsc323.a core

install: qsort libcsc323.a
	install qsort $(PREFIX)/bin/qsort
	install libcsc323.a $(PREFIX)/lib/libcsc323.a
	install array-utils.h $(PREFIX)/include/array-utils.h

array-utils.o: array-utils.h
quicksort.o: quicksort.h array-utils.o

libcsc323.a: $(objects)
	ar cru libcsc323.a $(objects)
	ranlib libcsc323.a

#./qsort runs command line quicksort (after make qsort called)
qsort: qsort.o libcsc323.a
	cc -o qsort qsort.o $(LIBDIRS) $(LIBS)

qstest: qstest.o libcsc323.a
	cc -o qstest qstest.o $(LIBDIRS) $(LIBS)

#type make test to run the unit tests
test: qstest
	./qstest

.PHONY: all clean test
