From 9e18d5d7a9465c987337c19116a33bb5057ace51 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Tue, 13 Jun 2023 23:47:34 +0300 Subject: [PATCH] Add build target to Makefile Add a build target to the Makefile that allows building a non static version if both garm and garm-cli. This is useful when you just need to build the binaries locally and make sure the version is properly set. Signed-off-by: Gabriel Adrian Samfira --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 72fd651b..be922aae 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ USER_ID=$(shell ((docker --version | grep -q podman) && echo "0" || id -u)) USER_GROUP=$(shell ((docker --version | grep -q podman) && echo "0" || id -g)) ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) GOPATH ?= $(shell go env GOPATH) +VERSION ?= $(shell git describe --tags --match='v[0-9]*' --dirty --always) GO ?= go @@ -18,6 +19,13 @@ build-static: docker run --rm -e USER_ID=$(USER_ID) -e USER_GROUP=$(USER_GROUP) -v $(PWD):/build/garm:z $(IMAGE_TAG) /build-static.sh @echo Binaries are available in $(PWD)/bin +build: + @echo Building garm ${VERSION} + $(shell mkdir -p ./bin) + @$(GO) build -ldflags "-s -w -X main.Version=${VERSION}" -tags osusergo,netgo,sqlite_omit_load_extension -o bin/garm ./cmd/garm + @$(GO) build -ldflags "-s -w -X github.com/cloudbase/garm/cmd/garm-cli/cmd.Version=${VERSION}" -tags osusergo,netgo,sqlite_omit_load_extension -o bin/garm-cli ./cmd/garm-cli + @echo Binaries are available in $(PWD)/bin + install: @$(GO) install -tags osusergo,netgo,sqlite_omit_load_extension ./... @echo Binaries available in ${GOPATH}