-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (62 loc) · 1.78 KB
/
Makefile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
VERSION = 0.1
TARGET = bin/ted
PREFIX = /usr/local
CPPFLAGS = -D_DEFAULT_SOURCE
CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -O2 $(CPPFLAGS)
CC = cc
SRC = $(addprefix src/, \
buffer.c cursor.c key.c main.c row.c screen.c term_control.c util.c \
)
OBJ = $(SRC:src/%.c=bin/%.o)
TEST_SRC = $(wildcard src/*_test.c)
TEST_SRC_OBJ = $(TEST_SRC:src/%_test.c=bin/%.o)
TEST_OBJ = $(TEST_SRC:src/%.c=bin/%.o)
TEST_BIN = $(TEST_SRC:src/%.c=bin/%)
TEST_LIBS = -lcriterion
DOC_SRC = $(wildcard src/*.h)
DOC_WEB = doc/web
DOC_ASSET = $(wildcard doc/asset/*/*)
all: $(TARGET)
options:
@echo "VERSION = $(VERSION)"
@echo "TARGET = $(TARGET)"
@echo "PREFIX = $(PREFIX)"
@echo "CFLAGS = $(CFLAGS)"
@echo "CC = $(CC)"
@echo "SRC = $(SRC)"
@echo "OBJ = $(OBJ)"
@echo "TEST_SRC = $(TEST_SRC)"
@echo "TEST_SRC_OBJ = $(TEST_SRC_OBJ)"
@echo "TEST_OBJ = $(TEST_OBJ)"
@echo "TEST_BIN = $(TEST_BIN)"
@echo "TEST_LIBS = $(TEST_LIBS)"
@echo "DOC_SRC = $(DOC_SRC)"
@echo "DOC_WEB = $(DOC_WEB)"
@echo "DOC_ASSET = $(DOC_ASSET)"
bin/:
mkdir bin/
bin/%.o: src/%.c | bin/
$(CC) -o $@ $< -c $(CFLAGS)
$(TARGET): $(OBJ)
$(CC) -o $@ $^
format:
clang-format -i src/*.[ch]
lint:
clang-tidy src/*.[ch]
$(TEST_BIN): $(TEST_OBJ) $(TEST_SRC_OBJ)
$(CC) -o $@ $^ $(TEST_LIBS)
test: $(TEST_BIN)
for test in $^; do ./$$test; done
$(DOC_WEB): $(DOC_SRC) $(DOC_ASSET) Doxyfile
doxygen Doxyfile
doc: $(DOC_WEB)
clean:
rm -rf $(DOC_WEB)
rm -f $(TARGET) $(OBJ) $(TEST_OBJ) $(TEST_BIN)
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f $(TARGET) $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/ted
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/ted
.PHONY: all options format lint test doc clean install uninstall