-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (38 loc) · 1.22 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
builder := go
builddir := bin
exe := nasa-judge-named
path := /usr/local/bin
importdir := middlewares models router utils
instdir := /usr/local/share/$(exe)
instrelativedir := $(subst /usr/local,..,$(instdir))
systemddir := /etc/systemd/system
config := .env
systemd := $(exe).service
ldflags := -s -w
tags := release
all: $(builddir)/$(exe)
$(builddir)/$(exe): main.go go.mod go.sum $(importdir)
$(builder) generate ./...
CGO_ENABLED=0 $(builder) build -o $(builddir)/$(exe) -tags $(tags) -ldflags "$(ldflags)" $<
run: main.go go.mod go.sum $(importdir)
$(builder) generate ./...
$(builder) run $<
install: $(path)/$(exe) $(systemddir)/$(systemd)
$(path)/$(exe): $(instdir)/$(exe) $(instdir)/$(config)
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)/$(config): $(instdir) $(config).sample
cp $(config).sample $(instdir)/$(config)
$(systemddir)/$(systemd): $(systemd)
cp $(systemd) $(systemddir)/$(systemd)
uninstall:
rm -rf $(path)/$(exe)
rm -rf $(instdir)
rm -rf $(systemddir)/$(systemd)
clean:
rm -rf $(builddir)