summaryrefslogtreecommitdiff
path: root/Makefile
blob: 6d732c23f39d577a2c2290bc26a31f0b82d09e07 (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
TARGET = crep
SOURCES = $(wildcard *.c *.h)
TS_ALIBS = $(shell find vendor -name "*.a" -print)
VENDOR_DIRS = $(wildcard vendor/*)
CFLAGS = $(EXTRA_FLAGS) -Wall -Wextra -std=gnu99 -pedantic -O3
LIBS = -I./vendor/tree-sitter/lib/include -lpthread

$(info VENDOR_DIRS: $(VENDOR_DIRS))
$(info SOURCES: $(SOURCES))
$(info TS_ALIBS: $(TS_ALIBS))
$(info CFLAGS: $(CFLAGS))
$(info LIBS: $(LIBS))

$(TARGET):
	$(CC) $(CFLAGS) $(SOURCES) $(LIBS) -o $(TARGET) $(TS_ALIBS)

all: ts-build query $(TARGET)

query:
	xxd -i -n query_c queries/c.scm > queries/c.h
	xxd -i -n query_python queries/python.scm > queries/python.h

ts-build:
	-cd vendor/tree-sitter && make -B
	-cd vendor/tree-sitter-c && make -B
	-cd vendor/tree-sitter-python && make -B

ts-clean:
	-cd vendor/tree-sitter && make clean
	-cd vendor/tree-sitter-c && make clean
	-cd vendor/tree-sitter-python && make clean

valgrind:
	valgrind -s --leak-check=full ./$(TARGET)

format:
	clang-format -i *.c *.h

clean:
	rm -f *.o $(TARGET) callgrind.out.*