~chrisppy/beagles

ref: 90f8d4d830d6b9302c060c14e41794e8bbe8527f beagles/Makefile -rw-r--r-- 1.7 KiB
90f8d4d8Chris Palmer Fix seg fault when list is empty on mark read 1 year, 6 months 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
.POSIX:
.SUFFIXES:

PKGNAME=beagles

VERSION=0.1.0

PREFIX?=/usr/local
_INSTDIR=$(DESTDIR)$(PREFIX)
BINDIR=$(_INSTDIR)/bin
SHAREDIR?=$(HOME)/.local/share
CONFIGDIR?=$(HOME)/.config
CACHEDIR?=$(HOME)/.cache
GO?=go
GOFLAGS?=

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

beagles: $(GOSRC)
	mkdir -m755 -p $(SHAREDIR)/$(PKGNAME) $(CONFIGDIR)/$(PKGNAME) \
		$(CACHEDIR)/$(PKGNAME)
	$(GO) build $(GOFLAGS) \
		-ldflags "-X main.Version=$(VERSION)/$(PKGNAME) \
		-X main.ShareDir=$(SHAREDIR)/$(PKGNAME) \
		-X main.ConfigDir=$(CONFIGDIR)/$(PKGNAME) \
		-X main.CacheDir=$(CACHEDIR)/$(PKGNAME)" \
		-o $@

all: beagles 

# 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)
	install -m755 $(PKGNAME) $(BINDIR)/$(PKGNAME)

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

uninstall:
	$(RM) $(BINDIR)/$(PKGNAME)
	$(RMDIR_IF_EMPTY) $(BINDIR)

check:
	$(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) fmt -x ./...
	$(GO) vet ./...
	golint -set_exit_status `go list ./... | grep -v vendor`
	gosec -exclude=G204 ./...
	staticcheck ./...
	aligncheck ./...
	$(GO) test -cover ./...

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

.DEFAULT_GOAL := all

.PHONY: all clean install uninstall check package