Added Makefile

This commit is contained in:
Andrew Scott 2024-08-19 15:46:10 -04:00
parent 8d7a24bfda
commit 3d55ec9731
Signed by: a
GPG key ID: 7CD5A5977E4931C1

49
Makefile Normal file
View file

@ -0,0 +1,49 @@
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)