hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: e1140cfd0d7a78eb0bcb5789e523c48b803c5b44 (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
CC      = cc
LEX     = flex
CFLAGS  = -std=c17 -Wall -Wextra -Werror -Wpedantic -O2
SOURCES = lexer.h main.c
OBJECTS = bin/lexer.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 lexer.h
	$(CC) -std=c17 -w -I. -c -o $@ bin/lexer.c

bin/%.o: %.c | bin
	$(CC) $(CFLAGS) -c -o $@ $<

bin/main.o: 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 main.c -- -std=c17

clean:
	rm -rf bin sfinae