blob: c107cb31f229c3397f8faa6d2764f3b882bcbdb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
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
|