-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
85 lines (65 loc) · 2.41 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
.PHONY = all clean distclean install uninstall
CC = gcc
prefix=/usr/local
bindir=$(prefix)/bin
datadir=$(prefix)/share
default_prefix=/usr/local
SRCS := $(wildcard Source/*.c)
install_data_dir = $(DESTDIR)$(datadir)/fpms
install_bin_dir = $(DESTDIR)$(bindir)
networkinfo_rel_dir = share/fpms/BakeBit/Software/Python/scripts/networkinfo
binary_name=NanoHatOLED
SERVICE_SUBS = \
s,[@]bindir[@],$(bindir),g; \
s,[@]datadir[@],$(datadir),g; \
s,[@]networkinfo[@],$(prefix)/$(networkinfo_rel_dir),g
OLED_SCRIPT_SUBS = \
s,[@]bindir[@],$(bindir),g; \
s,[@]binary_name[@],$(binary_name),g
LDCFLAGS += -lrt -lpthread
all: $(binary_name)
$(binary_name): $(SRCS)
# $@ = target (NanoHatOLED); $^ = prerequisites (SRCS files)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDCFLAGS)
oled-start: oled-start.in
@echo "Set variables on oled-start script"
sed -e '$(OLED_SCRIPT_SUBS)' $< > $@
chmod +x $@
fpms.service: fpms.service.in
@echo "Set the prefix on fpms.service"
sed -e '$(SERVICE_SUBS)' $< > $@
networkinfo.service: networkinfo.service.in
@echo "Set the prefix on networkinfo.service"
sed -e '$(SERVICE_SUBS)' $< > $@
install: installdirs $(binary_name) oled-start fpms.service networkinfo-links networkinfo.service
cp -rf $(filter-out debian fpms.service.in $^,$(wildcard *)) $(install_data_dir)
install oled-start $(install_bin_dir)
install $(binary_name) $(install_bin_dir)
install -m 644 fpms.service $(DESTDIR)/lib/systemd/system
install -m 644 networkinfo.service $(DESTDIR)/lib/systemd/system
installdirs:
mkdir -p $(install_bin_dir) \
$(install_data_dir) \
$(DESTDIR)/lib/systemd/system
networkinfo-links:
ln -fs ../$(networkinfo_rel_dir)/reachability.sh $(install_bin_dir)/reachability
ln -fs ../$(networkinfo_rel_dir)/publicip.sh $(install_bin_dir)/publicip
ln -fs ../$(networkinfo_rel_dir)/watchinternet.sh $(install_bin_dir)/watchinternet
ln -fs ../$(networkinfo_rel_dir)/telegrambot.sh $(install_bin_dir)/telegrambot
ln -fs ../$(networkinfo_rel_dir)/ipconfig.sh $(install_bin_dir)/ipconfig
ln -fs ../$(networkinfo_rel_dir)/portblinker.sh $(install_bin_dir)/portblinker
clean:
-rm -f $(binary_name)
-rm -f oled-start
-rm -f fpms.service
distclean: clean
uninstall:
-rm -rf $(install_data_dir) \
$(install_bin_dir)/oled-start \
$(DESTDIR)/lib/systemd/system \
$(bindir)/reachability \
$(bindir)/publicip \
$(bindir)/watchinternet \
$(bindir)/telegrambot \
$(bindir)/ipconfig \
$(bindir)/portblinker