CC = cc LEX = flex YACC = bison CFLAGS = -std=c17 -Wall -Wextra -Werror -Wpedantic -O2 -Ibin SOURCES = ast.c ast.h lexer.h main.c OBJECTS = bin/lexer.o bin/parser.o bin/ast.o bin/main.o SANITIZE = -g -O0 -fsanitize=address,undefined .PHONY: all debug check format lint clean all: sfinae bin: mkdir -p bin sfinae: $(OBJECTS) $(CC) $(CFLAGS) -o $@ $(OBJECTS) bin/lexer.c: sfinae.l | bin $(LEX) -o bin/lexer.c sfinae.l bin/lexer.o: bin/lexer.c bin/parser.h ast.h lexer.h $(CC) -std=c17 -w -I. -c -o $@ bin/lexer.c bin/parser.c bin/parser.h: sfinae.y | bin $(YACC) -d -o bin/parser.c sfinae.y bin/parser.o: bin/parser.c $(CC) -std=c17 -w -I. -c -o $@ bin/parser.c bin/%.o: %.c | bin $(CC) $(CFLAGS) -c -o $@ $< bin/main.o: ast.h lexer.h bin/ast.o: ast.h lexer.h debug: CFLAGS += $(SANITIZE) debug: clean sfinae check: sfinae @for example in examples/*.sfinae; do \ echo "== $$example"; \ ./sfinae "$$example" || exit 1; \ done format: clang-format -i $(SOURCES) lint: clang-tidy ast.c main.c -- -std=c17 -Ibin clean: rm -rf bin sfinae