CC = gcc CFLAGS = -O3 -Wall -Wextra -Wpedantic SRCS = main.c gc.c OBJS = $(SRCS:.c=.o) EXE = gc DBDIR = debug DBEXE = $(DBDIR)/$(EXE) DBOBJS = $(addprefix $(DBDIR)/, $(OBJS)) DBCFLAGS = -g -O0 -DDEBUG REDIR = build REEXE = $(REDIR)/$(EXE) REOBJS = $(addprefix $(REDIR)/, $(OBJS)) .PHONY: all clean debug release prep all: debug release gc gc: $(REEXE) @cp $< $@ debug: prep $(DBEXE) $(DBEXE): $(DBOBJS) $(CC) $(CFLAGS) $(DBCFLAGS) -DTEST -o $@ $^ $(DBDIR)/%.o: %.c $(CC) -c $(CFLAGS) $(DBCFLAGS) -o $@ $< release: prep $(REEXE) $(REEXE): $(REOBJS) $(CC) $(CFLAGS) -o $@ $^ $(REDIR)/%.o: %.c $(CC) -c $(CFLAGS) -o $@ $< prep: @mkdir -p $(DBDIR) $(REDIR) clean: rm -rf gc $(DBDIR) $(REDIR)