-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (39 loc) · 1.46 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
# Some utility functions stolen from the Linux kernel build system,
# and slightly modified.
TMPDIR ?= /tmp
try-run = $(shell set -e; \
TMP="$(TMPDIR)/.$$$$.tmp"; \
TMPO="$(TMPDIR)/.$$$$.o"; \
if ($(1)) >/dev/null 2>&1; \
then echo "$(2)"; \
else echo "$(3)"; \
fi; \
rm -f "$$TMP" "$$TMPO")
# Unknown warning options are not fatal be default with clang, so use -Werror.
cc-option = $(call try-run,\
$(CC) $(CPPFLAGS) -Werror $(1) -c -x c /dev/null -o "$$TMPO",$(1),$(2))
CWARN := -Wall -Wextra
CWARN += -Wmissing-prototypes
CWARN += -Wunused-parameter
CWARN += -Wfloat-equal
CWARN += -Wpointer-arith
CWARN += -Wshadow
CWARN += $(call cc-option,-Wlogical-op,)
CWARN += $(call cc-option,-Wmissing-parameter-type,)
CWARN += $(call cc-option,-Wsuggest-attribute=pure,)
CWARN += $(call cc-option,-Wsuggest-attribute=const,)
CWARN += $(call cc-option,-Wsuggest-attribute=format,)
CWARN += $(call cc-option,-Wnewline-eof,)
CPPFLAGS := -D_GNU_SOURCE
CFLAGS = -std=gnu99 -O2 -g $(CWARN)
LDFLAGS =
LDLIBS =
depssuffix := deps
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(dir $*).$(notdir $*).$(depssuffix) -c -o $@ $<
%: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS)
all: cident
cident: LDFLAGS += -lsparse
cident: CWARN += $(call cc-option,-Wno-override-init,)
cident: CWARN += $(call cc-option,-Wno-initializer-overrides,)