Skip to content

Commit cb53a34

Browse files
committed
Add extra version information to avrdude output
Some downstream projects build avrdude and want to add their own version information to the avrdude version to distinguish their builds from others. This adds a clean way to do that without needing to patch the avrdude sources, for both cmake and automake based builds: cmake -DEXTRA_VERSION:STRING=-arduino.1-rc1 ../configure EXTRA_VERSION=-arduino.1-rc1 After building avrdude, the last line of "avrdude -?" will now look similar to the following, depending on whether you are building an avrdude git checkout or an avrdude release tarball: avrdude version 8.0-20240901-arduino.1-rc1 (30e19f2), https://github.com/avrdudes/avrdude avrdude version 8.1-arduino.1-rc1 (30e19f2), https://github.com/avrdudes/avrdude
1 parent 30e19f2 commit cb53a34

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ include(FindPackageMessage)
4949
include(GNUInstallDirs)
5050

5151
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
52-
set(AVRDUDE_FULL_VERSION ${CMAKE_PROJECT_VERSION})
52+
set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}${EXTRA_VERSION_SUFFIX}")
5353

5454
# =====================================
5555
# Get Git commit info
@@ -91,7 +91,7 @@ if(Git_FOUND)
9191

9292
# If the commit is not tagged, include the date and commit hash in the full version string.
9393
if(NOT GIT_COMMIT_HASH STREQUAL GIT_TAG_HASH)
94-
set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}-${GIT_COMMIT_DATE} (${GIT_COMMIT_HASH})")
94+
set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}-${GIT_COMMIT_DATE}${EXTRA_VERSION_SUFFIX} (${GIT_COMMIT_HASH})")
9595
endif()
9696
endif()
9797

@@ -373,6 +373,7 @@ if (DEBUG_CMAKE)
373373
message(STATUS "CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}")
374374
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
375375
message(STATUS "CONFIG_DIR: ${CONFIG_DIR}")
376+
message(STATUS "EXTRA_VERSION_SUFFIX: ${EXTRA_VERSION_SUFFIX}")
376377
message(STATUS "AVRDUDE_FULL_VERSION: ${AVRDUDE_FULL_VERSION}")
377378
message(STATUS "USE_EXTERNAL_LIBS: ${USE_EXTERNAL_LIBS}")
378379
message(STATUS "USE_LIBUSBWIN32: ${USE_LIBUSBWIN32}")

src/configure.ac

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ AC_MSG_RESULT([$PACKAGE_VERSION])
8080
dnl Compose the full version message mirroring the cmake one, inform
8181
dnl about it and pass it on to avrdude.conf and the "avrdude -?"
8282
dnl version message
83+
AC_ARG_VAR([EXTRA_VERSION_SUFFIX],
84+
[extra version information to be appended to the version])
8385
AC_MSG_CHECKING([versioninfo derived AVRDUDE_FULL_VERSION])
8486
if test "x$GIT_COMMIT_HASH" = "x$GIT_TAG_HASH"; then
85-
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION"
87+
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION$EXTRA_VERSION_SUFFIX"
8688
else
87-
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION ($GIT_COMMIT_HASH)"
89+
AVRDUDE_FULL_VERSION="$PACKAGE_VERSION$EXTRA_VERSION_SUFFIX ($GIT_COMMIT_HASH)"
8890
fi
8991
AC_MSG_RESULT([$AVRDUDE_FULL_VERSION])
9092
AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"],

0 commit comments

Comments
 (0)