2020-02-28 08:25:30 +03:00
|
|
|
# Install rc.local file
|
|
|
|
USER := $(shell whoami)
|
|
|
|
PATH := /usr/local/go/bin:$(PATH)
|
|
|
|
|
|
|
|
.SILENT:copy_files
|
|
|
|
.SILENT:hard_copy_files
|
2020-02-28 08:36:46 +03:00
|
|
|
.SILENT:build
|
2020-02-28 08:25:30 +03:00
|
|
|
.SILENT:clean
|
|
|
|
|
|
|
|
install: as_root copy_files build
|
|
|
|
@echo "Install complete"
|
|
|
|
|
|
|
|
install_hard: as_root hard_copy_files build
|
|
|
|
@echo "Install complete"
|
|
|
|
|
|
|
|
as_root:
|
|
|
|
ifneq ($(USER),root)
|
|
|
|
$(error Must run as superuser!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
copy_files:
|
|
|
|
if [ -f /etc/rc.local ] ; then \
|
|
|
|
echo "/etc/rc.local left unmodified" ; \
|
|
|
|
else \
|
|
|
|
cp rc.local /etc; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
hard_copy_files:
|
|
|
|
if [ -f /etc/rc.local ] ; then \
|
|
|
|
echo "Backed up rc.local to /etc/rc.local.bak" ; \
|
|
|
|
cp /etc/rc.local /etc/rc.local.bak ; \
|
|
|
|
fi
|
|
|
|
cp -f rc.local /etc
|
|
|
|
|
|
|
|
build:
|
|
|
|
if grep -q 'Raspberry Pi 3' '/proc/device-tree/model'; then \
|
|
|
|
echo "Compiling for Raspberry pi 3";\
|
|
|
|
go build -tags pi3;\
|
|
|
|
else \
|
|
|
|
echo "Compiling for Raspberry pi 0";\
|
|
|
|
go build -tags pi0;\
|
|
|
|
fi
|