support compiling outside git checkout

When building nmrpflash for Debian, there is no 'git' command available,
and there is no '.git' directory either. This makes the build emit
warnings from the $(shell) calls in VERSION variable in the Makefile
and breaks the '-V' option.

The change in this patch accounts for missing 'git' command and resorts
to using a STANDALONE_VERSION environment variable which in turn is
provided by the package build mechanics.

This change has no effect when the git command is available and the
'.git' directory is present.
This commit is contained in:
Damyan Ivanov 2020-04-19 06:07:13 +00:00
parent e95526d06c
commit 9f1a6027b4

View file

@ -1,6 +1,6 @@
CC ?= gcc
PREFIX ?= /usr/local
VERSION = $(shell git describe --always | tail -c +2)
VERSION := $(shell if [ -d .git ] && which git 2>&1 > /dev/null; then git describe --always | tail -c +2; else echo $$STANDALONE_VERSION; fi)
LIBS = -lpcap
CFLAGS += -Wall -g -DNMRPFLASH_VERSION=\"$(VERSION)\"
LDFLAGS += $(LIBS)