-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathMakefile
103 lines (81 loc) · 2.04 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
MAKEFLAGS += -r
BINDIR := bin
BIN := $(BINDIR)/fist
BIN_SOURCES := \
fist/bst.c \
fist/config.c \
fist/dstring.c \
fist/fist.c \
fist/hashmap.c \
fist/indexer.c \
fist/serializer.c \
fist/server.c \
fist/tests.c \
fist/lzf_c.c \
fist/lzf_d.c
BIN_SOURCES_CHECK := \
fist/bst.c \
fist/config.c \
fist/dstring.c \
fist/fist.c \
fist/hashmap.c \
fist/indexer.c \
fist/serializer.c \
fist/server.c \
fist/tests.c
BIN_HEADER_SOURCES := \
fist/bst.h \
fist/dstring.h \
fist/hashmap.h \
fist/indexer.h \
fist/serializer.h \
fist/server.h \
fist/version.h \
fist/tests.h \
fist/lzfP.h \
fist/lzf.h
BIN_OBJECTS := $(BIN_SOURCES:=.o)
BIN_DEPS := $(BIN_SOURCES:=.d)
DESTDIR =
prefix = /usr/local
CC ?= gcc
CFLAGS ?= -Wall -O2 -g
CFLAGS += -std=c99 -D_DEFAULT_SOURCE
LDFLAGS ?=
LDLIBS :=
MKDIR ?= mkdir -p
RM ?= rm -f
CLANG_FORMAT ?= clang-format
DIFF ?= diff
.PHONY: all clean distclean
all: $(BIN)
$(BIN): $(BIN_OBJECTS)
$(MKDIR) $(BINDIR)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
test: $(BIN)
cppcheck --quiet --std=c99 --enable=style,warning,performance,portability,unusedFunction --error-exitcode=1 $(BIN_SOURCES_CHECK)
valgrind --suppressions=valgrind.supp --leak-check=full --error-exitcode=1 $(BIN) -t
.PHONY: test
%.c.o: %.c
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
check_format:
$(foreach f, $(BIN_SOURCES), $(CLANG_FORMAT) $(f) | $(DIFF) -u $(f) -;)
$(foreach f, $(BIN_HEADER_SOURCES), $(CLANG_FORMAT) $(f) | $(DIFF) -u $(f) -;)
format:
$(foreach f, $(BIN_SOURCES), $(CLANG_FORMAT) -i $(f);)
$(foreach f, $(BIN_HEADER_SOURCES), $(CLANG_FORMAT) -i $(f);)
.PHONY: format check_format
clean:
-$(RM) $(BIN) $(BIN_OBJECTS) $(BIN_DEPS)
distclean: clean
-$(RM) fist.db
.PHONY: install uninstall
install: $(BIN)
install -D $(BIN) $(DESTDIR)$(prefix)/bin/fist
install -D fist.1 $(DESTDIR)$(prefix)/man/man1/fist.1
install -D fist_config.5 $(DESTDIR)$(prefix)/man/man5/fist_config.5
uninstall:
-$(RM) $(DESTDIR)$(prefix)/bin/fist \
$(DESTDIR)$(prefix)/man/man1/fist.1 \
$(DESTDIR)$(prefix)/man/man5/fist_config.5
-include $(BIN_DEPS)