diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a583fa96..d87a7b2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,6 @@ jobs: build-essential automake libtool - gettext flex bison libelf-dev diff --git a/src/Makefile.am b/src/Makefile.am index fc978271..5b995756 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,15 +31,19 @@ EXTRA_DIST = \ avrdude.spec \ bootstrap -CLEANFILES = \ - config_gram.c \ - config_gram.h \ - lexer.c +BUILT_SOURCES = +CLEANFILES = + +built_sources = +built_sources += config_gram.c +built_sources += config_gram.h +built_sources += lexer.c + +BUILT_SOURCES += $(built_sources) +CLEANFILES += $(built_sources) include build-helpers/versioninfo.mk -BUILT_SOURCES = $(CLEANFILES) - #SUBDIRS = doc #DIST_SUBDIRS = doc @@ -53,19 +57,16 @@ AM_YFLAGS = -d avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" -libavrdude_a_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" -libavrdude_la_CPPFLAGS = $(libavrdude_a_CPPFLAGS) +libavrdude_la_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" avrdude_CFLAGS = @ENABLE_WARNINGS@ -libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ $(LIBGPIOD_CFLAGS) -libavrdude_la_CFLAGS = $(libavrdude_a_CFLAGS) +libavrdude_la_CFLAGS = @ENABLE_WARNINGS@ $(LIBGPIOD_CFLAGS) -avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBHIDAPI@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ @LIBSERIALPORT@ $(LIBGPIOD_LIBS) -lm +avrdude_LDADD = libavrdude.la @LIBUSB_1_0@ @LIBHIDAPI@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ @LIBSERIALPORT@ $(LIBGPIOD_LIBS) -lm bin_PROGRAMS = avrdude -noinst_LIBRARIES = libavrdude.a lib_LTLIBRARIES = libavrdude.la # automake thinks these generated files should be in the distribution, @@ -77,13 +78,14 @@ lib_LTLIBRARIES = libavrdude.la # https://savannah.nongnu.org/bugs/index.php?func=detailitem&item_id=15536 # # for why we don't want to have them. -dist-hook: - rm -f \ - $(distdir)/lexer.c \ - $(distdir)/config_gram.c \ - $(distdir)/config_gram.h +# +# We could avoid this dist-hook altogether if we could require +# Automake >= 1.16.4 and just use its no-dist-built-sources flag. +dist-hook: dist-hook-no-dist-built-sources-workaround +dist-hook-no-dist-built-sources-workaround: + cd "$(distdir)" && rm -f $(built_sources) -libavrdude_a_SOURCES = \ +libavrdude_la_SOURCES = \ config_gram.y \ lexer.l \ arduino.h \ @@ -218,8 +220,7 @@ libavrdude_a_SOURCES = \ wiring.c \ xbee.h \ xbee.c -libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) -libavrdude_la_LDFLAGS = -version-info 2:0 +libavrdude_la_LDFLAGS = -version-info @LIBAVRDUDE_VERSION_INFO@ include_HEADERS = libavrdude.h include_HEADERS += libavrdude-avrintel.h diff --git a/src/build-helpers/versioninfo.m4 b/src/build-helpers/versioninfo.m4 index 30e36d6e..1fa441ef 100644 --- a/src/build-helpers/versioninfo.m4 +++ b/src/build-helpers/versioninfo.m4 @@ -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] diff --git a/src/build-helpers/versioninfo.sh b/src/build-helpers/versioninfo.sh index 58ebc9c6..4ca2a95e 100755 --- a/src/build-helpers/versioninfo.sh +++ b/src/build-helpers/versioninfo.sh @@ -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; } +($1 == "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"; \ @@ -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 diff --git a/src/configure.ac b/src/configure.ac index b1e3102c..2abf9219 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -32,9 +32,10 @@ dnl 2018-02-25 automake 1.16 dnl 2018-03-11 automake 1.16.1 install-sh symlink fix -dnl Change this definition if you want to change the dist tarball name -dnl pattern from avrdude-7.3 for releases and avrdude-7.3-${COMMIT_DATE} -dnl for snapshots. +dnl Define the dist tarball name as +dnl * avrdude-7.3 for releases +dnl * avrdude-7.3-${COMMIT_DATE} for snapshots +dnl just like CMakeLists.txt does. m4_define([versioninfo_AVRDUDE_PACKAGE_VERSION], m4_case(m4_defn([versioninfo_GIT_COMMIT_HASH]), m4_defn([versioninfo_GIT_TAG_HASH]), @@ -63,7 +64,13 @@ AM_INIT_AUTOMAKE([ AM_SILENT_RULES([yes]) - +dnl Set up the macro definitions for versioninfo_* which we hand to AC_INIT. +dnl +dnl Yes, it does work to expand the VERSIONINFO_SETUP macro *after* AC_INIT: +dnl The presence of VERSIONINFO_SETUP pulls in the definitions at the top. +dnl +dnl For details, see the build-helpers/versioninfo.{md,m4,mk,sh} files. +m4_pattern_forbid([VERSIONINFO_SETUP])dnl VERSIONINFO_SETUP() dnl Inform about the derived PACKAGE_VERSION @@ -85,6 +92,33 @@ AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"], AC_SUBST([AVRDUDE_FULL_VERSION]) +# Define libavrdude libtool version from cmake libavrdude information +dnl +dnl This is a very simple consistency check. If this check ever fails, +dnl the library versioning policy and its technical implementation +dnl must be adapted. +m4_case(m4_defn([versioninfo_CMAKE_LIBAVRDUDE_SOVERSION])[.0.0], + m4_defn([versioninfo_CMAKE_LIBAVRDUDE_VERSION]), + [], + [m4_fatal([ +The cmake libavrdude VERSION should be SOVERSION.0.0 ("]m4_defn([versioninfo_CMAKE_LIBAVRDUDE_SOVERSION])[.0.0"), +but it is actually "]m4_defn([versioninfo_CMAKE_LIBAVRDUDE_VERSION])[". + +This is an internal error in the logic which transfers library version +information from the cmake buildsystem to the automake buildsystem. + +Please file a GitHub issue for avrdude and mention @ndim. + ])])dnl +dnl +AC_MSG_CHECKING([versioninfo derived libtool -version-info for libavrdude]) +libavrdude_lt_cur=$CMAKE_LIBAVRDUDE_SOVERSION +libavrdude_lt_rev=0 +libavrdude_lt_age=0 +AC_SUBST([LIBAVRDUDE_VERSION_INFO], + [${libavrdude_lt_cur}:${libavrdude_lt_rev}:${libavrdude_lt_age}]) +AC_MSG_RESULT([$LIBAVRDUDE_VERSION_INFO]) + + # Checks for programs. AC_PROG_CC AC_PROG_INSTALL @@ -93,13 +127,17 @@ AC_PROG_SED AC_PROG_YACC AC_PROG_LEX([noyywrap]) AM_PROG_AR + +m4_pattern_forbid([LT_INIT])dnl LT_INIT() -# If macro PKG_PROG_PKG_CONFIG is not available, Autoconf generates a misleading error message, -# so check for existence first, and otherwise provide helpful advice. +dnl If macro PKG_PROG_PKG_CONFIG is not available, Autoconf generates +dnl a misleading error message, so check for existence first, and +dnl otherwise provide helpful advice. m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal(m4_normalize([ Macro PKG_PROG_PKG_CONFIG is not available. It is usually defined in file pkg.m4 provided by package pkg-config.]))]) +m4_pattern_forbid([PKG_PROG_PKG_CONFIG])dnl PKG_PROG_PKG_CONFIG([0.23]) AH_TEMPLATE([HAVE_YYLEX_DESTROY],