CFLAGS = -Wall -O
# CFLAGS = -Wall -O -DTRACE

SORTS = insertion-sort.o \
        recursive-merge-sort.o \
        simple-bucket-sort.o bucket.o

default: isort competition 

tests: test-fake test-isort test-rms test-sbs

# +-----------------+------------------------------------------------
# | Primary Targets |
# +-----------------+

competition: competition.o $(SORTS) strutils.o
	$(CC) $(CFLAGS) -o $@ $^

# +-------+----------------------------------------------------------
# | Tests |
# +-------+

test-fake: test-fake.o fake-sort.o sort-tester.o strutils.o
	$(CC) $(CFLAGS) -o $@ $^

test-isort: test-insertion-sort.o insertion-sort.o sort-tester.o strutils.o
	$(CC) $(CFLAGS) -o $@ $^

test-rms: test-rms.o recursive-merge-sort.o sort-tester.o strutils.o
	$(CC) $(CFLAGS) -o $@ $^

test-sbs: test-sbs.o simple-bucket-sort.o recursive-merge-sort.o sort-tester.o strutils.o bucket.o
	$(CC) $(CFLAGS) -o $@ $^

# +-------+----------------------------------------------------------
# | Sorts |
# +-------+

isort: isort.o insertion-sort.o sort-tester.o strutils.o sort-main.o
	$(CC) $(CFLAGS) -o $@ $^

# +------+-----------------------------------------------------------
# | Misc |
# +------+

tarball:
	tar cvf sort.tar Makefile *.c *.h
