-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (136 loc) · 5.13 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# houseportal - A simple web portal environment for home servers
#
# Copyright 2023, Pascal Martin
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
HAPP=houseportal
HROOT=/usr/local
SHARE=$(HROOT)/share/house
# Local build ---------------------------------------------------
OBJS= hp_udp.o \
hp_redirect.o \
houseportal.o \
houseportalhmac.o \
houselog_nostorage.o
LIBOJS= houselog_live.o \
houselog_sensor.o \
houselog_storage.o \
houseconfig.o \
houseportalclient.o \
houseportaludp.o \
houseportalhmac.o \
housedepositor.o \
housediscover.o
EXPORT_INCLUDE=houselog.h houseconfig.h houseportalclient.h housediscover.h housedepositor.h houselog_sensor.h
all: libhouseportal.a houseportal housediscover housedepositor
clean:
rm -f *.o *.a houseportal housediscover housedepositor
rebuild: clean all
%.o: %.c
gcc -c -Os -o $@ $<
libhouseportal.a: $(LIBOJS)
ar r $@ $^
ranlib $@
houseportal: $(OBJS) libhouseportal.a
gcc -Os -o houseportal $(OBJS) libhouseportal.a -lechttp -lssl -lcrypto -lrt
housediscover: housediscoverclient.c libhouseportal.a
gcc -Os -o housediscover housediscoverclient.c libhouseportal.a -lechttp -lssl -lcrypto -lrt
housedepositor: housedepositorclient.c libhouseportal.a
gcc -Os -o housedepositor housedepositorclient.c libhouseportal.a -lechttp -lssl -lcrypto -lrt
# Minimal tar file for installation. ----------------------------
package:
mkdir -p packages
tar -cf packages/houseportal-`date +%F`.tgz houseportal housediscover housedepositor $(EXPORT_INCLUDE) libhouseportal.a systemd.service public Makefile
# Application installation (distribution agnostic) --------------
dev:
mkdir -p $(HROOT)/lib
cp libhouseportal.a $(HROOT)/lib
chown root:root $(HROOT)/lib/libhouseportal.a
chmod 644 $(HROOT)/lib/libhouseportal.a
mkdir -p $(HROOT)/bin
cp housediscover $(HROOT)/bin
chown root:root $(HROOT)/bin/housediscover
chmod 755 $(HROOT)/bin/housediscover
cp housedepositor $(HROOT)/bin
chown root:root $(HROOT)/bin/housedepositor
chmod 755 $(HROOT)/bin/housedepositor
mkdir -p $(HROOT)/include
cp $(EXPORT_INCLUDE) $(HROOT)/include
for i in $(EXPORT_INCLUDE) ; do chown root:root $(HROOT)/include/$$i ; done
for i in $(EXPORT_INCLUDE) ; do chmod 644 $(HROOT)/include/$$i ; done
mkdir -p $(SHARE)/public
chmod 755 $(SHARE) $(SHARE)/public
cp public/house.css public/events.js $(SHARE)/public
chown root:root $(SHARE)/public/*
chmod 644 $(SHARE)/public/*.*
cp houseinstall.mak $(SHARE)/install.mak
chown root:root $(SHARE)/install.mak
chmod 644 $(SHARE)/install.mak
chmod 644 $(SHARE)/install.mak
install-app: dev
mkdir -p /etc/house
if [ -e /etc/houseportal/houseportal.config ] ; then mv /etc/houseportal/houseportal.config /etc/house/portal.config; fi
mkdir -p $(HROOT)/bin
chmod 755 $(HROOT)/bin
rm -f $(HROOT)/bin/houseportal $(HROOT)/bin/roof
cp houseportal $(HROOT)/bin
cp roof.sh $(HROOT)/bin/roof
chown root:root $(HROOT)/bin/houseportal $(HROOT)/bin/roof
chmod 755 $(HROOT)/bin/houseportal $(HROOT)/bin/roof
mkdir -p $(SHARE)/public
chown root:root $(SHARE)/public
chmod 755 $(SHARE) $(SHARE)/public
cp public/* $(SHARE)/public
icotool -c -o $(SHARE)/public/favicon.ico favicon.png
chown root:root $(SHARE)/public/*
chmod 644 $(SHARE)/public/*.*
touch /etc/default/housegeneric
touch /etc/default/houseportal
touch /etc/house/portal.config
uninstall-app:
rm -f $(HROOT)/bin/houseportal
rm -f $(HROOT)/bin/housediscover
rm -f $(HROOT)/bin/housedepositor
rm -f $(SHARE)/public/*.html
purge-app:
for i in $(EXPORT_INCLUDE) ; do rm -f $(HROOT)/include/$$i ; done
rm -f $(SHARE)/public/house.css $(SHARE)/public/events.js
rm -f $(SHARE)/public/favicon.ico
rm -f $(SHARE)/install.mak
rmdir --ignore-fail-on-non-empty $(SHARE)/public
rmdir --ignore-fail-on-non-empty $(SHARE)
purge-config:
rm -f /etc/default/houseportal /etc/house/portal.config
# System installation. ------------------------------------------
include ./houseinstall.mak
# Docker install ------------------------------------------------
docker: all
rm -rf build
mkdir -p build
cp Dockerfile build
mkdir -p build$(HROOT)/bin
cp houseportal build$(HROOT)/bin
chmod 755 build$(HROOT)/bin/houseportal
mkdir -p build$(SHARE)/public
cp public/* build$(SHARE)/public
chmod 644 build$(SHARE)/public/*
mkdir -p build/etc/default
touch build/etc/default/housegeneric
touch build/etc/default/houseportal
mkdir -p build/etc/house
touch build/etc/house/portal.config
cd build ; docker build -t houseportal .
rm -rf build