Skip to content

Commit 23a9780

Browse files
committed
XXX Add GIT_COMMIT_HASH to autoconf version message
Add the GIT_COMMIT_HASH to the version message printed by "avrdude -?" and in the avrdude.conf avrdude_conf_version line. This should produce the same version message as cmake builds produce. TODO: Code basically works, but needs cleanups, tests and fixes.
1 parent b94a1f7 commit 23a9780

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

src/GNUmakefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include Makefile
44
AUTORECONF ?= autoreconf
55
AUTORECONF_OPTS ?= -vis
66

7-
script_version := $(shell $(top_srcdir)/build-helpers/package-version $(top_srcdir) version-stamp)
7+
script_version := $(shell $(top_srcdir)/build-helpers/package-version $(top_srcdir) version-stamp git-commit-hash-stamp | { read version hash; echo "$$version"; })
88
ifneq ($(PACKAGE_VERSION),$(script_version))
99
$(info autoconf and script versions do not match: $(PACKAGE_VERSION) vs $(script_version))
1010
$(info Removing autom4te.cache and related files and re-running autoreconf)

src/build-helpers/package-version

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,50 @@ prog="$(basename "$0")"
2121
top_srcdir="${1-.}"
2222
test -d "$top_srcdir" || { \
2323
echo "$prog: Error: Could not change to top_srcdir '$1'" >&2; \
24-
echo "version_error_1" | ${TR-tr} -d '\012'
24+
echo "version_error_01" | ${TR-tr} -d '\012'
2525
exit 2; \
2626
}
2727
version_stamp="${2-version-stamp}"
28+
git_commit_hash_stamp="${3-git-commit-hash-stamp}"
2829

2930
# echo "$prog: Error: Some error happend." >&2
30-
# echo "version_error_2" | ${TR-tr} -d '\012'
31+
# echo "version_error_02" | ${TR-tr} -d '\012'
3132
# exit 2
3233

3334
# Is this a dist source tree?
3435
# If so, use the version number from the version_stamp file.
3536
if test -f "$top_srcdir/$version_stamp"; then
36-
cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012'
37-
exit
37+
if test -f "$top_srcdir/$git_commit_hash_stamp"; then
38+
echo "$(cat "$top_srcdir/$version_stamp") $(cat "$top_srcdir/$git_commit_hash_stamp")" | ${TR-tr} -d '\012'
39+
exit
40+
else
41+
cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012'
42+
exit
43+
fi
44+
elif test -f "$top_srcdir/$git_commit_hash_stamp"; then
45+
echo "$prog: Error: Found git-commit-hash-stamp file, but not version-stamp file.." >&2
46+
echo "version_error_11" | ${TR-tr} -d '\012'
47+
exit 2
3848
fi
3949

4050
# Is this part of a git checkout or an expanded github snapshot tarball?
4151
test -f "$top_srcdir/../CMakeLists.txt" || { \
4252
echo "$prog: Error: top-level avrdude CMakeLists.txt file not found" >&2; \
43-
echo "version_error_3" | ${TR-tr} -d '\012'
53+
echo "version_error_21" | ${TR-tr} -d '\012'
4454
exit 2; \
4555
}
4656

4757
if PROJECT_VERSION="$(${SED-sed} -n 's/project(avrdude[[:space:]]\{1,\}VERSION[[:space:]]\{1,\}\([0-9\.]\{1,\}\)[[:space:]]\{1,\}.*/\1/p' "$top_srcdir/../CMakeLists.txt")"; then
4858
:
4959
else
5060
echo "$prog: Error parsing top-level avrdude 'CMakeLists.txt'." >&2
51-
echo "version_error_4" | ${TR-tr} -d '\012'
61+
echo "version_error_22" | ${TR-tr} -d '\012'
5262
exit 2
5363
fi
5464

5565
test -n "$PROJECT_VERSION" || { \
5666
echo "$prog: Error: Could not find project(...) in top-level avrdude 'CMakeLists.txt'" >&2; \
57-
echo "version_error_5" | ${TR-tr} -d '\012'
67+
echo "version_error_23" | ${TR-tr} -d '\012'
5868
exit 2; \
5969
}
6070

@@ -85,7 +95,7 @@ if test -d "$GIT_DIR"; then
8595
echo "${PROJECT_VERSION}" | ${TR-tr} -d '\012'
8696
exit
8797
else
88-
echo "${PROJECT_VERSION}-${GIT_COMMIT_DATE}" | ${TR-tr} -d '\012'
98+
echo "${PROJECT_VERSION}-${GIT_COMMIT_DATE} ${GIT_COMMIT_HASH}" | ${TR-tr} -d '\012'
8999
exit
90100
fi
91101
else
@@ -97,6 +107,6 @@ else
97107
exit
98108
fi
99109

100-
# If everything else has failed, call this version "devel"
101-
echo "devel" | ${TR-tr} -d '\012'
110+
# This should never be reached
111+
echo "version_error_99" | ${TR-tr} -d '\012'
102112
exit 2

src/build-helpers/package-version.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ distcheck-hook: cur-version-check
88
# restart the whole dist process from the start and there is none.
99
EXTRA_DIST += $(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version
1010
cur-version-check:
11-
@cur_ver=`$(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version $(top_srcdir) version-stamp`; \
11+
@cur_ver="$$($(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version $(top_srcdir) version-stamp git-commit-hash-stamp | { read version hash; echo "$$version"; })"; \
1212
if test "x$${cur_ver}" = "x$(PACKAGE_VERSION)"; then :; else \
1313
echo "ERROR: Recorded PACKAGE_VERSION and current version do not match:"; \
1414
echo " current version: $${cur_ver}"; \
@@ -24,3 +24,4 @@ cur-version-check:
2424
# up anywhere.
2525
cur-version-stamp:
2626
echo "$(PACKAGE_VERSION)" > "$(distdir)/version-stamp"
27+
test "x$(GIT_COMMIT_HASH)" = x || echo "$(GIT_COMMIT_HASH)" > "$(distdir)/git-commit-hash-stamp"

src/configure.ac

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,22 @@ dnl 2013-06-20 automake 1.14
3535
dnl 2018-02-25 automake 1.16
3636
dnl 2018-03-11 automake 1.16.1 install-sh symlink fix
3737

38+
m4_pattern_forbid([ndim4_])
39+
m4_define([ndim4_COMBINED], m4_esyscmd(./build-helpers/package-version . version-stamp git-commit-hash-stamp))
40+
m4_define([ndim4_SPLIT], m4_split(ndim4_COMBINED))
41+
m4_define([ndim4_VERSION], m4_car(ndim4_SPLIT))
42+
m4_define([ndim4_GIT_COMMIT_HASH], m4_argn(2, ndim4_SPLIT))
3843
AC_PREREQ([2.69])
3944
AC_INIT([avrdude],
40-
[m4_esyscmd(./build-helpers/package-version . version-stamp)],
45+
m4_defn([ndim4_VERSION]),
4146
[https://github.com/avrdudes/avrdude/issues])
4247

48+
ndim_COMBINED=m4_defn([ndim4_COMBINED])
49+
ndim_SPLIT=m4_defn([ndim4_SPLIT])
50+
ndim_VERSION=m4_defn([ndim4_VERSION])
51+
ndim_GIT_COMMIT_HASH=m4_defn([ndim4_GIT_COMMIT_HASH])
52+
AC_SUBST([GIT_COMMIT_HASH], [m4_defn([ndim4_GIT_COMMIT_HASH])])
53+
4354
AC_CANONICAL_BUILD
4455
AC_CANONICAL_HOST
4556
AC_CANONICAL_TARGET
@@ -598,8 +609,11 @@ AC_CONFIG_FILES([
598609
])
599610

600611
# Pass version number into avrdude.conf
601-
dnl AVRDUDE_FULL_VERSION="${PACKAGE_VERSION} (${GIT_COMMIT_HASH})"
602-
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION"
612+
AS_VAR_IF([GIT_COMMIT_HASH], [], [dnl
613+
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION"
614+
], [dnl
615+
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION ($GIT_COMMIT_HASH)"
616+
])
603617
AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"],
604618
[The full avrdude version as displayed in -? and avrdude.conf])
605619
AC_SUBST([AVRDUDE_FULL_VERSION])

0 commit comments

Comments
 (0)