Commit 44f23bdf authored by Jehan's avatar Jehan

app: move git-version.h generation to the repository root.

The reason is that this file is now included for a binary in tools/ as
well (the debug binary) and tools/ contents needs to be built before
app/. Even using BUILT_SOURCES in the Makefile under app/ is not enough.
Anyway it makes sense that this file should be under the root of the
repository since that describes the status of the source repository. So
let's move it up one folder.
parent 6fc05e36
......@@ -124,3 +124,44 @@ $(srcdir)/ChangeLog:
echo A git checkout and git-log is required to generate this file >> $@); \
fi
.PHONY: $(srcdir)/ChangeLog
libapp_generated_sources = \
git-version.h
# Build git-version.h before anything in the subdirs as this is needed
# in the about and debug dialog (app/) and in the debug tool (tools/).
BUILT_SOURCES = $(libapp_generated_sources)
CLEANFILES = $(libapp_generated_sources)
# If git is available, always check if git-version.h should be
# updated. If git is not available, don't do anything if git-version.h
# already exists because then we are probably working with a tarball
# in which case the git-version.h we ship is correct.
git-version.h: update-git-version-header
@if test -e "$(top_srcdir)/.git"; then \
git_version="`git --git-dir=$(top_srcdir)/.git describe --always`"; \
git_version_abbrev="`git --git-dir=$(top_srcdir)/.git rev-parse --short HEAD`"; \
git_last_commit_year="`git --git-dir=$(top_srcdir)/.git log -n1 --reverse --pretty=%ci | cut -b 1-4`"; \
elif test ! -f "$@"; then \
git_version="Unknown, shouldn't happen"; \
git_version_abbrev="$$git_version"; \
git_last_commit_timestamp=-1; \
git_last_commit_year="`date -u '+%Y'`"; \
fi; \
if test -n "$$git_version"; then \
echo "#ifndef __GIT_VERSION_H__" > "$@.tmp"; \
echo "#define __GIT_VERSION_H__" >> "$@.tmp"; \
echo "#define GIMP_GIT_VERSION \"$$git_version\"" >> "$@.tmp"; \
echo "#define GIMP_GIT_VERSION_ABBREV \"$$git_version_abbrev\"" >> "$@.tmp"; \
echo "#define GIMP_GIT_LAST_COMMIT_YEAR \"$$git_last_commit_year\"" >> "$@.tmp"; \
echo "#endif /* __GIT_VERSION_H__ */" >> "$@.tmp"; \
fi
@if ( test -f "$@.tmp" && test -f "$@" && cmp "$@.tmp" "$@" > /dev/null ); then \
rm -f "$@.tmp"; \
elif test -f "$@.tmp"; then \
mv "$@.tmp" "$@"; \
echo " git HEAD changed: $@ regenerated"; \
fi
.PHONY: update-git-version-header
......@@ -69,18 +69,7 @@ libapp_sources = \
gimp-version.c \
gimp-version.h
libapp_generated_sources = \
git-version.h
# Build git-version.h before anything in the subdirs as this is needed
# in the about dialog.
BUILT_SOURCES = $(libapp_generated_sources)
CLEANFILES = $(libapp_generated_sources)
$(srcdir)/version.c: git-version.h
libapp_a_SOURCES = $(libapp_sources) $(libapp_generated_sources)
libapp_a_SOURCES = $(libapp_sources)
gimp_@GIMP_APP_VERSION@_SOURCES = $(libapp_sources) main.c
......@@ -268,35 +257,3 @@ dist-dump-gimprc: gimp-console-$(GIMP_APP_VERSION)$(EXEEXT)
&& rm gimprc.tmp gimprc.tmp2
dist-hook: dist-check-gimp-console dist-dump-gimprc
# If git is available, always check if git-version.h should be
# updated. If git is not available, don't do anything if git-version.h
# already exists because then we are probably working with a tarball
# in which case the git-version.h we ship is correct.
git-version.h: update-git-version-header
@if test -e "$(top_srcdir)/.git"; then \
git_version="`git --git-dir=$(top_srcdir)/.git describe --always`"; \
git_version_abbrev="`git --git-dir=$(top_srcdir)/.git rev-parse --short HEAD`"; \
git_last_commit_year="`git --git-dir=$(top_srcdir)/.git log -n1 --reverse --pretty=%ci | cut -b 1-4`"; \
elif test ! -f "$@"; then \
git_version="Unknown, shouldn't happen"; \
git_version_abbrev="$$git_version"; \
git_last_commit_timestamp=-1; \
git_last_commit_year="`date -u '+%Y'`"; \
fi; \
if test -n "$$git_version"; then \
echo "#ifndef __GIT_VERSION_H__" > "$@.tmp"; \
echo "#define __GIT_VERSION_H__" >> "$@.tmp"; \
echo "#define GIMP_GIT_VERSION \"$$git_version\"" >> "$@.tmp"; \
echo "#define GIMP_GIT_VERSION_ABBREV \"$$git_version_abbrev\"" >> "$@.tmp"; \
echo "#define GIMP_GIT_LAST_COMMIT_YEAR \"$$git_last_commit_year\"" >> "$@.tmp"; \
echo "#endif /* __GIT_VERSION_H__ */" >> "$@.tmp"; \
fi
@if ( test -f "$@.tmp" && test -f "$@" && cmp "$@.tmp" "$@" > /dev/null ); then \
rm -f "$@.tmp"; \
elif test -f "$@.tmp"; then \
mv "$@.tmp" "$@"; \
echo " git HEAD changed: $@ regenerated"; \
fi
.PHONY: update-git-version-header
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment