From cf9d1d0b789a45a8d665e4705dd13d727b10b8be Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Sun, 30 Sep 2018 04:15:46 +0200 Subject: [PATCH] Makefile: Specify version when building from tarball When package maintainers build from a tarball, the .git directory does not exist to extract the version tag. Let's add a hack to work around this issue and let them specify `BEES_VERSION="v0.y"` on the make cmdline. Github-Bug: https://github.com/Zygo/bees/issues/75 Signed-off-by: Kai Krakow --- Makefile | 4 +++- src/Makefile | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a97b822..a065a97 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ SYSTEMD_SYSTEM_UNIT_DIR ?= $(shell pkg-config systemd --variable=systemdsystemun MARKDOWN := $(firstword $(shell type -P markdown markdown2 markdown_py 2>/dev/null || echo markdown)) +BEES_VERSION ?= $(shell git describe --always --dirty || echo UNKNOWN) + # allow local configuration to override above variables -include localconf @@ -36,7 +38,7 @@ lib: ## Build libs src: ## Build bins src: lib - $(MAKE) -C src + $(MAKE) BEES_VERSION="$(BEES_VERSION)" -C src test: ## Run tests test: lib src diff --git a/src/Makefile b/src/Makefile index a820b6a..fd65a10 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,7 @@ BEES_OBJS = \ bees-types.o \ bees-version.c: bees.h $(BEES_OBJS:.o=.cc) Makefile - echo "const char *BEES_VERSION = \"$(shell git describe --always --dirty || echo UNKNOWN)\";" > bees-version.new.c + echo "const char *BEES_VERSION = \"$(BEES_VERSION)\";" > bees-version.new.c mv -f bees-version.new.c bees-version.c .depends/%.dep: %.cc Makefile