2024-08-24 17:34:21 -04:00
|
|
|
CC = gcc
|
|
|
|
CFLAGS =
|
|
|
|
CPPFLAGS = -Iinclude -MMD -MP
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -04:00
|
|
|
SRCDIR = src
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -04:00
|
|
|
SRCS = $(wildcard $(SRCDIR)/*.c)
|
|
|
|
OBJS = $(patsubst $(SRCDIR)/%.c,%.o,$(SRCS))
|
|
|
|
EXE = gc
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -04:00
|
|
|
DBDIR = debug
|
|
|
|
DBEXE = $(DBDIR)/$(EXE)
|
|
|
|
DBOBJS = $(addprefix $(DBDIR)/, $(OBJS))
|
|
|
|
DBCFLAGS = -g -O0 -DDEBUG
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -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
|
|
|
|
2024-08-24 17:34:21 -04:00
|
|
|
.PHONY: all clean debug prep release
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -04:00
|
|
|
all: debug release
|
2024-08-19 15:46:10 -04:00
|
|
|
|
|
|
|
debug: prep $(DBEXE)
|
|
|
|
|
|
|
|
$(DBEXE): $(DBOBJS)
|
2024-08-24 17:34:21 -04:00
|
|
|
$(CC) $(CFLAGS) $(DBCFLAGS) -o $@ $^
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -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)
|
2024-08-24 17:34:21 -04:00
|
|
|
$(CC) $(CFLAGS) $(RECFLAGS) -o $@ $^
|
2024-08-19 15:46:10 -04:00
|
|
|
|
2024-08-24 17:34:21 -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:
|
2024-08-24 17:34:21 -04:00
|
|
|
rm -rf $(DBDIR) $(REDIR)
|