2023-10-30 19:13:24 +01:00
|
|
|
|
|
|
|
|
# Copyright © 2023 Thomas von Dein
|
|
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# no need to modify anything below
|
|
|
|
|
tool = rpn
|
|
|
|
|
VERSION = $(shell grep VERSION main.go | head -1 | cut -d '"' -f2)
|
|
|
|
|
archs = darwin freebsd linux windows
|
|
|
|
|
PREFIX = /usr/local
|
|
|
|
|
UID = root
|
|
|
|
|
GID = 0
|
2023-11-02 10:11:39 +01:00
|
|
|
HAVE_POD := $(shell pod2text -h 2>/dev/null)
|
|
|
|
|
|
|
|
|
|
all: $(tool).1 $(tool).go buildlocal
|
|
|
|
|
|
|
|
|
|
%.1: %.pod
|
|
|
|
|
ifdef HAVE_POD
|
|
|
|
|
pod2man -c "User Commands" -r 1 -s 1 $*.pod > $*.1
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
%.go: %.pod
|
|
|
|
|
ifdef HAVE_POD
|
|
|
|
|
echo "package main" > $*.go
|
|
|
|
|
echo >> $*.go
|
|
|
|
|
echo "var manpage = \`" >> $*.go
|
|
|
|
|
pod2text $*.pod >> $*.go
|
|
|
|
|
echo "\`" >> $*.go
|
|
|
|
|
endif
|
2023-10-30 19:13:24 +01:00
|
|
|
|
|
|
|
|
buildlocal:
|
|
|
|
|
CGO_LDFLAGS='-static' go build -tags osusergo,netgo -ldflags "-extldflags=-static" -o $(tool)
|
|
|
|
|
|
|
|
|
|
install: buildlocal
|
|
|
|
|
install -d -o $(UID) -g $(GID) $(PREFIX)/bin
|
|
|
|
|
install -d -o $(UID) -g $(GID) $(PREFIX)/man/man1
|
|
|
|
|
install -o $(UID) -g $(GID) -m 555 $(tool) $(PREFIX)/sbin/
|
|
|
|
|
install -o $(UID) -g $(GID) -m 444 $(tool).1 $(PREFIX)/man/man1/
|
|
|
|
|
|
|
|
|
|
clean:
|
2023-12-08 18:37:59 +01:00
|
|
|
rm -rf $(tool) coverage.out testdata
|
2023-10-30 19:13:24 +01:00
|
|
|
|
2023-12-08 18:37:59 +01:00
|
|
|
test: clean
|
|
|
|
|
go test ./... $(ARGS)
|
|
|
|
|
|
|
|
|
|
testfuzzy: clean
|
|
|
|
|
go test -fuzz ./... $(ARGS)
|
2023-10-30 19:13:24 +01:00
|
|
|
|
2024-01-26 13:08:15 +01:00
|
|
|
testlint: test lint
|
|
|
|
|
|
|
|
|
|
lint:
|
|
|
|
|
golangci-lint run
|
|
|
|
|
|
|
|
|
|
lint-full:
|
|
|
|
|
golangci-lint run --enable-all --exclude-use-default --disable exhaustivestruct,exhaustruct,depguard,interfacer,deadcode,golint,structcheck,scopelint,varcheck,ifshort,maligned,nosnakecase,godot,funlen,gofumpt,cyclop,noctx,gochecknoglobals,paralleltest,forbidigo,godox,dupword,forcetypeassert,goerr113,gomnd
|
|
|
|
|
|
2023-10-30 19:13:24 +01:00
|
|
|
singletest:
|
2023-12-07 14:09:42 +01:00
|
|
|
@echo "Call like this: make singletest TEST=TestPrepareColumns ARGS=-v"
|
|
|
|
|
go test -run $(TEST) $(ARGS)
|
2023-10-30 19:13:24 +01:00
|
|
|
|
|
|
|
|
cover-report:
|
|
|
|
|
go test ./... -cover -coverprofile=coverage.out
|
|
|
|
|
go tool cover -html=coverage.out
|
|
|
|
|
|
|
|
|
|
goupdate:
|
|
|
|
|
go get -t -u=patch ./...
|
2023-11-01 17:55:22 +01:00
|
|
|
|
|
|
|
|
buildall:
|
|
|
|
|
./mkrel.sh $(tool) $(VERSION)
|
|
|
|
|
|
|
|
|
|
release: buildall
|
2023-11-02 19:36:42 +01:00
|
|
|
gh release create v$(VERSION) --generate-notes releases/*
|
2023-11-06 16:09:56 +01:00
|
|
|
|
|
|
|
|
show-versions: buildlocal
|
|
|
|
|
@echo "### rpn version:"
|
|
|
|
|
@./rpn -v
|
|
|
|
|
|
|
|
|
|
@echo
|
|
|
|
|
@echo "### go module versions:"
|
|
|
|
|
@go list -m all
|
|
|
|
|
|
|
|
|
|
@echo
|
|
|
|
|
@echo "### go version used for building:"
|
|
|
|
|
@grep -m 1 go go.mod
|