# makefile adapted from http://www.mingw.org/mingwfaq.shtml#faq-Makefile

# defines source files
SRC=getopt.cpp icm.cpp cric.cpp comprisk.cpp
OBJ=$(SRC:.cpp=.o) # replaces the .c from SRC with .o
EXE=comprisk.exe

# util names and flags
CC=g++
CFLAGS=-Wall -O3
RM=rm

%.o: %.cpp       # combined w/ next line will compile recently changed .cpp files
	$(CC) $(CFLAGS) -o $@ -c $<

.PHONY : all     # .PHONY ignores files named all
all: $(EXE)      # all is dependent on $(EXE) to be complete

$(EXE): $(OBJ)   # $(EXE) is dependent on all of the files in $(OBJ) to exist
	$(CC) $(OBJ) -o $@

.PHONY : clean   # .PHONY ignores files named clean
clean:
	-$(RM) $(OBJ)  # '-' causes errors not to exit the process
