Skip to content

Commit a690c40

Browse files
committed
Add GIT_COMMIT_HASH to autotools AVRDUDE_FULL_VERSION
Add the GIT_COMMIT_HASH to the version message printed by "avrdude -?" and in the avrdude.conf avrdude_conf_version line. So the autotools buildsystem now produces the identical version message as the cmake buildsystem does.
1 parent dd9e4d2 commit a690c40

File tree

9 files changed

+454
-160
lines changed

9 files changed

+454
-160
lines changed

src/GNUmakefile.in

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Helps update the version number automatically if using GNU make.
2-
include Makefile
1+
# @configure_input@
32

4-
AUTORECONF ?= autoreconf
5-
AUTORECONF_OPTS ?= -vis
3+
include Makefile
64

7-
script_version := $(shell $(top_srcdir)/build-helpers/package-version $(top_srcdir) version-stamp)
8-
ifneq ($(PACKAGE_VERSION),$(script_version))
9-
$(info autoconf and script versions do not match: $(PACKAGE_VERSION) vs $(script_version))
10-
$(info Removing autom4te.cache and related files and re-running autoreconf)
11-
dummy1 := $(shell rm -rf $(top_srcdir)/autom4te.cache)
12-
dummy2 := $(shell $(AUTORECONF) $(AUTORECONF_OPTS) $(top_srcdir))
5+
need_to_rerun := $(shell $(top_srcdir)/build-helpers/versioninfo.sh "$(top_srcdir)" "@VERSIONINFO_STAMPFILE@" | { @VERSIONINFO_READ@; \
6+
if @VERSIONINFO_IS_UNCHANGED@ \
7+
echo "no"; \
8+
fi; } )
9+
ifneq (no,$(need_to_rerun))
10+
$(info Recorded and current version information do not match.)
11+
$(info Re-running autoreconf via bootstrap.)
12+
dummy1 := $(shell $(top_srcdir)/bootstrap)
1313
endif
1414

1515
# vim: syntax=make

src/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CLEANFILES = \
4040
config_gram.h \
4141
lexer.c
4242

43-
include build-helpers/package-version.mk
43+
include build-helpers/versioninfo.mk
4444

4545
BUILT_SOURCES = $(CLEANFILES)
4646

@@ -248,4 +248,4 @@ backup-avrdude-conf:
248248
${DESTDIR}${sysconfdir}/avrdude.conf.bak; \
249249
fi
250250

251-
ACLOCAL_AMFLAGS = -I m4
251+
ACLOCAL_AMFLAGS = -I m4 -I build-helpers

src/build-helpers/package-version

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/build-helpers/package-version.mk

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/build-helpers/versioninfo.m4

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# versioninfo.m4 - find avrdude version information for msg -*- Autoconf -*-
2+
# serial 1
3+
dnl | Increment the above serial number every time you edit this file.
4+
dnl | When it finds multiple m4 files with the same name,
5+
dnl | aclocal will use the one with the highest serial.
6+
dnl
7+
dnl The sequence of version info items to store in the version-stamp file.
8+
dnl This must be the same sequence as the versioninfo script writes.
9+
m4_pattern_forbid([versioninfo_items])
10+
m4_define([versioninfo_items], [
11+
[CMAKE_PROJECT_VERSION],
12+
[GIT_COMMIT_DATE],
13+
[GIT_COMMIT_HASH],
14+
[GIT_TAG_HASH]
15+
])
16+
dnl
17+
dnl Initialize version info from the script command given as macro argument.
18+
m4_pattern_forbid([versioninfo_init])
19+
m4_define([versioninfo_init], [
20+
m4_pushdef([versioninfo_split], m4_split(m4_esyscmd($1),m4_newline))
21+
m4_case(m4_sysval, [0], [
22+
m4_for([N], [1], m4_count(versioninfo_split), [1], [
23+
m4_define([versioninfo_]m4_normalize(m4_argn(N, versioninfo_items)),
24+
m4_normalize(m4_argn(N, versioninfo_split)))
25+
])
26+
], [
27+
m4_fatal([versioninfo script returned non-0])
28+
])
29+
])
30+
dnl
31+
m4_define([versioninfo_stampfile], [versioninfo-stamp])
32+
dnl
33+
versioninfo_init([./build-helpers/versioninfo.sh . ]m4_defn([versioninfo_stampfile]))
34+
dnl
35+
dnl
36+
dnl
37+
dnl ========================================================================
38+
dnl VERSIONINFO_SETUP()
39+
dnl ========================================================================
40+
dnl
41+
AC_DEFUN([VERSIONINFO_SETUP], [dnl
42+
m4_foreach([ITEM], [versioninfo_items], [dnl
43+
AC_SUBST(m4_normalize(ITEM), [m4_defn([versioninfo_]m4_normalize(ITEM))])
44+
AC_MSG_CHECKING([versioninfo item ]m4_normalize(ITEM))
45+
AC_MSG_RESULT([$]m4_normalize(ITEM))
46+
])
47+
dnl
48+
dnl Define helper substitutions containing shell code for use inside
49+
dnl make recipes in build-helpers/versioninfo.mk and $(shell ...)
50+
dnl calls in GNUmakefile.in dealing with version info.
51+
dnl
52+
AC_SUBST([VERSIONINFO_STAMPFILE], [m4_defn([versioninfo_stampfile])])
53+
AM_SUBST_NOTMAKE([VERSIONINFO_WRITE])
54+
dnl
55+
AC_SUBST([VERSIONINFO_READ],
56+
['m4_foreach([ITEM], [versioninfo_items], [read m4_normalize(ITEM); ]):'])
57+
AM_SUBST_NOTMAKE([VERSIONINFO_READ])
58+
dnl
59+
AC_SUBST([VERSIONINFO_WRITE],
60+
['printf "%s\n"m4_foreach([ITEM], [versioninfo_items], [ "$(m4_normalize(ITEM))"])'])
61+
AM_SUBST_NOTMAKE([VERSIONINFO_WRITE])
62+
dnl
63+
AC_SUBST([VERSIONINFO_IS_UNCHANGED],
64+
['false; then :; m4_foreach([ITEM], [versioninfo_items], [elif test "x$(m4_normalize(ITEM))" != "x$$m4_normalize(ITEM)"; then printf "%s has changed from %s to %s\n" "m4_normalize(ITEM)" "$(m4_normalize(ITEM))" "$$m4_normalize(ITEM)" >&2; ]) else '])
65+
AM_SUBST_NOTMAKE([VERSIONINFO_IS_UNCHANGED])
66+
dnl
67+
])dnl
68+
dnl
69+
dnl ####################################################################
70+
dnl
71+
dnl Local Variables:
72+
dnl mode: autoconf
73+
dnl End:

0 commit comments

Comments
 (0)