-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
104 lines (68 loc) · 1.67 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
104
-include config.mk
DESTDIR ?=
PREFIX ?= /usr/local
CC ?= gcc
CFLAGS ?= -O3
LDFLAGS ?=
_APP = kvmd-fan
_CFLAGS = -MD -c -std=c17 -Wall -Wextra -D_GNU_SOURCE $(shell pkg-config --atleast-version=2 libgpiod 2> /dev/null && echo -DHAVE_GPIOD2)
_LDFLAGS = $(LDFLAGS) -lm -lpthread -liniparser -lmicrohttpd -lgpiod
_SRCS = $(shell ls src/*.c)
_BUILD = build
_LINTERS_IMAGE ?= kvmd-fan-linters
# =====
define optbool
$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1)
endef
ifneq ($(call optbool,$(WITH_WIRINGPI_STUB)),)
override _CFLAGS += -DWITH_WIRINGPI_STUB
else
override _LDFLAGS += -lwiringPi
endif
# =====
all: $(_APP)
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
install -m755 $(_APP) $(DESTDIR)$(PREFIX)/bin/$(_APP)
install-strip: install
strip $(DESTDIR)$(PREFIX)/bin/$(_APP)
$(_APP): $(_SRCS:%.c=$(_BUILD)/%.o)
$(info == LD $@)
@ $(CC) $^ -o $@ $(_LDFLAGS) $(_LIBS)
$(_BUILD)/%.o: %.c
$(info -- CC $<)
@ mkdir -p $(dir $@) || true
@ $(CC) $< -o $@ $(_CFLAGS)
release:
$(MAKE) clean
$(MAKE) tox
$(MAKE) push
$(MAKE) bump V=$(V)
$(MAKE) push
$(MAKE) clean
tox: linters
time docker run --rm \
--volume `pwd`:/src:ro \
--volume `pwd`/linters:/src/linters:rw \
-t $(_LINTERS_IMAGE) bash -c " \
cd /src \
&& tox -q -c linters/tox.ini $(if $(E),-e $(E),-p auto) \
"
linters:
docker build \
$(if $(call optbool,$(NC)),--no-cache,) \
--rm \
--tag $(_LINTERS_IMAGE) \
-f linters/Dockerfile linters
bump:
bumpversion $(if $(V),$(V),minor)
push:
git push
git push --tags
clean:
rm -rf $(_APP) $(_BUILD) *.sock
clean-all: clean
sudo rm -rf linters/.tox
_OBJS = $(_SRCS:%.c=$(_BUILD)/%.o)
-include $(_OBJS:%.o=%.d)
.PHONY: linters