# Compiler to use
CC = gcc
# -g for debug, -O2 for optimise and -Wall additional messages -lm for including the Math library
OPTIONS = -O2 -g -Wall -lm
# Directory for header file
INCLUDES = -I .
# Defines for compilation
DEFINES = -DINITIAL_TESTS
debug: DEFINES += -DDEBUG
# Name of target binary
TARGET = polaron
# List of objects to be build
OBJS = \
	polaron.o \
	random.o \
	types.o

# To declare all, clean are not files
.PHONY: all clean
 
# The main targets
all: target
 
%.o: %.c  # % pattern wildcard matching
	${CC} ${OPTIONS} ${DEFINES} -c $*.c ${INCLUDES}

# To print output of command 'ls'
list:
	@echo $(shell ls)

# To clean this mess
clean:
	@echo "Cleaning up ..."
	-rm -rf *.o
	-rm ${TARGET}

# To link the program
target: ${OBJS}
	@echo "Building ..."
	${CC} ${OPTIONS} ${INCLUDES} ${OBJS} -o ${TARGET}

debug: ${OBJS}
	@echo "Building debug version ..."
	${CC} ${OPTIONS} ${INCLUDES} ${OBJS} -o ${TARGET}
