mirror of
https://codeberg.org/andyscott/marCsweep.git
synced 2024-12-22 01:33:11 -05:00
48 lines
909 B
Makefile
48 lines
909 B
Makefile
CC = gcc
|
|
CFLAGS = -std=gnu11
|
|
CPPFLAGS = -Iinclude -MMD -MP
|
|
|
|
SRCDIR = src
|
|
|
|
SRCS := $(wildcard $(SRCDIR)/*.c)
|
|
OBJS := $(patsubst $(SRCDIR)/%.c,%.o,$(SRCS))
|
|
EXE = gc
|
|
|
|
DBDIR = debug
|
|
DBEXE := $(DBDIR)/$(EXE)
|
|
DBOBJS := $(addprefix $(DBDIR)/, $(OBJS))
|
|
DBCFLAGS = -g -O0 -DDEBUG
|
|
|
|
|
|
REDIR = bin
|
|
REEXE := $(REDIR)/$(EXE)
|
|
REOBJS := $(addprefix $(REDIR)/, $(OBJS))
|
|
RECFLAGS = -O3 -Wall -Wextra -Wpedantic -Werror
|
|
|
|
.PHONY: all clean debug prep release
|
|
|
|
all: debug release
|
|
|
|
debug: prep $(DBEXE)
|
|
|
|
$(DBEXE): $(DBOBJS)
|
|
$(CC) $(CFLAGS) $(DBCFLAGS) -o $@ $^
|
|
|
|
$(DBDIR)/%.o: $(SRCDIR)/%.c
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DBCFLAGS) -o $@ $<
|
|
|
|
release: prep $(REEXE)
|
|
|
|
$(REEXE): $(REOBJS)
|
|
$(CC) $(CFLAGS) $(RECFLAGS) -o $@ $^
|
|
|
|
$(REDIR)/%.o: $(SRCDIR)/%.c
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(RECFLAGS) -o $@ $<
|
|
|
|
prep:
|
|
@mkdir -p $(DBDIR) $(REDIR)
|
|
|
|
clean:
|
|
rm -rf $(DBDIR) $(REDIR)
|
|
|
|
-include $(OBJ:.o=.d)
|