aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-06 15:11:13 +0700
committerShulhan <ms@kilabit.info>2022-08-06 15:11:13 +0700
commitcbcd1d10d415036d8bd00c709014cc5272340b1a (patch)
tree3b3595b837bda1e64e5ff386cfe3721860779c1d /Makefile
parent422e3b1cfb590e3c22023916bc5ad7d2ae7e3652 (diff)
downloadciigo-cbcd1d10d415036d8bd00c709014cc5272340b1a.tar.xz
all: set the Version automatically set during build
This require that the command build or install using "make build/install".
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 7 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 14a4c4d..9054629 100644
--- a/Makefile
+++ b/Makefile
@@ -2,25 +2,26 @@
## SPDX-License-Identifier: GPL-3.0-or-later
.PHONY: all lint test install build
-.FORCE:
-DIR_BUILD=_bin
+VERSION:=$(shell git describe --tags)
+LDFLAGS:=-ldflags "-s -w -X 'git.sr.ht/~shulhan/ciigo.Version=$(VERSION)'"
+DIR_BUILD:=_bin
all: test lint build
lint:
- golangci-lint run ./...
+ -golangci-lint run ./...
test:
go run ./cmd/ciigo-example embed
CGO_ENABLED=1 go test -v -race ./...
-install:
- go install ./cmd/ciigo
+install: build
+ mv _bin/ciigo $(GOBIN)
run-example:
DEBUG=1 go run ./cmd/ciigo-example
build:
mkdir -p $(DIR_BUILD)
- CGO_ENABLED=0 go build -o $(DIR_BUILD) ./cmd/...
+ CGO_ENABLED=0 go build $(LDFLAGS) -o $(DIR_BUILD) ./cmd/...