-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
66 lines (46 loc) · 1.41 KB
/
makefile
File metadata and controls
66 lines (46 loc) · 1.41 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
CC=LD_LIBRARY_PATH=/usr/lib gcc
BASE_CFLAGS = $(shell cat compile_flags.txt | tr '\n' ' ')
CFLAGS = $(BASE_CFLAGS)
TS_LDFLAGS := -ltree-sitter -ldl
SRC_DIR = src
BUILD_DIR = build
TARGET = $(BUILD_DIR)/hed
TSI = $(BUILD_DIR)/tsi
SOURCES = $(shell find $(SRC_DIR) -type f -name "*.c")
HEADERS = $(shell find $(SRC_DIR) -type f -name "*.h")
OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES))
.PHONY: all clean run test test_args ts-langs strip_build
all: $(TARGET) $(TSI)
test:
$(MAKE) -C test test
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(TARGET): $(OBJECTS)
$(CC) -o $@ $^ $(LDFLAGS) $(TS_LDFLAGS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
# echo '@':$@, '^':$^, '<':$<
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(TSI): ts/ts_lang_install.c
$(CC) -Wall -Wextra -O2 -I/usr/include -o $@ $<
publish:
@echo "Publishing hed and tsi to /usr/local/bin/"
$(MAKE) install
install: $(TARGET) $(TSI)
cp $(TARGET) /usr/local/bin/hed
cp $(TSI) /usr/local/bin/tsi
ts-langs: $(BUILD_DIR)
@echo "Tree-sitter source files:"
cp -rf ts-langs build/ts-langs
cp -rf ts-langs/* ~/.config/hed/ts/
strip_build: $(BUILD_DIR) $(TARGET) $(TSI) ts-langs
@# Keep only final binaries in $(BUILD_DIR)
@find $(BUILD_DIR) -mindepth 1 -maxdepth 1 ! -name 'hed' ! -name 'tsi' -exec rm -rf {} +
clean:
rm -rf $(BUILD_DIR)
fmt:
clang-format -i $(SOURCES) $(HEADERS)
tags:
ctags -R --languages=C src
run: $(TARGET)
./$(TARGET)