rutile/Makefile
2025-01-19 20:47:25 -03:00

38 lines
984 B
Makefile

SRCDIR = ./compiler
COMPILER_SRCS != find $(SRCDIR) -type f -name '*.c'
COMPILER_OBJS := $(COMPILER_SRCS:.c=.o)
COMPILER_DEPS := $(COMPILER_OBJS:.o=.d)
ASAN = -fsanitize=address,undefined
CFLAGS := -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wvla -Wwrite-strings \
-Wnull-dereference -pipe -O0 -ggdb3 -std=c11
LDFLAGS := $(ASAN)
all: rutilec ast2dot
rutilec: ./rutilec.c $(COMPILER_OBJS)
touch $@
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@$(EXE)
ast2dot: ./tools/ast2dot.c $(COMPILER_OBJS)
touch $@
$(CC) $(CFLAGS) $(LDFLAGS) $< $(COMPILER_OBJS) -o $@$(EXE)
clean:
rm -f $(COMPILER_OBJS) $(COMPILER_DEPS) ./rutilec$(EXE) ./ast2dot$(EXE)
options:
@echo "Build options:"
@echo "CC = $(CC)"
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "ASan flags = $(ASAN)"
@echo "SRCS = $(COMPILER_SRCS)"
@echo "OBJS = $(COMPILER_OBJS)"
.PHONY: all clean options
-include $(COMPILER_DEPS)
%.o: %.c Makefile
$(CC) $(CFLAGS) $(ASAN) -MMD -MP -c -o $@ $<