CC=gcc
CFLAGS=-pg -g3 -Wall -ansi -pedantic

all: test_graph test_search

test_graph: test_graph.o graph.o
	$(CC) $(CFLAGS) -o $@ $^

test_search: test_search.o search.o graph.o
	$(CC) $(CFLAGS) -o $@ $^

test_shortest_path: test_shortest_path.o shortest_path.o dijkstra.o graph.o pq.o
	$(CC) $(CFLAGS) -o $@ $^

test_graph.o graph.o: graph.h
test_search.o search.o: graph.h search.h
shortest_path.o: shortest_path.h graph.h
test_shortest_path.o: shortest_path.h graph.h dijkstra.h
dijkstra.o: dijkstra.h pq.h graph.h
pq.o: pq.h

test: test_graph test_search test_shortest_path
	./test_shortest_path
	valgrind --tool=memcheck --leak-check=yes ./test_shortest_path
	./test_graph
	valgrind --tool=memcheck --leak-check=yes ./test_graph
	./test_search
	valgrind --tool=memcheck --leak-check=yes ./test_search

clean:
	-rm -rf test_graph test_search test_shortest_path *.o
