forked from rszimm/sprinklers_pi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (76 loc) · 1.95 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
#
# Makefile for the Sprinkling System
VERSION := $(shell cat version.txt )
BUILD_DIR=build
CC=gcc
CCFLAGS=-O3 -Wall -fmessage-length=0 -MMD -MP -DLOGGING -DVERSION=\"$(VERSION)\" -Wno-psabi -std=c++11
CPP_SRCS += \
Event.cpp \
Logging.cpp \
Weather.cpp \
Wunderground.cpp \
Aeris.cpp \
DarkSky.cpp \
OpenWeather.cpp \
core.cpp \
port.cpp \
settings.cpp \
sprinklers_pi.cpp \
sysreset.cpp \
web.cpp
LIBS := -lsqlite3 -lwiringPi
LIBNAME=sprinklers_pi
OBJS=$(CPP_SRCS:%.cpp=$(BUILD_DIR)/%.o)
all: build_dir $(LIBNAME)
$(LIBNAME): $(OBJS)
@echo 'Building target: $@'
g++ -o "$@" $(OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
build_dir: ${BUILD_DIR}
${BUILD_DIR}:
mkdir -p ${BUILD_DIR}
$(BUILD_DIR)/%.o: %.cpp
$(CC) $(CCFLAGS) -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -c -o "$@" "$<"
.PHONY: build_dir
#Misc stuff below here..
IUSER = $(shell whoami)
install: all
ifneq ($(IUSER),root)
$(error You are not ROOT. Rerun with sudo)
endif
@cp -f $(LIBNAME) /usr/local/sbin
mkdir -p /web
-@cp -rf web/* /web/
cp -f sprinklers_init.d.sh /etc/init.d/sprinklers_pi
chmod a+x /etc/init.d/sprinklers_pi
mkdir -p /usr/local
mkdir -p /usr/local/etc
mkdir -p /usr/local/etc/sprinklers_pi
update-rc.d sprinklers_pi defaults
@echo "done"
upgrade: install
/etc/init.d/sprinklers_pi restart
remove:
ifneq ($(IUSER),root)
$(error You are not ROOT. Rerun with sudo)
endif
/etc/init.d/sprinklers_pi stop
rm -f /etc/init.d/sprinklers_pi
update-rc.d sprinklers_pi remove
rm -rf /usr/local/etc/sprinklers_pi
rm -f /usr/local/sbin/sprinklers_pi
rm -rf /web
package: clean
@mkdir -p /tmp/$(LIBNAME)-$(VERSION)
@cp -rf * /tmp/$(LIBNAME)-$(VERSION)
@rm -rf /tmp/$(LIBNAME)-$(VERSION)/web/json
@rm -rf /tmp/$(LIBNAME)-$(VERSION)/web/bin
tar -C/tmp -czvhf $(LIBNAME)-$(VERSION).tar.gz $(LIBNAME)-$(VERSION)
rm -rf /tmp/$(LIBNAME)-$(VERSION)
version:
@echo $(VERSION)
clean:
rm -rf $(BUILD_DIR) $(LIBNAME) settings db.sql *.tar.gz
FORCE:
# DO NOT DELETE