#compiler
CC=gcc
#CC = clang

#put any desired compilation flags here.  Feel free to remove O2 or change to O3 or Ofast
#lm is to help find the math library
#make sure to run "make clean" if this is changed
CFLAGS=-O2 -lm

#flags to use when running make debug
#replaces CFLAGS
DEBUGFLAGS=-g -O0

#files to be kept up-to-date
OBJ = test.o twotowers.o

#include any files beyond .c files that depend on .o object files here
#(this likely only includes headers)
DEPS = twotowers.h

#only need test.out to build 'all' of project
all: test.out

#adds flags (set above) for make debug
#make sure to run "make clean" if no changes to source files
debug: CFLAGS=$(DEBUGFLAGS)
debug: test.out

#this rule says that every .o file needs to be compiled using the corresponding .c file
%.o: %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)

#this rule links the object files together and stores the output in test.out
test.out: $(OBJ)
	$(CC) -o $@ $^ $(CFLAGS)

#a possibly-sloppy way to undo making: remove all object files
clean: 
	rm $(OBJ)
