Skip to content

Commit

Permalink
XXX libavrdude VERSION and SOVERSION from cmake for autotools
Browse files Browse the repository at this point in the history
This transfers the information from the CMakeLists.txt
libavrdude VERSION and SOVERSION into the autotools
configure script and AC_SUBST into every Makefile.

This information is completely unused at this time.
  • Loading branch information
ndim committed Feb 21, 2024
1 parent 8553d37 commit 849fa5e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/build-helpers/versioninfo.m4
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ dnl This must be the same sequence as the versioninfo script writes.
m4_pattern_forbid([versioninfo_items])
m4_define([versioninfo_items], [
[CMAKE_PROJECT_VERSION],
[CMAKE_LIBAVRDUDE_VERSION],
[CMAKE_LIBAVRDUDE_SOVERSION],
[GIT_COMMIT_DATE],
[GIT_COMMIT_HASH],
[GIT_TAG_HASH]
Expand Down
34 changes: 33 additions & 1 deletion src/build-helpers/versioninfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ test -n "$PROJECT_VERSION" || \
ret_error "Cannot find project(...) in top-level avrdude 'CMakeLists.txt'"


# Parse libavrdude library version from CMakeLists.txt
tmp="$(${AWK-awk} '
BEGIN { v=0; }
/^set_target_properties\(libavrdude\>/ { v=1; }
(v == 1) && /^[[:space:]]+\)/ { v=0; }
(v == 1) && /^[[:space:]]+VERSION[[:space:]]+/ { version=$2; }
(v == 1) && /^[[:space:]]+SOVERSION[[:space:]]+/ { soversion=$2; }
END { print version;
print soversion; }
' < "$top_srcdir/CMakeLists.txt")"


# Extract the libavrdude VERSION
CMAKE_LIBAVRDUDE_VERSION="$(printf "%s\n" "$tmp" | { \
read LIB_VERSION; read LIB_SOVERSION; \
printf "%s\n" "$LIB_VERSION"; })"

test -n "$CMAKE_LIBAVRDUDE_VERSION" || \
ret_error "Cannot find library VERSION in library 'CMakeLists.txt'"


# Extract the libavrdude SOVERSION
CMAKE_LIBAVRDUDE_SOVERSION="$(printf "%s\n" "$tmp" | { \
read LIB_VERSION; read LIB_SOVERSION; \
printf "%s\n" "$LIB_SOVERSION"; })"

test -n "$CMAKE_LIBAVRDUDE_SOVERSION" || \
ret_error "Cannot find library SOVERSION in library 'CMakeLists.txt'"


# If GIT_DIR is set, use it. If not, try "$top_srcdir/../.git".
test -n "$GIT_DIR" || { \
GIT_DIR="$top_srcdir/../.git"; \
Expand All @@ -106,11 +136,13 @@ if test -d "$GIT_DIR" && ${GIT-git} --version > /dev/null 2>&1; then
ret_error "$prog: Cannot run 'git log' for tag hash"
# This must be the same sequence as versioninfo_items in configure.ac
ret_ok "${PROJECT_VERSION}" \
"${CMAKE_LIBAVRDUDE_VERSION}" "${CMAKE_LIBAVRDUDE_SOVERSION}" \
"${GIT_COMMIT_DATE}" "${GIT_COMMIT_HASH}" "${GIT_TAG_HASH}"
else # This is a github release tarball or github snapshot tarball
# Presume this is a release version, because who would build a
# non-release version from a snapshot tarball?
ret_ok "${PROJECT_VERSION}"
ret_ok "${PROJECT_VERSION}" \
"${CMAKE_LIBAVRDUDE_VERSION}" "${CMAKE_LIBAVRDUDE_SOVERSION}"
fi


Expand Down

0 comments on commit 849fa5e

Please sign in to comment.