-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (42 loc) · 1.07 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
BUILDDIR = ./bin
CFLAGS = -lwiringPi -O3
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
CONFDIR = /etc/coolpi
SERVICEDIR = /lib/systemd/system
SERVICEFILE = ./coolpi.service
TOOLDIR = ./tools
INSTALL = cp -a
target = coolpi
OBCS = $(shell find ./src -name "*.c")
DEPS = $(shell find ./src -name "*.h")
OBJS = $(OBCS:./src%.c=./bin%.o)
$(target): dirpre $(OBJS)
$(CC) -o $(BUILDDIR)/$(target) $(OBJS) $(CFLAGS)
$(OBJS): ./bin%.o: ./src%.c $(DEPS)
$(CC) -o $@ $(CFLAGS) -c $<
.PHONY: clean install uninstall dirpre
clean:
rm -rf $(BUILDDIR)
install:
mkdir -p $(CONFDIR)
@chmod a+x tools/uninstall.sh
$(INSTALL) $(BUILDDIR)/$(target) $(BINDIR)
$(INSTALL) $(TOOLDIR)/* $(CONFDIR)
$(INSTALL) $(SERVICEFILE) $(SERVICEDIR)
@echo "enable the service"
@systemctl daemon-reload
@systemctl enable coolpi.service
@systemctl restart coolpi.service
@echo "Done!"
uninstall:
@echo "stopping the coolpi"
@systemctl stop coolpi
@echo Stopped
rm -f $(BINDIR)/$(target)
rm -rf $(CONFDIR)
rm -f $(SERVICEDIR)/$(SERVICEFILE)
@systemctl daemon-reload
@echo "Done"
dirpre:
@mkdir -p $(BUILDDIR)