-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (76 loc) · 3.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
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
SHELL = /bin/sh
CFLAGS := -O2 -mtune=native -Wall
CC := gcc
COMPILE.c = $(CC) $(CFLAGS)
SRCS = $(wildcard i2c/*.c spi/*.c bme280/*.c bme280/common/*.c utils/json/*.c sht3x/*.c sht3x/common/*.c)
PROGS = $(patsubst %.c,%.o,$(SRCS))
KVER = $(shell uname -r)
KMAJ = $(shell echo $(KVER) | \
sed -e 's/^\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*.*/\1/')
KMIN = $(shell echo $(KVER) | \
sed -e 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*.*/\1/')
OUT = bin
.PHONY: all directories clean install_common docs
build: directories $(OUT)/fan $(OUT)/bme $(OUT)/volt $(OUT)/leak $(OUT)/pru1.out
directories: $(OUT)
wireless: $(OUT)/wireless
$(OUT):
mkdir -p $(OUT)
$(OUT)/volt: /usr/local/lib/libhiredis.so main/volt.c spi/common.o
$(COMPILE.c) $^ -lpthread -fno-trapping-math -o $@ -lhiredis
$(OUT)/bme: /usr/local/lib/libhiredis.so main/bme.c $(PROGS)
$(COMPILE.c) $^ -o $@ -lhiredis
$(OUT)/wireless: /usr/local/lib/libhiredis.so main/wireless.c $(PROGS)
$(COMPILE.c) $^ -o $@ -lpthread -lhiredis
$(OUT)/fan: /usr/local/lib/libhiredis.so main/fan.c $(PROGS)
$(COMPILE.c) $^ -o $@ -lhiredis
$(OUT)/leak: /usr/local/lib/libhiredis.so main/leak.c $(PROGS)
$(COMPILE.c) $^ -o $@ -lhiredis
$(OUT)/pru1.out:
@if [ $(KMAJ) -gt 4 ] && [ $(KMIN) -gt 9 ] ; then \
$(MAKE) -C pru ; \
else \
echo "Kernel version incompatible with remoteproc implementation, skipping PRU..." ; \
fi
%.o: %.c
$(COMPILE.c) -c $^ -o $@
docs:
@doxygen docs/Doxyfile
@open docs/html/index.html
/usr/local/lib/libhiredis.so:
git clone https://github.com/redis/hiredis.git
cd ./hiredis; make && make install
grep -qxF 'include /usr/local/lib' /etc/ld.so.conf || \
echo 'include /usr/local/lib' >> /etc/ld.so.conf
ldconfig
rm -rf hiredis
install_common:
sed -i -e "3cSIMAR_FOLDER=$$PWD" ./start/simar_startup.sh
cp ./start/services/[email protected] /etc/systemd/system/.
cp ./start/conf/simar_log_conf /etc/logrotate.d/simar
grep -qxF ':syslogtag, isequal, "simar:" /var/log/simar/simar.log' /etc/rsyslog.conf || echo ':syslogtag, isequal, "simar:" /var/log/simar/simar.log' >> /etc/rsyslog.conf
install: install_common
sed -i '/bind 127.0.0.1/c\bind 0.0.0.0' /etc/redis/*.conf
sed -i '/protected-mode yes/c\protected-mode no' /etc/redis/*.conf
cp ./start/services/simar_volt.service /etc/systemd/system/.
service rsyslog restart
systemctl daemon-reload
install_wireless: install_common
sed -i -e "9iExecStartPre=/bin/sleep 8 " ./start/services/[email protected]
sed -i -e "9iExecStartPre=/bin/sh -c 'echo none > /sys/class/leds/beaglebone\:green\:usr3/trigger'" ./start/services/[email protected]
sed -i -e "9iExecStartPre=/bin/sh -c 'echo none > /sys/class/leds/beaglebone\:green\:usr2/trigger'" ./start/services/[email protected]
cp ./start/services/[email protected] /etc/systemd/system/.
cp ./start/conf/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
cp ./start/conf/99-local.rules /etc/udev/rules.d/99-local.rules
cp ./start/services/[email protected] /etc/systemd/system/[email protected]
cp ./start/services/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service
cp ./start/usb-mount.sh /usr/local/bin/usb-mount.sh
grep -qxF ':syslogtag, isequal, "simar\:" /var/log/simar/simar.log' /etc/rsyslog.conf || echo ':syslogtag, isequal, "simar:" /var/log/simar/simar.log' >> /etc/rsyslog.conf
service rsyslog restart
udevadm control --reload-rules
systemctl daemon-reload
systemctl start simar@wireless
systemctl enable simar@wireless
systemctl restart wpa_supplicant
clean:
rm -rf $(PROGS) $(OUT)