app: Include git commit hash in verbose version output

Note:
* Passes make distcheck
* The git commit hash is shipped with tarballs
* Build handles if git-version.h is removed from a tarball
This commit is contained in:
Martin Nordholts 2010-01-30 08:10:41 +01:00
parent 22864d1b88
commit d1202096e6
3 changed files with 34 additions and 5 deletions

9
app/.gitignore vendored
View File

@ -1,9 +1,10 @@
/Makefile
/Makefile.in
/makefile.mingw
/.deps
/.libs
/Makefile
/Makefile.in
/gimp-2.*
/gimp-console-2.*
/libapp.a
/gimp.rc
/git-version.h
/libapp.a
/makefile.mingw

View File

@ -70,7 +70,12 @@ libapp_sources = \
gimp-log.h \
gimp-intl.h
libapp_a_SOURCES = $(libapp_sources)
libapp_generated_sources = \
git-version.h
$(srcdir)/version.c: git-version.h
libapp_a_SOURCES = $(libapp_sources) $(libapp_generated_sources)
gimp_2_7_SOURCES = $(libapp_sources) main.c
@ -264,3 +269,22 @@ gimp-console.rc.o: gimp.rc
$(WINDRES) --define ORIGINALFILENAME_STR="gimp-console-2.7$(EXEEXT)" \
--define INTERNALNAME_STR="gimp-console-2.7" \
gimp.rc gimp-console.rc.o
# If git is available, always check if git-version.h should be
# updated. If git is not avaialbe, 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 -d "$(top_srcdir)/.git"; then \
echo "#define GIMP_GIT_VERSION \"`git log HEAD^..HEAD --pretty=format:%H`\"" > "$@.tmp"; \
elif test ! -f "$@"; then \
echo "#define GIMP_GIT_VERSION \"Unknown, shouldn't happen\"" > "$@.tmp"; \
fi
@if ( test -f "$@" && cmp "$@.tmp" "$@" > /dev/null); then \
rm -f "$@.tmp"; \
elif test -f "$@.tmp"; then \
mv "$@.tmp" "$@"; \
echo " git HEAD changed: git-version.h regenerated"; \
fi
.PHONY: update-git-version-header

View File

@ -34,6 +34,7 @@
#include "about.h"
#include "version.h"
#include "git-version.h"
#include "gimp-intl.h"
@ -128,6 +129,9 @@ gimp_version_show (gboolean be_verbose)
if (be_verbose)
{
g_print (_("git commit %s"), GIMP_GIT_VERSION);
g_print ("\n");
g_print ("\n");
gimp_show_library_versions ();
}