Files
arl/Makefile
Aryadev Chavali 76872179f9 *: Split off headers into their own folder
Main reason is so we don't have that stupid arl prefix directory in
our source code.  Now our source code is flat, and we can still
reference headers by linking from root.
2026-01-24 03:02:54 +00:00

48 lines
890 B
Makefile

CC=cc
DIST=build
OUT=$(DIST)/arl.out
MODULES=. lib parser
UNITS=main lib/vec lib/sv parser/ast parser/parser
OBJECTS:=$(patsubst %,$(DIST)/%.o, $(UNITS))
LDFLAGS=
GFLAGS=-Wall -Wextra -Wpedantic -std=c23 -I./include/
DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined
RFLAGS=-O3
MODE=release
ifeq ($(MODE), release)
CFLAGS=$(GFLAGS) $(RFLAGS)
else
CFLAGS=$(GFLAGS) $(DFLAGS)
endif
# Dependency generation
DEPFLAGS=-MT $@ -MMD -MP -MF
DEPDIR=$(DIST)/deps
$(OUT): $(OBJECTS) | $(DIST)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(DIST)/%.o: src/%.c | $(DIST) $(DEPDIR)
$(CC) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c -o $@ $<
$(DIST):
mkdir -p $(patsubst %,$(DIST)/%, $(MODULES))
$(DEPDIR):
mkdir -p $(patsubst %,$(DEPDIR)/%, $(MODULES))
.PHONY: run clean
ARGS=
run: $(OUT)
./$^ $(ARGS)
clean:
rm -rf $(DIST)
DEPS:=$(patsubst %,$(DEPDIR)/%.d, $(UNITS))
include $(wildcard $(DEPS))