summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile27
-rw-r--r--sixkcd.go3
2 files changed, 23 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index ff38c26..8c1db33 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/sixkcd.go b/sixkcd.go
index b9c13d7..9fdfdc9 100644
--- a/sixkcd.go
+++ b/sixkcd.go
@@ -22,6 +22,8 @@ const (
target = "info.0.json"
)
+var version string
+
type Comic struct {
Month string
Num int
@@ -40,6 +42,7 @@ func main() {
app := &cli.App{
Name: "siXKCD",
Usage: "Sixel viewer/fetcher for XKCD Comics",
+ Version: version,
Authors: []*cli.Author{
{
Name: "Benjamin Chausse",