.SUFFIXES:
.PHONY: default all clean mrproper indent zip

include Makefile_config.mak

CCFLAGS	:= -W -Wno-unused-parameter -Wall -std=gnu++14 -I $(SFML_INCLUDE_DIR)
LDFLAGS	:= -L $(SFML_LIB_DIR)


LIBS	:= -lsfml-graphics -lsfml-window -lsfml-system

CC_FILES	:= $(wildcard *.cc)
HH_FILES	:= $(wildcard *.hh)
O_FILES		:= $(CC_FILES:%.cc=%.o)
HELPER_FILES	:= $(wildcard Makefile*)

TARGET		:= main

###########################################################

default: all

all: $(TARGET)

$(TARGET): $(O_FILES) $(HELPER_FILES)
	$(CC) $(LDFLAGS) $(O_FILES) $(LIBS) -o $@

$(O_FILES): %.o: %.cc $(HH_FILES) $(HELPER_FILES)
	$(CC) $(CCFLAGS) -c $< -o $@

pdf: rapport2.tex
	latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S" rapport2.tex

clean:
	-rm -f $(O_FILES)
	-rm *.pdf *.ps
	-find . -type f -iname '*.orig' -delete

mrproper: clean
	-rm $(TARGET)

indent:
	clang-format -i -style=Mozilla $(CC_FILES) $(HH_FILES)

zip: all clean
	zip -r ../Raytracing.zip $(CC_FILES) $(HH_FILES) $(HELPER_FILES)
