diff --git a/common/Makefile b/common/Makefile index 6c86b4e1bbcc00f3fe7a9d17d1f96e8c3e676105..c63c195b8ac6bfe5a9818d3ecf402afc190e7d06 100644 --- a/common/Makefile +++ b/common/Makefile @@ -27,24 +27,16 @@ TOP := .. include $(TOP)/Makefile.cfg # Generating git_version.c according to GIT_COMMIT_ID -ifeq ($(GIT_COMMIT_ID), yes) - $(shell echo -e "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"$$(git describe --always --dirty --match 'NOT A TAG')\";" > git_version.c.tmp; \ - if [ ! -f git_version.c.tmp ]; then \ - echo -e "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"\";" > git_version.c.tmp; \ - fi; \ - if diff -q git_version.c.tmp git_version.c >/dev/null 2>&1; then \ - rm git_version.c.tmp; \ - else \ - mv git_version.c.tmp git_version.c; \ - fi) -else - $(shell echo -e "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"\";" > git_version.c.tmp; \ - if diff -q git_version.c.tmp git_version.c >/dev/null 2>&1; then \ - rm git_version.c.tmp; \ - else \ - mv git_version.c.tmp git_version.c; \ - fi) +GIT_HASH=`git describe --always --dirty --match 'NOT A TAG'` +ifeq ($(GIT_COMMIT_ID), no) + GIT_HASH="" endif +$(shell printf "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"${GIT_HASH}\";" > git_version.c.tmp) +$(shell if diff -q git_version.c.tmp git_version.c >/dev/null 2>&1; then \ + rm git_version.c.tmp; \ +else \ + mv git_version.c.tmp git_version.c; \ +fi) TARGETS :=