Files
arl/Makefile
Aryadev Chavali 84996130b7 base: Added some extra logging macros
LOG, LOG_ERR.  LOG_ERR will always compile to a /stderr/ print.  LOG,
on the other hand, may not actually do anything if VERBOSE_LOGS is
not 1.  By default it is 0, so it must be defined when compiling to
enable - hence the adjustment of the Makefile.
2026-01-28 08:59:29 +00:00

52 lines
1001 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 -DVERBOSE_LOGS=1
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))
clangd: compile_commands.json
compile_commands.json: Makefile
bear -- $(MAKE) -B MODE=debug
.PHONY: run clean
ARGS=
run: $(OUT)
./$^ $(ARGS)
clean:
rm -rf $(DIST)
DEPS:=$(patsubst %,$(DEPDIR)/%.d, $(UNITS))
include $(wildcard $(DEPS))