- if [ -n "$${git_version}" ]; then \
- ##
- ## We remove the leading "v" for the version number
- ##
- git_version="$$(echo "$${git_version}" | sed -r "s/^v([0-9])/\1/")"; \
- ##
- ## If we have a git version, we verify that it isn't the same
- ## as the one currently in the file (if there is one), as we
- ## don't want to update the file if it is already up to date
- ##
- if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
- if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
- ##
- ## If there is already a GIT_VERSION defined,
- ## we just replace it by the new version
- ##
- sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
- else \
- ##
- ## Else, we add a GIT_VERSION define
- ## containing our new version.
- ##
- sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
- fi; \
- fi; \
+ echo $(ECHO_N) "git version: \"$${git_version}\"$(ECHO_C)"; \
+ ##
+ ## We verify that git_version isn't the same as the one
+ ## currently in the file (if there is one), as we don't
+ ## want to update the file if it is already up to date.
+ ##
+ version_match='^#define GIT_VERSION.*'; \
+ old_version=$$($(GREP) "$${version_match}" "$${version_h}"); \
+ new_version="#define GIT_VERSION \"$${git_version}\""; \
+ if [ x"$${old_version}" != x"$${new_version}" ]; then \
+ $(SED) -i "s'$${version_match}'$${new_version}'" "$${version_h}"; \
+ else \
+ echo $(ECHO_N) " (cached)$(ECHO_C)"; \