-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
60 lines (49 loc) · 1.34 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
GO = go
PREFIX = /usr/local
CFGPREFIX = /etc
EXE = dischord
all:
$(GO) build -o $(EXE) cmd/$(EXE)/*.go
debug:
$(GO) build -o $(EXE) -gcflags=all="-N -l" cmd/$(EXE)/*.go
dlv exec ./dischord
fmt:
find . -type f -name '*.go' -exec gofmt -w '{}' ';'
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f $(EXE) $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/$(EXE)
mkdir -p $(DESTDIR)$(CFGPREFIX)/$(EXE)
@if command -v systemd; then \
$(MAKE) install-systemd; \
else \
@echo "Systemd not found, if you want to add $(DESTDIR)$(PREFIX)/bin/$(EXE) as a service, please do so manually."; \
fi
install-systemd:
mkdir -p $(DESTDIR)$(CFGPREFIX)/systemd/system
echo \
[Unit] \
Description=$(EXE) \
Requires=network-online.target \
After=network-online.target \
[Service] \
Type=simple \
ExecStart=$(PREFIX)/bin/$(EXE) \
WorkingDirectory=$(CFGPREFIX)/$(EXE) \
Restart=on-failure \
[Install] \
WantedBy=multi-user.target \
| sed 's/ /\n/g' > $(DESTDIR)$(CFGPREFIX)/systemd/system/$(EXE).service
uninstall:
@if command -v systemd; then \
systemctl stop $(EXE); \
systemctl disable $(EXE); \
fi
rm -f $(DESTDIR)$(PREFIX)/bin/$(EXE)
rm -f $(DESTDIR)$(CFGPREFIX)/systemd/system/$(EXE).service
test:
$(GO) test -count=1 -v git.nobrain.org/r4/dischord/extractor/
.PHONY: all debug fmt install uninstall clean
clean:
rm -f $(EXE)
rm -rf build/