diff options
-rw-r--r-- | Makefile | 27 | ||||
-rw-r--r-- | sixkcd.go | 3 |
2 files changed, 23 insertions, 7 deletions
@@ -1,24 +1,37 @@ # sixkcd - Fetch XKCD comics from the command line # See LICENSE file for copyright and license details. +COMMIT := $(shell git rev-parse --short HEAD) +VERSION := $(or $(SIXKCD_VERSION),dev-$(COMMIT)) + +SRC := $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' ./...) + +CMD := sixkcd PREFIX=/usr/local MANPREFIX=$(PREFIX)/share/man -all: +sixkcd: $(SRC) go mod download - go build -o sixkcd ./sixkcd.go + go mod verify + go build -ldflags "-X main.version=$(VERSION)" -o $(CMD) ./$(CMD).go install: all mkdir -p $(PREFIX)/bin mkdir -p $(MANPREFIX)/man1 - cp -f sixkcd $(PREFIX)/bin - cp -f sixkcd.1 $(MANPREFIX)/man1 + cp -f $(CMD) $(PREFIX)/bin + cp -f $(CMD).1 $(MANPREFIX)/man1 clean: - rm -f ./sixkcd + rm -f ./$(CMD) uninstall: - rm -f $(PREFIX)/bin/sixkcd - rm -f $(MANPREFIX)/man1/sixkcd.1 + rm -f $(PREFIX)/bin/$(CMD) + rm -f $(MANPREFIX)/man1/$(CMD).1 + +info: + @echo "$(CMD)" + @echo "Version: $(VERSION)" + +all: info sixkcd .PHONY: all install clean uninstall help @@ -21,6 +21,8 @@ const ( target = "info.0.json" ) +var version string + type Comic struct { Month string Num int @@ -39,6 +41,7 @@ func main() { app := &cli.App{ Name: "siXKCD", Usage: "Sixel viewer/fetcher for XKCD Comics", + Version: version, Authors: []*cli.Author{ { Name: "Benjamin Chausse", |