hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 12 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index a30b93c..c107cb3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,9 @@
CC = cc
LEX = flex
-CFLAGS = -std=c17 -Wall -Wextra -Werror -Wpedantic -O2
+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/ast.o bin/main.o
+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
@@ -18,13 +19,19 @@ sfinae: $(OBJECTS)
bin/lexer.c: sfinae.l | bin
$(LEX) -o bin/lexer.c sfinae.l
-bin/lexer.o: bin/lexer.c lexer.h
+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: lexer.h
+bin/main.o: ast.h lexer.h
bin/ast.o: ast.h lexer.h
debug: CFLAGS += $(SANITIZE)
@@ -40,7 +47,7 @@ format:
clang-format -i $(SOURCES)
lint:
- clang-tidy ast.c main.c -- -std=c17
+ clang-tidy ast.c main.c -- -std=c17 -Ibin
clean:
rm -rf bin sfinae