-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (33 loc) · 1 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
builder := go
builddir := bin
exe := wgapi
path := /usr/local/bin
instdir := /usr/local/share/wgapi
instrelativedir := ../share/wgapi
systemddir := /etc/systemd/system
config := .env.sample
systemd := wgapi.service
tags := release
ldflags := -s -w
all: $(builddir)/$(exe)
$(builddir)/$(exe): main.go go.mod go.sum models router utils
$(builder) build -o $(builddir)/$(exe) -tags $(tags) -ldflags "$(ldflags)" $<
install: $(path)/$(exe) $(systemddir)/$(systemd)
$(path)/$(exe): $(instdir)/$(exe) $(instdir)/.env
ln -s $(instrelativedir)/$(exe) $(path)/$(exe)
$(instdir):
mkdir $(instdir)
$(instdir)/$(exe): $(instdir) $(builddir)/$(exe)
cp $(builddir)/$(exe) $(instdir)/$(exe)
chown root:root $(instdir)/$(exe)
chmod 4755 $(instdir)/$(exe)
$(instdir)/.env: $(instdir) $(config)
cp $(config) $(instdir)/.env
$(systemddir)/$(systemd): $(systemd)
cp $(systemd) $(systemddir)/$(systemd)
uninstall:
rm -rf $(path)/$(exe)
rm -rf $(instdir)
rm -rf $(systemddir)/$(systemd)
clean:
rm -rf $(builddir)