diff options
author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-06-21 15:54:52 +0200 |
---|---|---|
committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-07-19 01:13:31 +0200 |
commit | bd8a638e9caa2fa508f8865d9532c821f81fa909 (patch) | |
tree | 0ecc9aba522c50ae5f4f9e2c00c969d3f67daaae /build-helpers/package-version.mk | |
parent | afcce7e37a5308198cd524f5b1e83f03eb580158 (diff) | |
download | ndim-git-utils-bd8a638e9caa2fa508f8865d9532c821f81fa909.tar.gz ndim-git-utils-bd8a638e9caa2fa508f8865d9532c821f81fa909.tar.xz ndim-git-utils-bd8a638e9caa2fa508f8865d9532c821f81fa909.zip |
Generate version information from git info
Diffstat (limited to 'build-helpers/package-version.mk')
-rw-r--r-- | build-helpers/package-version.mk | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/build-helpers/package-version.mk b/build-helpers/package-version.mk new file mode 100644 index 0000000..126628e --- /dev/null +++ b/build-helpers/package-version.mk @@ -0,0 +1,52 @@ +BUILD_SCRIPT_DIR = build-helpers + +# Check that package version matches git version before creating dist tarballs +dist-hook: git-version-check git-version-stamp +distcheck-hook: git-version-check + +# Note: We cannot run autogen.sh from here, because we would need some way to +# restart the whole dist process from the start and there is none. +# FIXME: NEWS check uses ${foo%%-*} POSIX shell, tested +# with bash, dash, busybox. +EXTRA_DIST += $(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version +git-version-check: + @git_ver=`$(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version $(top_srcdir) version-stamp`; \ + if test "x$${git_ver}" = "x$(PACKAGE_VERSION)"; then :; else \ + echo "ERROR: PACKAGE_VERSION and 'git describe' version do not match:"; \ + echo " current 'git describe' version: $${git_ver}"; \ + echo " current PACKAGE_VERSION: $(PACKAGE_VERSION)"; \ + rm -rf "$(top_srcdir)/autom4te.cache"; \ + if test -f "$(top_srcdir)/autogen.sh"; then \ + echo "Update PACKAGE_VERSION by running $(top_srcdir)/autogen.sh."; \ + else \ + echo "Update PACKAGE_VERSION by running autoreconf(1)."; \ + fi; \ + exit 1; \ + fi; \ + case `sed 15q $(top_srcdir)/NEWS` in \ + *"$${git_ver%%-*}"*) : ;; \ + *) \ + echo "NEWS not updated for version $${git_ver%%-*}; not releasing" 1>&2; \ + exit 1;; \ + esac + +# Version stamp files can only exist in tarball source trees. +# +# So there is no need to generate them anywhere else or to clean them +# up anywhere. +git-version-stamp: + echo "$(PACKAGE_VERSION)" > "$(distdir)/version-stamp" + +# Update *.h file to contain up-to-date version number +A_V = package-version-internal +CLEANFILES += $(A_V).h +BUILT_SOURCES += $(A_V).h.stamp +$(A_V).h.stamp: + @current_ver=`$(SHELL) $(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version $(top_srcdir) version-stamp`; \ + { echo '#ifndef PACKAGE_VERSION_INTERNAL_H'; \ + echo "#define PACKAGE_VERSION_INTERNAL \"$${current_ver}\""; \ + echo "#endif /* !PACKAGE_VERSION_INTERNAL */"; } > "$(A_V).h.new" + @if test -f "$(A_V).h" \ + && cmp "$(A_V).h.new" "$(A_V).h"; then :; \ + else cat "$(A_V).h.new" > "$(A_V).h"; fi; \ + rm -f "$(A_V).h.new" |