2022-09-30 14:08:59 +02:00
|
|
|
|
|
|
|
|
# Copyright © 2022 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/>.
|
|
|
|
|
|
|
|
|
|
|
2022-09-28 19:30:08 +02:00
|
|
|
#
|
|
|
|
|
# no need to modify anything below
|
2022-11-03 19:26:57 +01:00
|
|
|
tool = tablizer
|
|
|
|
|
version = $(shell egrep "= .v" cfg/config.go | cut -d'=' -f2 | cut -d'"' -f 2)
|
|
|
|
|
archs = android darwin freebsd linux netbsd openbsd windows
|
|
|
|
|
PREFIX = /usr/local
|
|
|
|
|
UID = root
|
|
|
|
|
GID = 0
|
|
|
|
|
BRANCH = $(shell git branch --show-current)
|
|
|
|
|
COMMIT = $(shell git rev-parse --short=8 HEAD)
|
|
|
|
|
BUILD = $(shell date +%Y.%m.%d.%H%M%S)
|
|
|
|
|
VERSION := $(if $(filter $(BRANCH), development),$(version)-$(BRANCH)-$(COMMIT)-$(BUILD),$(version))
|
|
|
|
|
HAVE_POD := $(shell pod2text -h 2>/dev/null)
|
2022-10-04 15:09:13 +02:00
|
|
|
|
|
|
|
|
all: $(tool).1 cmd/$(tool).go buildlocal
|
2022-09-28 19:30:08 +02:00
|
|
|
|
2022-09-30 19:14:58 +02:00
|
|
|
%.1: %.pod
|
2022-11-03 19:26:57 +01:00
|
|
|
ifdef HAVE_POD
|
2022-09-30 19:14:58 +02:00
|
|
|
pod2man -c "User Commands" -r 1 -s 1 $*.pod > $*.1
|
2022-11-03 19:26:57 +01:00
|
|
|
endif
|
2022-09-29 16:50:36 +02:00
|
|
|
|
2022-10-04 15:09:13 +02:00
|
|
|
cmd/%.go: %.pod
|
2022-11-03 19:26:57 +01:00
|
|
|
ifdef HAVE_POD
|
2022-10-04 15:09:13 +02:00
|
|
|
echo "package cmd" > cmd/$*.go
|
2022-10-14 19:51:19 +02:00
|
|
|
echo >> cmd/$*.go
|
2022-10-04 15:09:13 +02:00
|
|
|
echo "var manpage = \`" >> cmd/$*.go
|
|
|
|
|
pod2text $*.pod >> cmd/$*.go
|
|
|
|
|
echo "\`" >> cmd/$*.go
|
|
|
|
|
|
2022-10-21 10:21:07 +02:00
|
|
|
echo "var usage = \`" >> cmd/$*.go
|
|
|
|
|
awk '/SYNOPS/{f=1;next} /DESCR/{f=0} f' $*.pod | sed 's/^ //' >> cmd/$*.go
|
|
|
|
|
echo "\`" >> cmd/$*.go
|
2022-11-03 19:26:57 +01:00
|
|
|
endif
|
2022-10-21 10:21:07 +02:00
|
|
|
|
2022-09-29 16:50:36 +02:00
|
|
|
buildlocal:
|
2022-10-19 19:32:41 +02:00
|
|
|
go build -ldflags "-X 'github.com/tlinden/tablizer/cfg.VERSION=$(VERSION)'"
|
2022-09-28 19:30:08 +02:00
|
|
|
|
|
|
|
|
release:
|
2022-10-02 15:06:11 +02:00
|
|
|
./mkrel.sh $(tool) $(version)
|
2022-10-11 18:42:10 +02:00
|
|
|
gh release create $(version) --generate-notes releases/*
|
2022-09-29 16:50:36 +02:00
|
|
|
|
|
|
|
|
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/
|
2022-09-29 16:52:03 +02:00
|
|
|
|
|
|
|
|
clean:
|
2022-10-16 15:30:34 +02:00
|
|
|
rm -rf $(tool) releases coverage.out
|
2022-09-30 19:38:54 +02:00
|
|
|
|
|
|
|
|
test:
|
|
|
|
|
go test -v ./...
|
2022-10-16 15:30:34 +02:00
|
|
|
|
2022-10-16 16:37:26 +02:00
|
|
|
singletest:
|
|
|
|
|
@echo "Call like this: ''make singletest TEST=TestPrepareColumns MOD=lib"
|
|
|
|
|
go test -run $(TEST) github.com/tlinden/tablizer/$(MOD)
|
|
|
|
|
|
2022-10-16 15:30:34 +02:00
|
|
|
cover-report:
|
|
|
|
|
go test ./... -cover -coverprofile=coverage.out
|
|
|
|
|
go tool cover -html=coverage.out
|