-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
58 lines (49 loc) · 1.41 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
GITV != git describe --tags
GITC != git rev-parse --verify HEAD
SRC != find . -type f -name '*.go' ! -name '*_test.go'
TEST != find . -type f -name '*_test.go'
DATEC != date +'%B %d, %Y'
PREFIX ?= /usr/local
VERSION ?= $(GITV)
COMMIT ?= $(GITC)
BUILDER ?= Makefile
DATE ?= $(DATEC)
GO := go
INSTALL := install
RM := rm
SED := sed
PANDOC := pandoc
GZIP := gzip
MANDB := mandb
CP := cp
didder: go.mod go.sum $(SRC)
GO111MODULE=on CGO_ENABLED=0 $(GO) build -o $@ -ldflags="-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.builtBy=$(BUILDER)"
.PHONY: clean
clean:
$(RM) -f didder
.PHONY: man
man:
$(PANDOC) didder.1.md -s -t man -o didder.1
$(SED) -i 's/VERSION/$(VERSION)/g' didder.1
$(SED) -i 's/DATE/$(DATE)/g' didder.1
$(CP) didder.1.md MANPAGE.md
$(SED) -i 's/VERSION/$(VERSION)/g' MANPAGE.md
$(SED) -i 's/DATE/$(DATE)/g' MANPAGE.md
$(SED) -i '1s/^/<!-- DO NOT EDIT, AUTOMATICALLY GENERATED, EDIT dither.1.md INSTEAD -->\n/' MANPAGE.md
$(SED) -i 's/: /\n/g' MANPAGE.md
$(SED) -i 's/ //g' MANPAGE.md
$(SED) -i 's/^\[/ \[/g' MANPAGE.md
$(SED) -i 's/\\$$//g' MANPAGE.md
.PHONY: install
install: didder
$(INSTALL) -d $(PREFIX)/bin/
$(INSTALL) -m 755 didder $(PREFIX)/bin/didder
$(GZIP) -c didder.1 > /usr/share/man/man1/didder.1.gz
$(MANDB)
.PHONY: uninstall
uninstall:
$(RM) -f $(PREFIX)/bin/didder
# Development helpers
.PHONY: fmt
fmt:
$(GO) fmt ./...