|
| 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