# FLAGS = -std=c99 -Wall -Wextra -pedantic -Werror -O3
FLAGS = -std=c99 -Wall -Wextra -pedantic -Werror -Wno-unused-parameter -Og -pg
LFLAGS = -lm

NOM = KURT

VERSIONS = $(wildcard maxflow-*_$(NOM).c)
EXE = $(subst maxflow,segment, $(VERSIONS:_$(NOM).c=))

GCC = gcc
# GCC = clang

FILES = naive_ppm.c stack.c queue.c graph.c log.c main.c
O_FILES = $(FILES:.c=.o)

all: $(EXE)

%.o: %.c naive_ppm.h stack.h graph.h
	$(GCC) $(FLAGS) -c $<

segment-%: maxflow-%_$(NOM).o $(O_FILES) Makefile
	$(GCC) $(FLAGS) $(O_FILES) $< -o $@ $(LFLAGS)

clean:
	rm -f *.o a.out gmon.out

veryclean: clean
	rm -f $(EXE) *-output.ppm

.SECONDARY: $(O_FILES)

.PHONY: all clean veryclean FORCE
