marCsweep/Makefile

49 lines
909 B
Makefile
Raw Normal View History

CC = gcc
CFLAGS = -std=gnu11
CPPFLAGS = -Iinclude -MMD -MP
2024-08-19 15:46:10 -04:00
SRCDIR = src
2024-08-19 15:46:10 -04:00
SRCS := $(wildcard $(SRCDIR)/*.c)
OBJS := $(patsubst $(SRCDIR)/%.c,%.o,$(SRCS))
EXE = gc
2024-08-19 15:46:10 -04:00
DBDIR = debug
DBEXE := $(DBDIR)/$(EXE)
DBOBJS := $(addprefix $(DBDIR)/, $(OBJS))
DBCFLAGS = -g -O0 -DDEBUG
2024-08-19 15:46:10 -04:00
REDIR = bin
REEXE := $(REDIR)/$(EXE)
REOBJS := $(addprefix $(REDIR)/, $(OBJS))
RECFLAGS = -O3 -Wall -Wextra -Wpedantic -Werror
2024-08-19 15:46:10 -04:00
.PHONY: all clean debug prep release
2024-08-19 15:46:10 -04:00
all: debug release
2024-08-19 15:46:10 -04:00
debug: prep $(DBEXE)
$(DBEXE): $(DBOBJS)
$(CC) $(CFLAGS) $(DBCFLAGS) -o $@ $^
2024-08-19 15:46:10 -04:00
$(DBDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DBCFLAGS) -o $@ $<
2024-08-19 15:46:10 -04:00
release: prep $(REEXE)
$(REEXE): $(REOBJS)
$(CC) $(CFLAGS) $(RECFLAGS) -o $@ $^
2024-08-19 15:46:10 -04:00
$(REDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(RECFLAGS) -o $@ $<
2024-08-19 15:46:10 -04:00
prep:
@mkdir -p $(DBDIR) $(REDIR)
clean:
rm -rf $(DBDIR) $(REDIR)
-include $(OBJ:.o=.d)