#
# makefile for binary search tree
#
# 'make -f Makefile.bst test-int-bst' makes the executable 
# (so does 'make -f Makefile.bst main')
# 'make -f Makefile.bst OPT=<opt> test-int-bst makes the executable
#   with a non-default optimization level <opt> 
#   (possible values are -g, -O0, etc.)
# 'make -f Makefile.bst clean' deletes object files
# 'make -f Makefile.bst xclean' deletes object files and executable
#
# to use valgrind to check for memory leaks and other malloc/free errors:
# 'make -f Makefile.bst OPT="-g -O0" test-int-bst
# 'valgrind test-int-bst'
#

OPT = -O
CFLAGS = -Wall -pedantic -std=c99 $(OPT)

EXE = test-int-bst
OBJS = test-int-bst.o test-helper.o int-bst.o

main: $(EXE)

$(EXE): $(OBJS)
	gcc $(CFLAGS) -o $(EXE) $(OBJS)

test-int-bst.o: test-int-bst.c int-bst.h

test-helper.o: test-helper.c test-helper.h

int-bst.o: int-bst.c int-bst.h

.PHONY: clean
clean:
	-rm $(OBJS)

.PHONY: xclean
xclean:
	-rm $(OBJS) $(EXE)

