-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (60 loc) · 1.55 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
# Referenced from aerc's makefile
.POSIX:
.SUFFIXES:
.SUFFIXES: .1 .1.scd
TAG != git describe --abbrev=0 --tags
REVISION != git rev-parse --short HEAD
VERSION = $(TAG)-$(REVISION)
PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
MANDIR?=$(PREFIX)/share/man
GO?=go
GOFLAGS?=
LDFLAGS:=-X main.Prefix=$(PREFIX)
LDFLAGS+=-X main.Version=$(VERSION)
GOSRC:=$(shell find * -name '*.go')
GOSRC+=go.mod go.sum
DOCS := gelim.1
.PHONY: all
all: gelim $(DOCS)
gelim: fmt $(GOSRC)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@
.PHONY: fmt
fmt:
gofmt -w .
.PHONY: checkfmt
checkfmt:
@if [ `gofmt -l . | wc -l` -ne 0 ]; then \
gofmt -d .; \
echo "ERROR: source files need reformatting with gofmt"; \
exit 1; \
fi
.1.scd.1:
scdoc < $< > $@
# Exists in GNUMake but not in NetBSD make and others.
RM?=rm -f
.PHONY: clean
clean:
$(RM) $(DOCS) gelim
.PHONY: install
install: gelim
mkdir -m755 -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
install -m755 gelim $(DESTDIR)$(BINDIR)/gelim
install -m644 gelim.1 $(DESTDIR)$(MANDIR)/man1/gelim.1
.PHONY: checkinstall
checkinstall:
$(DESTDIR)$(BINDIR)/gelim --version
test -e $(DESTDIR)$(MANDIR)/man1/gelim.1
@echo OK
RMDIR_IF_EMPTY:=sh -c '! [ -d $$0 ] || ls -1qA $$0 | grep -q . || rmdir $$0'
.PHONY: uninstall
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/gelim
$(RM) $(DESTDIR)$(MANDIR)/man1/gelim.1
$(RM) -r $(DESTDIR)$(SHAREDIR)
${RMDIR_IF_EMPTY} $(DESTDIR)$(BINDIR)
$(RMDIR_IF_EMPTY) $(DESTDIR)$(MANDIR)/man1
$(RMDIR_IF_EMPTY) $(DESTDIR)$(MANDIR)
.PHONY: release
release:
goreleaser release --skip validate --clean