Fix compatibility with dash as /bin/sh.
Ubuntu's default /bin/sh is dash, which does not support the `&>` redirection syntax. This commit moves version.h generation back into the Makefile, as8afaedd
had it, but restores compatibility with GNU Make < 4.0, which8afaedd
, broke. This also fixes building on macOS, as macOS bundles GNU Make 3.81.
This commit is contained in:
parent
7180a5b9a2
commit
db4b568e52
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if ! command -v git &>/dev/null; then
|
|
||||||
echo "Git not found, assuming up to date include/version.h"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! git rev-parse HEAD &>/dev/null; then
|
|
||||||
echo "No git repository found, not updating include/version.h"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
version=`git describe --always --dirty --tags`
|
|
||||||
header="#define FIRMWARE_VERSION \"$version\""
|
|
||||||
|
|
||||||
if [ "`cat include/version.h 2>/dev/null`" != "$header" ]; then
|
|
||||||
echo $header > include/version.h
|
|
||||||
fi
|
|
17
src/Makefile
17
src/Makefile
|
@ -174,8 +174,21 @@ all_platforms:
|
||||||
|
|
||||||
command.c: include/version.h
|
command.c: include/version.h
|
||||||
|
|
||||||
|
GIT_VERSION := $(shell git describe --always --dirty --tags)
|
||||||
|
VERSION_HEADER := \#define FIRMWARE_VERSION "$(GIT_VERSION)"
|
||||||
|
|
||||||
include/version.h: FORCE
|
include/version.h: FORCE
|
||||||
@echo " GEN $@"
|
@# If git isn't found then GIT_VERSION will be an empty string.
|
||||||
$(Q)../scripts/gen-version.sh
|
ifeq ($(GIT_VERSION),)
|
||||||
|
@echo Git not found, assuming up to date include/version.h
|
||||||
|
else
|
||||||
|
@# Note that when we echo the version to the header file, echo writes a final newline
|
||||||
|
@# to the file. This is fine and probably makes the file more human-readable, but
|
||||||
|
@# also means we have to account for that newline in this comparison.
|
||||||
|
$(Q)if [ ! -f $@ ] || [ "$$(cat $@)" != "$$(echo '$(VERSION_HEADER)\n')" ]; then \
|
||||||
|
echo " GEN $@"; \
|
||||||
|
echo '$(VERSION_HEADER)' > $@; \
|
||||||
|
fi
|
||||||
|
endif
|
||||||
|
|
||||||
-include *.d
|
-include *.d
|
||||||
|
|
Loading…
Reference in New Issue