
# --- special targets ----------------------

all: heap_test heap_stats huffman_test run_huffman

clean:
	rm -f *.o

test:
	./heap_test && ./huffman_test

# --- explicit targets --------------------------------

run_huffman: utility.o heap.o huffman.o run_huffman.o
	gcc -lm utility.o heap.o huffman.o run_huffman.o -o run_huffman

huffman_test: utility.o heap.o huffman.o test_framework.o huffman_test.o
	gcc -lm utility.o heap.o huffman.o test_framework.o huffman_test.o -o huffman_test

heap_test: heap_test.o heap.o test_framework.o utility.o
	gcc heap_test.o heap.o test_framework.o utility.o -o heap_test

heap_stats: heap_stats.o heap.o utility.o
	gcc heap_stats.o heap.o utility.o -o heap_stats

utility.o: utility.h utility.c
	gcc -c utility.c -o utility.o

heap.o: utility.h heap.h heap.c
	gcc -c heap.c -o heap.o

test_framework.o: heap.h test_framework.h test_framework.c
	gcc -c test_framework.c -o test_framework.o

heap_test.o: heap.h heap_test.c
	gcc -c heap_test.c -o heap_test.o

heap_stats.o: utility.h heap.h heap_stats.c
	gcc -c heap_stats.c -o heap_stats.o

huffman.o: utility.h heap.h huffman.h huffman.c
	gcc -c huffman.c -o huffman.o

run_huffman.o: heap.h huffman.h run_huffman.c
	gcc -c run_huffman.c -o run_huffman.o

huffman_test.o: utility.h test_framework.h huffman.h huffman_test.c
	gcc -c huffman_test.c -o huffman_test.o


###########################################################
# Usage: 
#
#   $ make          # create executables listed in "all" line
#   $ make test     # run tests
#   $ make clean    # remove intermediate files
#
# --- notes -------------------------------------------------
#
# See http://www.gnu.org/software/make/manual/make.html
#
# Basically, a Makefile like this contains compilation rules, which
# let the "make" program figure out what needs to be recompiled
# depending on what has changed.
#
# explict rules : 
#
#    target_file : depends_file_1 depends_file_2
#             command that creates target_file from dependencies
#
# special rules
#
#     all: target1 target2 target 3    # what needs to be created
#
#     clean: 
#        what to do to remove intermediates
#
#     test:
#        how to run reality checks
#
# other
#
#     CC by default is the name of the C compiler; defaults to cc
#     CFLAGS by default are c compiler options
#
#     -lm is "-lib math" which is needed if <math.h> is included.
#
# $Id: Makefile 12620 2007-04-10 17:23:46Z mahoney $ 
#####################################################
