~chrisppy/beagles

ref: c14a6fce4bc432220f07e9044e18e72905a90b6a beagles/Makefile -rw-r--r-- 2.5 KiB
c14a6fceChris Palmer Updates for 0.2.0 release 1 year, 1 month ago
                                                                                
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
.POSIX:
.SUFFIXES:
.SUFFIXES: .1 .5 .1.scd .5.scd

PKGNAME=beagles

VERSION=0.2.0

VPATH=doc
PREFIX?=/usr/local
_INSTDIR=$(DESTDIR)$(PREFIX)
BINDIR=$(_INSTDIR)/bin
MANDIR?=$(_INSTDIR)/share/man
GO?=go
GOFLAGS?=

GOSRC!=find . -name '*.go'
GOSRC+=go.mod go.sum

beagles: $(GOSRC)
	$(GO) build $(GOFLAGS) \
		-ldflags "-X main.Version=$(VERSION)" \
		-o $@

DOCS := \
	$(PKGNAME).1 \
	$(PKGNAME)-config.5

.1.scd.1:
	scdoc < $< > $@

.5.scd.5:
	scdoc < $< > $@

doc: $(DOCS)

all: beagles doc

# Exists in GNUMake but not in NetBSD make and others.
RM?=rm -f

clean:
	$(GO) mod tidy
	$(RM) $(DOCS) $(PKGNAME) *.tar.gz
	$(RM) -r vendor

install: all
	mkdir -m755 -p $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man5
	install -m755 $(PKGNAME) $(BINDIR)/$(PKGNAME)
	install -m644 $(PKGNAME).1 $(MANDIR)/man1/$(PKGNAME).1
	install -m644 $(PKGNAME)-config.5 $(MANDIR)/man5/$(PKGNAME)-config.5

RMDIR_IF_EMPTY:=sh -c '\
if test -d $$0 && ! ls -1qA $$0 | grep -q . ; then \
	rmdir $$0; \
fi'

uninstall:
	$(RM) $(BINDIR)/$(PKGNAME)
	$(RM) $(MANDIR)/man1/$(PKGNAME).1
	$(RM) $(MANDIR)/man5/$(PKGNAME)-config.5
	$(RMDIR_IF_EMPTY) $(BINDIR)
	$(RMDIR_IF_EMPTY) $(MANDIR)/man1
	$(RMDIR_IF_EMPTY) $(MANDIR)/man5
	$(RMDIR_IF_EMPTY) $(MANDIR)

check: clean 
	$(GO) get -u golang.org/x/lint/golint
	$(GO) get -u github.com/securego/gosec/cmd/gosec
	$(GO) get -u honnef.co/go/tools/cmd/staticcheck
	$(GO) get -u gitlab.com/opennota/check/cmd/aligncheck
	$(GO) get -u gitlab.com/opennota/check/cmd/structcheck
	$(GO) get -u gitlab.com/opennota/check/cmd/varcheck
	$(GO) get -u github.com/kisielk/errcheck
	$(GO) get -u github.com/psampaz/go-mod-outdated
	$(GO) fmt -x `$(GO) list ./... | grep -v fmsg`
	$(GO) vet `$(GO) list ./... | grep -v fmsg`
	golint -set_exit_status `$(GO) list ./... | grep -v fmsg`
	staticcheck `$(GO) list ./... | grep -v fmsg`
	aligncheck `$(GO) list ./... | grep -v fmsg`
	structcheck `$(GO) list ./... | grep -v fmsg`
	varcheck `$(GO) list ./... | grep -v fmsg`
	errcheck `$(GO) list ./... | grep -v fmsg`
	gosec -exclude=G107,G204 -exclude-dir=fmsg ./... 
	$(GO) list -u -m -json all | go-mod-outdated -direct -ci
	$(GO) test -cover `$(GO) list ./... | grep -v vendor | grep -v fmsg`
	make clean

package: check
	$(GO) mod vendor
	tar --exclude='.git' \
		--exclude='*.tar.gz' \
		--exclude='mkrelease.sh' \
	       	--exclude='examples' \
	       	--exclude="tags" \
	       	--exclude=".vscode" \
		--exclude=".build.yml" \
		--exclude=".gitignore" \
		--exclude="*~" \
		-zcvf $(PKGNAME)-v$(VERSION).tar.gz ../$(PKGNAME)

.DEFAULT_GOAL := all

.PHONY: all doc clean install uninstall check package