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
|
# based off of the Makefile for aerc:
# https://git.sr.ht/~rjarry/aerc/tree/master/item/Makefile
.POSIX:
.SUFFIXES:
.SUFFIXES: .1 .1.scd .5 .5.scd
VERSION?=`git describe --tags --dirty 2>/dev/null || echo 0.0.0`
VPATH=doc
PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
SHAREDIR?=$(PREFIX)/share
SYSCONFDIR?=/etc
MANDIR?=$(PREFIX)/share/man
GO?=go
GOFLAGS?=
LDFLAGS+=-X main.Version=$(VERSION) -s -w
RM?=rm -f
GOSRC!=find * -name '*.go'
GOSRC+=go.mod go.sum
DOCS := \
gnss-share.1 \
gnss-share.conf.5
all: gnss-share $(DOCS)
gnss-share: $(GOSRC)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o gnss-share ./cmd/gnss-share
.PHONY: fmt
fmt:
gofmt -w .
# NOTE: most of the skipped staticcheck tests are from the default, SA1019
# skips the ioutil deprecation warning since some distros (Debian) are only on
# Go 1.15, which was before some ioutil functionality was moved into other
# modules (e.g. os.)
# See: https://staticcheck.io/docs/configuration
test:
@if [ `gofmt -l . | wc -l` -ne 0 ]; then \
gofmt -d .; \
echo "ERROR: source files need reformatting with gofmt"; \
exit 1; \
fi
@staticcheck -checks all,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022,-ST1023,-SA1019 ./...
@go test -race -count=1 ./...
.1.scd.1:
scdoc < $< > $@
.5.scd.5:
scdoc < $< > $@
doc: $(DOCS)
clean:
$(RM) $(DOCS) gnss-share
install: gnss-share $(DOCS)
mkdir -m755 -p $(DESTDIR)$(BINDIR)
install -m755 gnss-share $(DESTDIR)$(BINDIR)/
mkdir -m755 -p $(DESTDIR)$(SYSCONFDIR)
install -m644 gnss-share.conf $(DESTDIR)$(BINDIR)/
install -Dm644 gnss-share.1 -t $(DESTDIR)$(MANDIR)/man1/
install -Dm644 gnss-share.conf.5 -t $(DESTDIR)$(MANDIR)/man5/
.PHONY: checkinstall
checkinstall:
test -e $(DESTDIR)$(BINDIR)/gnss-share
test -e $(DESTDIR)$(BINDIR)/gnss-share.conf
test -e $(DESTDIR)$(MANDIR)/man1/gnss-share.1
test -e $(DESTDIR)$(MANDIR)/man5/gnss-share.conf.5
RMDIR_IF_EMPTY:=sh -c '! [ -d $$0 ] || ls -1qA $$0 | grep -q . || rmdir $$0'
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/gnss-share
$(RM) $(DESTDIR)$(BINDIR)/gnss-share.conf
$(RM) $(DESTDIR)$(MANDIR)/man1/gnss-share.1
$(RM) $(DESTDIR)$(MANDIR)/man5/gnss-share.conf.5
.PHONY: all doc clean install uninstall test
|