-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
142 lines (92 loc) · 2.48 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
.POSIX:
PNAME = pgot
RTEMPLATE ?= ../repo-template
all: goUtil docMan
clean: cleanGoUtil cleanCheck
install: installGoUtil installMan
uninstall: uninstallGoUtil uninstallMan
.DEFAULT_GOAL := all
.PHONY: all clean install uninstall
#---Helper Macros to Remove Files---
RMDIR_IF_EMPTY := sh -c '\
if test -d $$0 && ! ls -1qA $$0 | grep -q . ; then \
rmdir $$0; \
fi'
RM ?= rm -f
#---Generate Golang Utility---
PREFIX ?= /usr/local
_INSTDIR = $(DESTDIR)$(PREFIX)
BINDIR ?= $(_INSTDIR)/bin
GO ?= go
GOFLAGS ?=
VERSION != git describe --tags 2> /dev/null
GOSRC != find . -name '*.go'
goUtil: $(PNAME)
$(PNAME): $(GOSRC)
$(GO) build $(GOFLAGS) \
-ldflags "-X main.Version=$(VERSION)" \
-o $@
cleanGoUtil:
$(RM) $(PNAME)
installGoUtil: $(PNAME)
strip $(PNAME)
mkdir -m755 -p $(BINDIR)
install -m755 $(PNAME) $(BINDIR)/$(PNAME)
uninstallGoUtil:
$(RM) $(BINDIR)/$(PNAME)
$(RMDIR_IF_EMPTY) $(BINDIR)
.PHONY: goUtil cleanGoUtil installGoUtil uninstallGoUtil
#---Generate Man Page(s)---
.SUFFIXES:
.SUFFIXES: .1 .5 .1.scd .5.scd
PREFIX ?= /usr/local
_INSTDIR = $(DESTDIR)$(PREFIX)
MANDIR ?= $(_INSTDIR)/share/man
DOCMAN := doc/$(PNAME).1 doc/$(PNAME).5
.1.scd.1:
scdoc < $< > $@
.5.scd.5:
scdoc < $< > $@
docMan: $(DOCMAN)
cleanDocMan:
$(RM) $(DOCMAN)
installMan: $(DOCMAN)
mkdir -m755 -p $(MANDIR)/man1 $(MANDIR)/man5
install -m644 doc/$(PNAME).1 $(MANDIR)/man1/$(PNAME).1
install -m644 doc/$(PNAME).5 $(MANDIR)/man5/$(PNAME).5
uninstallMan:
$(RM) $(MANDIR)/man1/$(PNAME).1
$(RM) $(MANDIR)/man5/$(PNAME).5
$(RMDIR_IF_EMPTY) $(MANDIR)/man1
$(RMDIR_IF_EMPTY) $(MANDIR)/man5
$(RMDIR_IF_EMPTY) $(MANDIR)
.PHONY: docMan cleanDocMan installMan uninstallMan
#---Test/Check Section---
TESTDIR = tests
check: $(PNAME)
cd $(TESTDIR) && go test -v
cleanCheck:
find $(TESTDIR) -name '*.result' -delete
.PHONY: check cleanCheck
#---Generate Main Documents---
regenDocMain:
pgot -i ":$(RTEMPLATE)" -o README.md template/README.md.got
pgot -i ":$(RTEMPLATE)" -o LICENSE $(RTEMPLATE)/LICENSE.src/BSD-2-clause.got
.PHONY: regenDocMain
#---Generate Makefile---
regenMakefile:
pgot -i ":$(RTEMPLATE)" -o Makefile template/Makefile.got
.PHONY: regenMakefile
#---Lint Helper Target---
lint:
@find . -path ./.git -prune -or \
-type f -and -not -name 'Makefile' \
-exec grep -Hn '<no value>' '{}' ';'
.PHONY: lint
#---TODO Helper Target---
todo:
@find . -path ./.git -prune -or \
-type f -and -not -name 'Makefile' \
-exec grep -Hn TODO '{}' ';'
.PHONY: todo
# vim:set noet tw=80: