From bfd9606d23a703bc77371e5fce70e56eea9ce3b4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 16:43:26 +0100 Subject: [PATCH 01/30] More stringent #include API checks --- src/libavrdude-avrintel.h | 3 +++ src/libavrdude.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 9e7197b0..830f1960 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -1,6 +1,9 @@ /* * Do not edit: automatically generated by mkavrintel.pl * + * Do NOT directly "#include " into your code. + * DO "#include " instead. + * * libavrdude-avrintel.h * * Microchip AVR8L, AVR8, XMEGA and AVR8X family description of interrupts, configurations and more diff --git a/src/libavrdude.h b/src/libavrdude.h index 648fceba..36187d2e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -25,6 +25,11 @@ #include #include #include + +#ifdef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS +#error LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS is defined. Do not do that. +#endif + #define LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS #include "libavrdude-avrintel.h" #undef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS From efafa0ced050841e447d70c3340be916aeda76cf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 17:14:25 +0100 Subject: [PATCH 02/30] Install libavrdude internal header libavrdude-avrintel.h --- src/CMakeLists.txt | 2 +- src/Makefile.am | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c02d4d54..9c1b9149 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -278,7 +278,7 @@ add_library(libavrdude set_target_properties(libavrdude PROPERTIES PREFIX "" - PUBLIC_HEADER "libavrdude.h" + PUBLIC_HEADER "libavrdude.h;libavrdude-avrintel.h" VERSION 1.0.0 SOVERSION 1 ) diff --git a/src/Makefile.am b/src/Makefile.am index 8863291a..eaf70732 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -222,6 +222,7 @@ libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) libavrdude_la_LDFLAGS = -version-info 1:0 include_HEADERS = libavrdude.h +include_HEADERS += libavrdude-avrintel.h avrdude_SOURCES = \ main.c \ From df7c495fb7471c48144055d737748da0931c8848 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 16:44:53 +0100 Subject: [PATCH 03/30] Use proper C99 parameterless function declaration --- src/libavrdude.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 36187d2e..413be677 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1108,11 +1108,11 @@ int avr_read(const PROGRAMMER * pgm, const AVRPART *p, const char *memstr, const int avr_write_page(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr); -unsigned long avr_ustimestamp(); +unsigned long avr_ustimestamp(void); -unsigned long avr_mstimestamp(); +unsigned long avr_mstimestamp(void); -double avr_timestamp(); +double avr_timestamp(void); int avr_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char data); @@ -1481,7 +1481,7 @@ const char *str_plural(int x); const char *str_inname(const char *fn); const char *str_outname(const char *fn); const char *str_interval(int a, int b); -bool is_bigendian(); +bool is_bigendian(void); void change_endian(void *p, int size); int memall(const void *p, char c, size_t n); unsigned long long int str_ull(const char *str, char **endptr, int base); @@ -1511,7 +1511,7 @@ int terminal_mode(const PROGRAMMER *pgm, const AVRPART *p); int terminal_mode_noninteractive(const PROGRAMMER *pgm, const AVRPART *p); int terminal_line(const PROGRAMMER *pgm, const AVRPART *p, const char *line); char *terminal_get_input(const char *prompt); -void terminal_setup_update_progress(); +void terminal_setup_update_progress(void); #ifdef __cplusplus } From ec698b4e1aa70bcb9bddb0618a668051f93e6314 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 16:46:02 +0100 Subject: [PATCH 04/30] Include headers defining the used types As libavrdude-avrintel.h uses not only uint32_t and related types from stdint.h, but also size_t from stddef.h, we also need to #include the latter into libavrdude.h before libavrdude.h includes libavrdude-avrintel.h --- src/libavrdude.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 413be677..1675b766 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #ifdef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS From 565a7238f49d2101412679b332ef92e898ce4ed0 Mon Sep 17 00:00:00 2001 From: Dawid Buchwald Date: Fri, 16 Feb 2024 09:38:52 +0100 Subject: [PATCH 05/30] Updated section about NVM models support --- src/doc/avrdude.texi | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 3707f4ef..b77186a5 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -3722,15 +3722,11 @@ Tx---/\/\/\---Tx |----|<|---' .--------| Gnd 470 ohm There are several limitations in current SerialUPDI/AVRDUDE integration, listed below. -At the end of each run there are fuse values being presented to the user. -For most of the UPDI-enabled devices these definitions (low fuse, high -fuse, extended fuse) have no meaning whatsoever, as they have been -simply replaced by array of fuses: fuse0..9. Therefore you can simply -ignore this particular line of AVRDUDE output. - -Currently available devices support only UPDI NVM programming model 0 -and 2, but there is also experimental implementation of model 3 - not -yet tested. +Currently available devices support only UPDI NVM programming model 0, 2 +3 and 5, but there is also experimental implementation of model 4 - it +has been tested only on a single device, so issues with other devices are +expected. Full NVM v4 mode support will be provided once the hardware is +widely available. One of the core AVRDUDE features is verification of the connection by reading device signature prior to any operation, but this operation From 8fb73a1458343e87b46f9d9ce3c20a5dca932f92 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 6 Feb 2024 12:18:47 +0100 Subject: [PATCH 06/30] Add basic CI checks using the autotools build This add some basic CI checks which exercise the autotools build: * make targets "all" "install" testing compilation and installation * run the same dry-run test-avrdude check as the cmake builds * make target "distcheck" testing that dist tarball contains all the necessary files --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b1dfdb9..38120150 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,6 +31,51 @@ env: BUILD_TYPE: RelWithDebInfo jobs: + linux-x86_64-autotools: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install prerequisites + run: >- + sudo apt-get update + + sudo apt-get install -y + build-essential + automake + libtool + gettext + flex + bison + libelf-dev + libusb-dev + libusb-1.0-0-dev + libhidapi-dev + libftdi1-dev + libreadline-dev + libserialport-dev + texinfo + texlive + texi2html + - name: Configure + run: >- + autoreconf -vis src + + mkdir _ambuild && cd _ambuild + + ../src/configure + --enable-doc + --enable-parport + --enable-linuxgpio + --enable-linuxspi + - name: Build + run: make -C _ambuild -j$(nproc) + - name: Install + run: sudo make -C _ambuild install + - name: Dryrun_test + run: printf "\n\n" | ./tools/test-avrdude -d0 -p"-cdryrun -pm2560" -p"-cdryrun -pavr64du28" + - name: distcheck + run: make -C _ambuild -j$(nproc) distcheck + linux-x86_64: runs-on: ubuntu-latest steps: From 610330f0d9296b9cef734a996f2ed3d11e46bcaf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 8 Feb 2024 04:09:44 +0100 Subject: [PATCH 07/30] Remove unused unnecessary commented build code Remove unused unnecessary commented out build code from "src/configure.ac". I accidentally left those comments in commit d15c561a. --- src/configure.ac | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index d24ba689..65cd7f6d 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -563,16 +563,6 @@ AC_CONFIG_FILES([ AC_CONFIG_FILES([ GNUmakefile ]) -dnl TODO: Add GIT_COMMIT_HASH to the AVRDUDE_FULL_VERSION like cmake build does -dnl # Detect GIT -dnl AC_ARG_VAR([GIT], [git revision control system]) -dnl AS_VAR_IF([GIT], [], [dnl -dnl AC_PATH_PROG([GIT], [git], [no]) -dnl ]) -dnl AM_CONDITIONAL([HAVE_GIT], [test "x$GIT" != xno]) -dnl AS_IF([test -d "../.git/info/exclude"], [dnl -dnl GIT_COMMIT_HASH="$(${GIT} --version)" -dnl ]) # Pass version number into avrdude.conf dnl AVRDUDE_FULL_VERSION="${PACKAGE_VERSION} (${GIT_COMMIT_HASH})" From 1b5f3935b619c939b13c1ddc0b8af4a2cc1367ad Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 8 Feb 2024 17:25:56 +0100 Subject: [PATCH 08/30] Add example build script for autotools build tests --- src/autotools-build.sh | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 src/autotools-build.sh diff --git a/src/autotools-build.sh b/src/autotools-build.sh new file mode 100755 index 00000000..e1843cb6 --- /dev/null +++ b/src/autotools-build.sh @@ -0,0 +1,57 @@ +#! /bin/sh + +set -ex + +cd "$(dirname "$0")" +top_srcdir="$(pwd)" + +ostype="$(uname | tr A-Z a-z)" + +if test "x$MAKE" = x; then + if gmake --version > /dev/null 2>&1; then + MAKE=gmake + fi +fi +make="${make-"${MAKE-make} -j$(nproc)"}" + +rm -rf autom4te.cache/ + +prefix="$top_srcdir/build_autotools-prefix" +rm -rf "$prefix" + +top_builddir="$top_srcdir/build_autotools" + +# Remove remainders of failed distcheck attempts +for dir in "$top_builddir" +do + if test -d "$dir"; then + chmod -R +w "$dir" + fi +done +rm -rf "$top_builddir" + +./bootstrap + +mkdir "$top_builddir" +cd "$top_builddir" + +configure_opts="" +configure_opts="$configure_opts --disable-silent-rules" +configure_opts="$configure_opts --enable-parport" +case "$ostype" in + *linux) + configure_opts="$configure_opts --enable-linuxgpio --enable-linuxspi" + configure_opts="$configure_opts --enable-doc" + ;; +esac + +$top_srcdir/configure --prefix="$prefix" ${configure_opts} + +$make all +$make check +$make install +$make installcheck + +printf "\n\n" | $top_srcdir/../tools/test-avrdude -e $prefix/bin/avrdude -d0 -p"-cdryrun -pm2560" -p"-cdryrun -pavr64du28" + +$make distcheck From c96032a57b4d61ca44ca4b599a6b50cd57a706ad Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 11 Feb 2024 20:46:42 +0100 Subject: [PATCH 09/30] Move all autotools helper scripts to auto-aux/ Move all autotools helper scripts and auxiliary files installed automatically by the autotools to auto-aux/ (e.g. config.guess, depcomp, install-sh, texinfo.tex, etc.). Moving AC_CANONICAL_TARGET after AC_CONFIG_AUX_DIR works around a silent bug in Autoconf 2.69 where the generated configure script would not find the install-sh file which has been placed in that given aux directory. Moved AM_INIT_AUTOMAKE which must also happen after AC_CONFIG_AUX_DIR. --- src/auto-aux/.gitignore | 2 ++ src/configure.ac | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 src/auto-aux/.gitignore diff --git a/src/auto-aux/.gitignore b/src/auto-aux/.gitignore new file mode 100644 index 00000000..cf0fcab4 --- /dev/null +++ b/src/auto-aux/.gitignore @@ -0,0 +1,2 @@ +# Ensure git creates empty directory for autotools to place files into +* diff --git a/src/configure.ac b/src/configure.ac index 65cd7f6d..9734c312 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -27,14 +27,16 @@ AC_INIT([avrdude], m4_esyscmd([./build-helpers/package-version . version-stamp]), [https://github.com/avrdudes/avrdude/issues]) +AC_CONFIG_SRCDIR([main.c]) +AC_CONFIG_HEADERS([ac_cfg.h]) +AC_CONFIG_AUX_DIR([auto-aux]) +AC_CONFIG_MACRO_DIR([m4]) + AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET -AC_CONFIG_SRCDIR([main.c]) AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_HEADERS(ac_cfg.h) -AC_CONFIG_MACRO_DIR([m4]) # Check that the build-helpers/package-version script has worked properly. case "$PACKAGE_VERSION" in From 2a6f4151663ba1ca8df098a7daa773b37107127d Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 16:14:52 +0100 Subject: [PATCH 10/30] Have autoreconf deal with initializing GNU build system Let the autoreconf tool handle the sequencing of tool calls. The autoreconf tool has been dealing with calling tools like aclocal, libtoolize, etc. quite well for about the last 20 years. This keeps the "bootstrap" script around to keep the old way of calling bootstrap working, i.e. maintain compatibility with the existing workflows. --- src/bootstrap | 8 +++----- src/configure.ac | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/bootstrap b/src/bootstrap index 207dc4c2..02163035 100755 --- a/src/bootstrap +++ b/src/bootstrap @@ -1,5 +1,6 @@ #! /bin/sh +: ${AUTORECONF="autoreconf${AC_VER}"} : ${AUTOHEADER="autoheader${AC_VER}"} : ${AUTOCONF="autoconf${AC_VER}"} : ${ACLOCAL="aclocal${AM_VER}"} @@ -17,9 +18,6 @@ rm -rf autom4te.cache # probe for that LIBTOOLIZE=libtoolize glibtoolize --version > /dev/null 2>&1 && LIBTOOLIZE=glibtoolize -${LIBTOOLIZE} +export LIBTOOLIZE -${ACLOCAL} -${AUTOHEADER} -${AUTOCONF} -${AUTOMAKE} -a -c +${AUTORECONF} -i diff --git a/src/configure.ac b/src/configure.ac index 9734c312..deab8b5c 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -20,7 +20,7 @@ # $Id$ # -# Process this file with autoconf to produce a configure script. +# Process this file with autoreconf to produce a configure script. AC_PREREQ(2.60) AC_INIT([avrdude], From b4402bd334874f07bd7310c513e3f55f68f3268c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 16:16:22 +0100 Subject: [PATCH 11/30] Have bootstrap script work only in its own directory When called from a working directory different from the directory where the bootstrap script is located, make the bootstrap script only work on its own directory and not whatever the current working directory just happens to be. --- src/bootstrap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap b/src/bootstrap index 02163035..9e8d4b9e 100755 --- a/src/bootstrap +++ b/src/bootstrap @@ -1,5 +1,7 @@ #! /bin/sh +cd "$(dirname "$0")" + : ${AUTORECONF="autoreconf${AC_VER}"} : ${AUTOHEADER="autoheader${AC_VER}"} : ${AUTOCONF="autoconf${AC_VER}"} From ed2bb826526cc18c16608dbfe90edfe4b045ba66 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 13 Feb 2024 13:25:57 +0100 Subject: [PATCH 12/30] Pass bootstrap CLI arguments to autoreconf For my convenience, pass all bootstrap CLI arguments on to autoreconf. This is useful when testing with e.g. -Wall and -Werror arguments. --- src/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap b/src/bootstrap index 9e8d4b9e..19d4bb64 100755 --- a/src/bootstrap +++ b/src/bootstrap @@ -22,4 +22,4 @@ LIBTOOLIZE=libtoolize glibtoolize --version > /dev/null 2>&1 && LIBTOOLIZE=glibtoolize export LIBTOOLIZE -${AUTORECONF} -i +${AUTORECONF} -i "$@" From 9b576c4c014430374a1dd21a2883a9574cb116c9 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 15:56:43 +0100 Subject: [PATCH 13/30] Raw result of running "autoupdate" This is just the raw result of running "autoupdate" to update the src/configure.ac file to a more recent standard. Manual fixes to the autoupdate output will happen over the next few commits. This fixes some of the autoreconf time warnings, e.g. about AC_TRY_* being used instead of AC_*_IFELSE. --- src/configure.ac | 64 +++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index deab8b5c..0b820577 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -22,10 +22,8 @@ # Process this file with autoreconf to produce a configure script. -AC_PREREQ(2.60) -AC_INIT([avrdude], - m4_esyscmd([./build-helpers/package-version . version-stamp]), - [https://github.com/avrdudes/avrdude/issues]) +AC_PREREQ([2.71]) +AC_INIT([avrdude],[m4_esyscmd(./build-helpers/package-version . version-stamp)],[https://github.com/avrdudes/avrdude/issues]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([ac_cfg.h]) @@ -139,9 +137,7 @@ AC_SUBST(LIBUSB, $LIBUSB) AC_ARG_ENABLE( [libusb_1_0], - AC_HELP_STRING( - [--disable-libusb_1_0], - [Allow to build with libusb instead of libusb_1_0 if both are present]), + AS_HELP_STRING([--disable-libusb_1_0],[Allow to build with libusb instead of libusb_1_0 if both are present]), [case "${enableval}" in yes) enabled_libusb_1_0=yes ;; no) enabled_libusb_1_0=no ;; @@ -259,7 +255,20 @@ AC_CHECK_HEADERS([ddk/hidsdi.h],,,[#include # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -AC_HEADER_TIME +m4_warn([obsolete], +[Update your code to rely only on HAVE_SYS_TIME_H, +then remove this warning and the obsolete code below it. +All current systems provide time.h; it need not be checked for. +Not all systems provide sys/time.h, but those that do, all allow +you to include it and time.h simultaneously.])dnl +AC_CHECK_HEADERS_ONCE([sys/time.h]) +# Obsolete code to be removed. +if test $ac_cv_header_sys_time_h = yes; then + AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both + and . This macro is obsolete.]) +fi +# End of obsolete code. + AC_CHECK_HEADERS([netinet/in.h]) @@ -281,10 +290,9 @@ LIBS="${LIBS} ${LIBHID}" AH_TEMPLATE([HAVE_LIBHID], [Define if HID support is enabled via the Win32 DDK]) -AC_TRY_LINK([#include +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include #include -$HIDINCLUDE], -[int +$HIDINCLUDE]], [[int main(void) { GUID hidGuid; @@ -292,7 +300,7 @@ main(void) return 0; } -], [have_libhid=yes], [have_libhid=no]) +]])],[have_libhid=yes],[have_libhid=no]) AC_MSG_RESULT([$have_libhid]) if test x$have_libhid = xyes; then AC_DEFINE([HAVE_LIBHID]) @@ -313,9 +321,7 @@ AC_CHECK_TYPES([ulong_t], [], [], [#include ]) AC_ARG_ENABLE( [versioned-doc], - AC_HELP_STRING( - [--enable-versioned-doc], - [install docs in directory with version name (default)]), + AS_HELP_STRING([--enable-versioned-doc],[install docs in directory with version name (default)]), [case "${enableval}" in yes) versioned_doc=yes ;; no) versioned_doc=no ;; @@ -331,9 +337,7 @@ fi AC_ARG_ENABLE( [doc], - AC_HELP_STRING( - [--enable-doc], - [Enable building documents]), + AS_HELP_STRING([--enable-doc],[Enable building documents]), [case "${enableval}" in yes) enabled_doc=yes ;; no) enabled_doc=no ;; @@ -343,9 +347,7 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [parport], - AC_HELP_STRING( - [--enable-parport], - [Enable accessing parallel ports(default)]), + AS_HELP_STRING([--enable-parport],[Enable accessing parallel ports(default)]), [case "${enableval}" in yes) enabled_parport=yes ;; no) enabled_parport=no ;; @@ -355,9 +357,7 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [linuxgpio], - AC_HELP_STRING( - [--enable-linuxgpio], - [Enable the Linux sysfs GPIO interface programmer type]), + AS_HELP_STRING([--enable-linuxgpio],[Enable the Linux sysfs GPIO interface programmer type]), [case "${enableval}" in yes) enabled_linuxgpio=yes ;; no) enabled_linuxgpio=no ;; @@ -367,9 +367,7 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [linuxspi], - AC_HELP_STRING( - [--enable-linuxspi], - [Enable the Linux SPIDEV interface programmer type]), + AS_HELP_STRING([--enable-linuxspi],[Enable the Linux SPIDEV interface programmer type]), [case "${enableval}" in yes) enabled_linuxspi=yes ;; no) enabled_linuxspi=no ;; @@ -490,10 +488,10 @@ if test "$GCC" = yes; then safe_CFLAGS=$CFLAGS CFLAGS="$ENABLE_WARNINGS -Wno-pointer-sign" - AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]])],[ no_pointer_sign=yes AC_MSG_RESULT([yes]) - ], [ + ],[ no_pointer_sign=no AC_MSG_RESULT([no]) ]) @@ -515,10 +513,10 @@ case $target in safe_CFLAGS="$CFLAGS" CFLAGS="$ENABLE_WARNINGS -mno-cygwin" - AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]])],[ no_cygwin=yes AC_MSG_RESULT([yes]) - ], [ + ],[ no_cygwin=no AC_MSG_RESULT([no]) ]) @@ -539,10 +537,10 @@ case $target in safe_LDFLAGS="$LDFLAGS" LDFLAGS="${LDFLAGS} -static" - AC_TRY_LINK(, [ int main () { return 0 ; } ], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]])],[ can_link_static=yes AC_MSG_RESULT([yes]) - ], [ + ],[ can_link_static_cygwin=no AC_MSG_RESULT([no]) ]) From b6a47dddecdb84f916bd8c492eae344696aadc2a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 16:19:59 +0100 Subject: [PATCH 14/30] Line wraps to improve human readability Wrap some lines in src/configure.ac to improve readability. --- src/configure.ac | 52 ++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 0b820577..4ba197e7 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -23,7 +23,9 @@ # Process this file with autoreconf to produce a configure script. AC_PREREQ([2.71]) -AC_INIT([avrdude],[m4_esyscmd(./build-helpers/package-version . version-stamp)],[https://github.com/avrdudes/avrdude/issues]) +AC_INIT([avrdude], + [m4_esyscmd(./build-helpers/package-version . version-stamp)], + [https://github.com/avrdudes/avrdude/issues]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([ac_cfg.h]) @@ -137,7 +139,8 @@ AC_SUBST(LIBUSB, $LIBUSB) AC_ARG_ENABLE( [libusb_1_0], - AS_HELP_STRING([--disable-libusb_1_0],[Allow to build with libusb instead of libusb_1_0 if both are present]), + AS_HELP_STRING([--disable-libusb_1_0], + [Allow to build with libusb instead of libusb_1_0 if both are present]), [case "${enableval}" in yes) enabled_libusb_1_0=yes ;; no) enabled_libusb_1_0=no ;; @@ -300,7 +303,7 @@ main(void) return 0; } -]])],[have_libhid=yes],[have_libhid=no]) +]])], [have_libhid=yes], [have_libhid=no]) AC_MSG_RESULT([$have_libhid]) if test x$have_libhid = xyes; then AC_DEFINE([HAVE_LIBHID]) @@ -321,7 +324,8 @@ AC_CHECK_TYPES([ulong_t], [], [], [#include ]) AC_ARG_ENABLE( [versioned-doc], - AS_HELP_STRING([--enable-versioned-doc],[install docs in directory with version name (default)]), + AS_HELP_STRING([--enable-versioned-doc], + [install docs in directory with version name (default)]), [case "${enableval}" in yes) versioned_doc=yes ;; no) versioned_doc=no ;; @@ -337,7 +341,8 @@ fi AC_ARG_ENABLE( [doc], - AS_HELP_STRING([--enable-doc],[Enable building documents]), + AS_HELP_STRING([--enable-doc], + [Enable building documents]), [case "${enableval}" in yes) enabled_doc=yes ;; no) enabled_doc=no ;; @@ -347,7 +352,8 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [parport], - AS_HELP_STRING([--enable-parport],[Enable accessing parallel ports(default)]), + AS_HELP_STRING([--enable-parport], + [Enable accessing parallel ports(default)]), [case "${enableval}" in yes) enabled_parport=yes ;; no) enabled_parport=no ;; @@ -357,7 +363,8 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [linuxgpio], - AS_HELP_STRING([--enable-linuxgpio],[Enable the Linux sysfs GPIO interface programmer type]), + AS_HELP_STRING([--enable-linuxgpio], + [Enable the Linux sysfs GPIO interface programmer type]), [case "${enableval}" in yes) enabled_linuxgpio=yes ;; no) enabled_linuxgpio=no ;; @@ -367,7 +374,8 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [linuxspi], - AS_HELP_STRING([--enable-linuxspi],[Enable the Linux SPIDEV interface programmer type]), + AS_HELP_STRING([--enable-linuxspi], + [Enable the Linux SPIDEV interface programmer type]), [case "${enableval}" in yes) enabled_linuxspi=yes ;; no) enabled_linuxspi=no ;; @@ -488,13 +496,15 @@ if test "$GCC" = yes; then safe_CFLAGS=$CFLAGS CFLAGS="$ENABLE_WARNINGS -Wno-pointer-sign" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]])],[ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]]) + ], [dnl no_pointer_sign=yes - AC_MSG_RESULT([yes]) - ],[ + AC_MSG_RESULT([yes]) + ], [dnl no_pointer_sign=no - AC_MSG_RESULT([no]) - ]) + AC_MSG_RESULT([no]) + ]) CFLAGS=$safe_CFLAGS if test x$no_pointer_sign = xyes; then @@ -513,13 +523,15 @@ case $target in safe_CFLAGS="$CFLAGS" CFLAGS="$ENABLE_WARNINGS -mno-cygwin" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]])],[ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]]) + ], [dnl no_cygwin=yes AC_MSG_RESULT([yes]) - ],[ + ], [dnl no_cygwin=no AC_MSG_RESULT([no]) - ]) + ]) CFLAGS="$safe_CFLAGS" if test x$no_cygwin = xyes; then @@ -537,13 +549,15 @@ case $target in safe_LDFLAGS="$LDFLAGS" LDFLAGS="${LDFLAGS} -static" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]])],[ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[]], [[ int main () { return 0 ; } ]]) + ], [dnl can_link_static=yes AC_MSG_RESULT([yes]) - ],[ + ], [dnl can_link_static_cygwin=no AC_MSG_RESULT([no]) - ]) + ]) LDFLAGS="$safe_LDFLAGS" if test x$can_link_static = xyes; then From 84b649849cf6860228d6103b2c7255981a633a4e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 16:24:13 +0100 Subject: [PATCH 15/30] Require a certain baseline of tool versions Require a certain baseline of tool versions, in this case from around 2013 (autoconf 2.69 and automake 1.14). This is a significant advancement over the old requirement of autoconf 2.60 (from 2006) and no requirement on automake which gives us features without needing a very recent system. The exact versions to require might be up to debate. --- src/configure.ac | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 4ba197e7..6c671ca3 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -22,7 +22,20 @@ # Process this file with autoreconf to produce a configure script. -AC_PREREQ([2.71]) +dnl A few tool releases with release dates for orientation which tool +dnl requirements can make sense: +dnl +dnl 2019-03-14 cmake 3.13 +dnl +dnl 2006-10-23 autoconf 2.60 used to be avrdude's requirement +dnl 2012-04-24 autoconf 2.69 +dnl 2021-01-28 autoconf 2.71 +dnl +dnl 2013-06-20 automake 1.14 +dnl 2018-02-25 automake 1.16 +dnl 2018-03-11 automake 1.16.1 install-sh symlink fix + +AC_PREREQ([2.69]) AC_INIT([avrdude], [m4_esyscmd(./build-helpers/package-version . version-stamp)], [https://github.com/avrdudes/avrdude/issues]) @@ -36,7 +49,10 @@ AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE([foreign]) +AM_INIT_AUTOMAKE([ + 1.14 + foreign +]) # Check that the build-helpers/package-version script has worked properly. case "$PACKAGE_VERSION" in From 9b4a667fc26db8e0dbf0b47bab0a426bd3c1f04c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 16:26:16 +0100 Subject: [PATCH 16/30] Use newer AC_PROG_LEX invocation As our src/config.c defines a "yywrap" function, there is no need for AC_PROG_LEX to look for for a "yywrap" function in LEXLIBS. Therefore we add the "noyywrap" option to follow the more modern AC_PROG_LEX invocation. --- src/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configure.ac b/src/configure.ac index 6c671ca3..fb2f2691 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -78,7 +78,7 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_SED AC_PROG_YACC -AC_PROG_LEX +AC_PROG_LEX([noyywrap]) AN_MAKEVAR([AR], [AC_PROG_AR]) AN_PROGRAM([ar], [AC_PROG_AR]) AC_DEFUN([AC_PROG_AR], [AC_CHECK_TARGET_TOOL(AR, ar, :)]) From 5cbbf3185256f118a89fda67fc9776b08d07ba33 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 11 Feb 2024 04:40:35 +0100 Subject: [PATCH 17/30] Expand AC_PROG_AWK because we are using $(AWK) --- src/configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/src/configure.ac b/src/configure.ac index fb2f2691..744570f3 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -76,6 +76,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL +AC_PROG_AWK AC_PROG_SED AC_PROG_YACC AC_PROG_LEX([noyywrap]) From c076aa7f3b04ed70cefb966adf6c9de035a7b6a1 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 20:19:29 +0100 Subject: [PATCH 18/30] Consistently use x and quotes in test(1) calls --- src/configure.ac | 84 ++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 744570f3..08c9997e 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -123,7 +123,7 @@ AC_CHECK_LIB([readline], [readline]) AH_TEMPLATE([HAVE_LIBELF], [Define if ELF support is enabled via libelf]) AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes]) -if test x$have_libelf = xyes; then +if test "x$have_libelf" = xyes; then case $target in *) LIBELF="-lelf" @@ -139,7 +139,7 @@ AC_SEARCH_LIBS([setsockopt], [socket]) AH_TEMPLATE([HAVE_LIBUSB], [Define if USB support is enabled via libusb]) AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes]) -if test x$have_libusb = xyes; then +if test "x$have_libusb" = xyes; then case $target in *-*-darwin*) LIBUSB="-lusb -framework CoreFoundation -framework IOKit" @@ -168,7 +168,7 @@ AC_ARG_ENABLE( AH_TEMPLATE([HAVE_LIBUSB_1_0], [Define if USB support is enabled via libusb 1.0]) AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes]) -if test x$have_libusb_1_0 = xyes && test x$enabled_libusb_1_0 = xyes; then +if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then case $target in *-*-darwin*) LIBUSB_1_0="-lusb-1.0 -framework CoreFoundation -framework IOKit" @@ -184,7 +184,7 @@ fi AH_TEMPLATE([HAVE_LIBUSB_1_0], [Define if USB support is enabled via a libusb-1.0 compatible libusb]) AC_CHECK_LIB([usb], [libusb_init], [have_libusb_1_0=yes]) -if test x$have_libusb_1_0 = xyes && test x$enabled_libusb_1_0 = xyes; then +if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then case $target in *-*-freebsd*) # FreeBSD 8+ has a native libusb-1.0 API compatible @@ -206,7 +206,7 @@ AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0) AH_TEMPLATE([HAVE_LIBHIDAPI], [Define if HID support is enabled via libhidapi]) AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes]) -if test x$have_libhidapi = xyes; then +if test "x$have_libhidapi" = xyes; then case $target in *-*-darwin*) LIBHIDAPI="-lhidapi -iframework CoreFoundation -framework IOKit" @@ -223,7 +223,7 @@ AC_SUBST(LIBHIDAPI, $LIBHIDAPI) AH_TEMPLATE([HAVE_LIBSERIALPORT], [Define if libserialport is found]) AC_CHECK_LIB([serialport], [sp_open], [have_libserialport=yes]) -if test x$have_libserialport = xyes; then +if test "x$have_libserialport" = xyes; then case $target in *) LIBSERIALPORT="-lserialport" @@ -242,19 +242,19 @@ AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H], [Define if libftdi supports FT232H, libftdi version >= 0.20]) AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0]) AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb]) -if test x$have_libftdi1 = xyes; then +if test "x$have_libftdi1" = xyes; then LIBFTDI1="-lftdi1" AC_DEFINE([HAVE_LIBFTDI1]) AC_SUBST(LIBFTDI1, $LIBFTDI1) LIBS="${LIBS} ${LIBFTDI1}" AC_CHECK_FUNCS(ftdi_tcioflush) else - if test x$have_libftdi = xyes; then + if test "x$have_libftdi" = xyes; then LIBFTDI="-lftdi -lusb" AC_DEFINE([HAVE_LIBFTDI]) AC_SUBST(LIBFTDI, $LIBFTDI) AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include ]]) - if test x$have_libftdi_FT232H = xyes; then + if test "x$have_libftdi_FT232H" = xyes; then AC_DEFINE([HAVE_LIBFTDI_TYPE_232H]) fi fi @@ -262,7 +262,7 @@ fi AC_CHECK_HEADERS([pthread.h]) # as there exits header file only pthread implementations for Windows, check if we have a library AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes]) -if test x$have_pthread = xyes; then +if test "x$have_pthread" = xyes; then LIBPTHREAD="-lpthread" fi AC_SUBST(LIBPTHREAD, $LIBPTHREAD) @@ -283,7 +283,7 @@ Not all systems provide sys/time.h, but those that do, all allow you to include it and time.h simultaneously.])dnl AC_CHECK_HEADERS_ONCE([sys/time.h]) # Obsolete code to be removed. -if test $ac_cv_header_sys_time_h = yes; then +if test "x$ac_cv_header_sys_time_h" = xyes; then AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both and . This macro is obsolete.]) fi @@ -322,7 +322,7 @@ main(void) } ]])], [have_libhid=yes], [have_libhid=no]) AC_MSG_RESULT([$have_libhid]) -if test x$have_libhid = xyes; then +if test "x$have_libhid" = xyes; then AC_DEFINE([HAVE_LIBHID]) else LIBHID="" @@ -350,7 +350,7 @@ AC_ARG_ENABLE( esac], [versioned_doc=yes]) -if test "$versioned_doc" = "yes"; then +if test "x$versioned_doc" = "xyes"; then DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude-$(VERSION)' else DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude' @@ -402,7 +402,7 @@ AC_ARG_ENABLE( DIST_SUBDIRS_AC='doc' -if test "$enabled_doc" = "yes"; then +if test "x$enabled_doc" = xyes; then SUBDIRS_AC='doc' else SUBDIRS_AC='' @@ -453,9 +453,9 @@ case $target in ;; esac -if test "$enabled_parport" = "yes"; then +if test "x$enabled_parport" = xyes; then AC_MSG_CHECKING([for parallel device]) - if test "$DEFAULT_PAR_PORT" = "unknown"; then + if test "x$DEFAULT_PAR_PORT" = xunknown; then AC_MSG_NOTICE([parallel port access disabled for this system]) enabled_parport=no else @@ -468,7 +468,7 @@ AC_MSG_CHECKING([for serial device]) AC_MSG_RESULT([$DEFAULT_SER_PORT]) AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT) -if test "$enabled_parport" = "yes"; then +if test "x$enabled_parport" = xyes; then AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled]) confsubst="-e /^@HAVE_PARPORT_/d" else @@ -476,9 +476,9 @@ else fi -if test "$enabled_linuxgpio" = "yes"; then +if test "x$enabled_linuxgpio" = xyes; then AC_MSG_CHECKING([for default linuxgpio port]) - if test "$DEFAULT_LINUXGPIO_PORT" = "unknown"; then + if test "x$DEFAULT_LINUXGPIO_PORT" = xunknown; then AC_MSG_NOTICE([linuxgpio port access disabled for this system]) enabled_linuxgpio=no else @@ -487,7 +487,7 @@ if test "$enabled_linuxgpio" = "yes"; then AC_SUBST(DEFAULT_LINUXGPIO_PORT, $DEFAULT_LINUXGPIO_PORT) fi -if test "$enabled_linuxgpio" = "yes"; then +if test "x$enabled_linuxgpio" = xyes; then AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled]) confsubst="$confsubst -e /^@HAVE_LINUXGPIO_/d" else @@ -495,7 +495,7 @@ else fi -if test "$enabled_linuxspi" = "yes"; then +if test "x$enabled_linuxspi" = xyes; then AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled]) confsubst="$confsubst -e /^@HAVE_LINUXSPI_/d" else @@ -504,8 +504,8 @@ fi # If we are compiling with gcc, enable all warnings and make warnings errors. -if test "$GCC" = yes; then - ENABLE_WARNINGS="-Wall -Wextra -Wno-unused-parameter" +if test "x$GCC" = xyes; then + ENABLE_WARNINGS="-Wall -Wextra -Wno-unused-parameter" # does this compiler support -Wno-pointer-sign ? AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ]) @@ -524,7 +524,7 @@ if test "$GCC" = yes; then ]) CFLAGS=$safe_CFLAGS - if test x$no_pointer_sign = xyes; then + if test "x$no_pointer_sign" = xyes; then ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign" fi fi @@ -533,7 +533,7 @@ AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS) # See if we need to drop into the windows subdir. case $target in *-*-mingw32* | *-*-cygwin* | *-*-windows*) - if test "$GCC" = yes -a \( "$CC" = "cc" -o "$CC" = "gcc" \); then + if test "x$GCC" = xyes && test "x$CC" = xcc -o "x$CC" = xgcc; then # does this compiler support -mno-cygwin? AC_MSG_CHECKING([if $CC accepts -mno-cygwin]) @@ -551,7 +551,7 @@ case $target in ]) CFLAGS="$safe_CFLAGS" - if test x$no_cygwin = xyes; then + if test "x$no_cygwin" = xyes; then CFLAGS="${CFLAGS} -mno-cygwin" else AC_MSG_NOTICE([Your compiler does not understand the -mno-cygwin option.]) @@ -577,7 +577,7 @@ case $target in ]) LDFLAGS="$safe_LDFLAGS" - if test x$can_link_static = xyes; then + if test "x$can_link_static" = xyes; then LDFLAGS="${LDFLAGS} -static" fi @@ -617,20 +617,20 @@ echo "" echo "Configuration summary:" echo "----------------------" -if test x$have_libelf = xyes; then +if test "x$have_libelf" = xyes; then echo "DO HAVE libelf" else echo "DON'T HAVE libelf" fi -if test x$have_libusb = xyes; then +if test "x$have_libusb" = xyes; then echo "DO HAVE libusb" else echo "DON'T HAVE libusb" fi -if test x$have_libusb_1_0 = xyes; then - if test x$enabled_libusb_1_0 = xyes; then +if test "x$have_libusb_1_0" = xyes; then + if test "x$enabled_libusb_1_0" = xyes; then echo "DO HAVE libusb_1_0" else echo "DISABLED libusb_1_0" @@ -639,13 +639,13 @@ else echo "DON'T HAVE libusb_1_0" fi -if test x$have_libftdi1 = xyes; then +if test "x$have_libftdi1" = xyes; then echo "DO HAVE libftdi1" else echo "DON'T HAVE libftdi1" fi -if test x$have_libftdi = xyes; then +if test "x$have_libftdi" = xyes; then if test x$have_libftdi1 = xyes; then echo "DO HAVE libftdi (but prefer to use libftdi1)" else @@ -655,55 +655,55 @@ else echo "DON'T HAVE libftdi" fi -if test x$have_libhid = xyes; then +if test "x$have_libhid" = xyes; then echo "DO HAVE libhid" else echo "DON'T HAVE libhid" fi -if test x$have_libhidapi = xyes; then +if test "x$have_libhidapi" = xyes; then echo "DO HAVE libhidapi" else echo "DON'T HAVE libhidapi" fi -if test x$have_readline = xyes; then +if test "x$have_readline" = xyes; then echo "DO HAVE libreadline" else echo "DON'T HAVE libreadline" fi -if test x$have_libserialport = xyes; then +if test "x$have_libserialport" = xyes; then echo "DO HAVE libserialport" else echo "DON'T HAVE libserialport" fi -if test x$have_pthread = xyes; then +if test "x$have_pthread" = xyes; then echo "DO HAVE pthread" else echo "DON'T HAVE pthread" fi -if test x$enabled_doc = xyes; then +if test "x$enabled_doc" = xyes; then echo "ENABLED doc" else echo "DISABLED doc" fi -if test x$enabled_parport = xyes; then +if test "x$enabled_parport" = xyes; then echo "ENABLED parport" else echo "DISABLED parport" fi -if test x$enabled_linuxgpio = xyes; then +if test "x$enabled_linuxgpio" = xyes; then echo "ENABLED linuxgpio" else echo "DISABLED linuxgpio" fi -if test x$enabled_linuxspi = xyes; then +if test "x$enabled_linuxspi" = xyes; then echo "ENABLED linuxspi" else echo "DISABLED linuxspi" From d0a36e03b75f3f5ed302354fca481897f8397788 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 20:22:27 +0100 Subject: [PATCH 19/30] Fix accidentally inconsequential typo in variable name --- src/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configure.ac b/src/configure.ac index 08c9997e..11e51cd7 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -572,7 +572,7 @@ case $target in can_link_static=yes AC_MSG_RESULT([yes]) ], [dnl - can_link_static_cygwin=no + can_link_static=no AC_MSG_RESULT([no]) ]) LDFLAGS="$safe_LDFLAGS" From bccad9dfe6f701dfe6bafc39ee76ad4e3f095352 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 7 Feb 2024 20:27:20 +0100 Subject: [PATCH 20/30] Fix libreadline summary output AC_CHECK_LIB([readline], [readline]) without an ACTION-IF-FOUND results in the definition of the HAVE_LIBREADLINE C preprocessor macro and the addition of -lreadline to LIBS, not a configure script environment variable have_readline. So this repeats what the default ACTION-IF-FOUND does (add -lreadline to LIBS, AC_DEFINE the HAVE_LIBREADLINE macro), and in addition defines the have_libreadline variable as yes for later use inside configure.ac. --- src/configure.ac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 11e51cd7..57b853d6 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -119,7 +119,14 @@ AC_CHECK_LIB([ws2_32], [WSAStartup]) AC_CHECK_LIB([termcap], [tputs]) AC_CHECK_LIB([ncurses], [tputs]) -AC_CHECK_LIB([readline], [readline]) + +AC_CHECK_LIB([readline], [readline], [dnl + LIBS="-lreadline $LIBS" + AC_DEFINE([HAVE_LIBREADLINE], [1], + [Whether we have libreadline with the readline function]) + have_libreadline=yes +]) + AH_TEMPLATE([HAVE_LIBELF], [Define if ELF support is enabled via libelf]) AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes]) @@ -667,7 +674,7 @@ else echo "DON'T HAVE libhidapi" fi -if test "x$have_readline" = xyes; then +if test "x$have_libreadline" = xyes; then echo "DO HAVE libreadline" else echo "DON'T HAVE libreadline" From f8bb5619b8d22b892733420d1fbb83ce4b8a4cfc Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 8 Feb 2024 03:48:55 +0100 Subject: [PATCH 21/30] Use committer date for commit date and year Quoting CMakeLists.txt: "[...] of latest commit" "Latest commit" is better served by using the committer date %cd instead of the author date %ad: The author date could be some time last year with committer date being today. Note this affects both autotools and cmake buildsystems to keep the generated version message dates and year in sync. --- CMakeLists.txt | 4 ++-- src/build-helpers/package-version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 431eda87..071f50b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,14 +69,14 @@ if(Git_FOUND) ) execute_process( - COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y%m%d + COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=format:%Y%m%d WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_COMMIT_DATE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( - COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y + COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=format:%Y WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_COMMIT_YEAR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/src/build-helpers/package-version b/src/build-helpers/package-version index cc87d13e..beb5b36c 100755 --- a/src/build-helpers/package-version +++ b/src/build-helpers/package-version @@ -71,7 +71,7 @@ if test -d "$GIT_DIR"; then echo "version_error_71" | ${TR-tr} -d '\012'; \ exit 2; \ } - GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%ad --date=format:%Y%m%d)" || { \ + GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%cd --date=format:%Y%m%d)" || { \ echo "$prog: Error: Cannot run 'git log' for commit date" >&2; \ echo "version_error_72" | ${TR-tr} -d '\012'; \ exit 2; \ From 8d73b0521d40089f476da4aa7fe192be79a96447 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 9 Feb 2024 02:39:11 +0100 Subject: [PATCH 22/30] Remove unused TIME_WITH_SYS_TIME macro definition The TIME_WITH_SYS_TIME C preprocessor macro is not found anywhere in the source tree, so we do not need to define it after all and can get rid of the obsoletion warning. --- src/configure.ac | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 57b853d6..dfbb185a 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -282,19 +282,6 @@ AC_CHECK_HEADERS([ddk/hidsdi.h],,,[#include # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -m4_warn([obsolete], -[Update your code to rely only on HAVE_SYS_TIME_H, -then remove this warning and the obsolete code below it. -All current systems provide time.h; it need not be checked for. -Not all systems provide sys/time.h, but those that do, all allow -you to include it and time.h simultaneously.])dnl -AC_CHECK_HEADERS_ONCE([sys/time.h]) -# Obsolete code to be removed. -if test "x$ac_cv_header_sys_time_h" = xyes; then - AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both - and . This macro is obsolete.]) -fi -# End of obsolete code. AC_CHECK_HEADERS([netinet/in.h]) From 6f11b88bcd15b45621d31f4bbeb9c73ce68bd1df Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 11 Feb 2024 22:16:04 +0100 Subject: [PATCH 23/30] Stop checking for AM_SILENT_RULES macro There is no need to check for AM_SILENT_RULES. AM_SILENT_RULES was introduced in automake 1.11, and we require at least automake-1.14 now. --- src/configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/configure.ac b/src/configure.ac index dfbb185a..99b4c4fb 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -71,7 +71,8 @@ esac LT_INIT() -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +AM_SILENT_RULES([yes]) + # Checks for programs. AC_PROG_CC From 3ef9f7194aab49b1c61bcf4c0215e44a51c1a54f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 13 Feb 2024 13:38:44 +0100 Subject: [PATCH 24/30] Move AM_SILENT_RULES directly after AM_INIT_AUTOMAKE --- src/configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 99b4c4fb..6d0c2b9d 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -54,6 +54,9 @@ AM_INIT_AUTOMAKE([ foreign ]) +AM_SILENT_RULES([yes]) + + # Check that the build-helpers/package-version script has worked properly. case "$PACKAGE_VERSION" in devel|version_error_*) @@ -71,8 +74,6 @@ esac LT_INIT() -AM_SILENT_RULES([yes]) - # Checks for programs. AC_PROG_CC From dc88ff42adc69debd500f6e818cfbd7f65997bdf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 8 Feb 2024 01:36:45 +0100 Subject: [PATCH 25/30] Add AM_PROG_AR before LT_INIT, removing AC_PROG_AR etc Use AM_PROG_AR before LT_INIT to prevent occasional warnings. AM_PROG_AR was introduced in the 1.11 to 1.12 timeframe, and we require at least Automake 1.14. --- src/configure.ac | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 6d0c2b9d..4802c1d3 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -72,8 +72,6 @@ fixed. ;; esac -LT_INIT() - # Checks for programs. AC_PROG_CC @@ -82,10 +80,9 @@ AC_PROG_AWK AC_PROG_SED AC_PROG_YACC AC_PROG_LEX([noyywrap]) -AN_MAKEVAR([AR], [AC_PROG_AR]) -AN_PROGRAM([ar], [AC_PROG_AR]) -AC_DEFUN([AC_PROG_AR], [AC_CHECK_TARGET_TOOL(AR, ar, :)]) -AC_PROG_AR +AM_PROG_AR +LT_INIT() + AH_TEMPLATE([HAVE_YYLEX_DESTROY], [Define if lex/flex has yylex_destroy]) # flex should have this From 29695afebbc32686a7a1f93012afd48826f4e7aa Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 00:24:51 +0100 Subject: [PATCH 26/30] gitignore: dist tarballs and distdir/ itself --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c47a39dc..21bf3708 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,10 @@ ltmain.sh ylwrap tags cscope.out -/src/avrdude-[1-9].*.tar.* +/src/avrdude-[1-9].[0-9].tar.* +/src/avrdude-[1-9].[0-9]/ +/src/avrdude-[1-9].[0-9]-20[0-9][0-9][01][0-9][0-3][0-9].tar.* +/src/avrdude-[1-9].[0-9]-20[0-9][0-9][01][0-9][0-3][0-9]/ /src/GNUmakefile *.o From cc94578803bb4ea36516aba3c80d5b9ad45b1368 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 8 Feb 2024 03:53:01 +0100 Subject: [PATCH 27/30] Call it AVRDUDE_FULL_VERSION everywhere Calling AVRDUDE_FULL_VERSION just VERSION in parts of the build process, and AVRDUDE_FULL_VERSION in others, is unnecessarily confusing. So call it AVRDUDE_FULL_VERSION everywhere. --- src/cmake_config.h.in | 2 +- src/configure.ac | 5 ++++- src/main.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in index 88f6f39e..b8e9c250 100644 --- a/src/cmake_config.h.in +++ b/src/cmake_config.h.in @@ -20,7 +20,7 @@ #include "msvc/msvc_compat.h" #endif -#define VERSION "@AVRDUDE_FULL_VERSION@" +#define AVRDUDE_FULL_VERSION "@AVRDUDE_FULL_VERSION@" /* Options */ diff --git a/src/configure.ac b/src/configure.ac index 4802c1d3..029180bc 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -590,7 +590,10 @@ AC_CONFIG_FILES([ # Pass version number into avrdude.conf dnl AVRDUDE_FULL_VERSION="${PACKAGE_VERSION} (${GIT_COMMIT_HASH})" -AC_SUBST([AVRDUDE_FULL_VERSION], ["$PACKAGE_VERSION"]) +AVRDUDE_FULL_VERSION="$PACKAGE_VERSION" +AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"], + [The full avrdude version as displayed in -? and avrdude.conf]) +AC_SUBST([AVRDUDE_FULL_VERSION]) # The procedure to create avrdude.conf involves two steps. First, # normal autoconf substitution will be applied, resulting in diff --git a/src/main.c b/src/main.c index fb2b73ae..7debe44b 100644 --- a/src/main.c +++ b/src/main.c @@ -52,7 +52,7 @@ #include "developer_opts.h" /* Get VERSION from ac_cfg.h */ -char * version = VERSION; +char * version = AVRDUDE_FULL_VERSION; char * progname; char progbuf[PATH_MAX]; /* temporary buffer of spaces the same From dd9e4d2cf2104f2879f9da10c7b97b05b3f68217 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 12 Feb 2024 01:08:21 +0100 Subject: [PATCH 28/30] m4 quote macro args and set variable defaults This m4 quotes many more macro arguments and deals with the setting of variables. * Set variable default values to avoid accidental use of env var values from the caller of the configure script * rewrap some longer lines * Remove AC_SUBST([FOO], [$FOO]) type no-ops. AC_SUBST([FOO]) does the same. --- src/configure.ac | 91 +++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index 029180bc..1c07f575 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -129,6 +129,7 @@ AC_CHECK_LIB([readline], [readline], [dnl AH_TEMPLATE([HAVE_LIBELF], [Define if ELF support is enabled via libelf]) AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes]) +LIBELF="" if test "x$have_libelf" = xyes; then case $target in *) @@ -138,13 +139,14 @@ if test "x$have_libelf" = xyes; then AC_DEFINE([HAVE_LIBELF]) AC_CHECK_HEADERS([libelf.h libelf/libelf.h]) fi -AC_SUBST(LIBELF, $LIBELF) +AC_SUBST([LIBELF]) AC_SEARCH_LIBS([gethostent], [nsl]) AC_SEARCH_LIBS([setsockopt], [socket]) AH_TEMPLATE([HAVE_LIBUSB], [Define if USB support is enabled via libusb]) AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes]) +LIBUSB="" if test "x$have_libusb" = xyes; then case $target in *-*-darwin*) @@ -158,7 +160,7 @@ if test "x$have_libusb" = xyes; then AC_CHECK_HEADERS([usb.h]) AC_CHECK_HEADERS([lusb0_usb.h]) fi -AC_SUBST(LIBUSB, $LIBUSB) +AC_SUBST([LIBUSB]) AC_ARG_ENABLE( [libusb_1_0], @@ -167,13 +169,15 @@ AC_ARG_ENABLE( [case "${enableval}" in yes) enabled_libusb_1_0=yes ;; no) enabled_libusb_1_0=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for enable-libusb_1_0 option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for enable-libusb_1_0 option]) ;; esac], [enabled_libusb_1_0=yes]) +have_libusb_1_0=no AH_TEMPLATE([HAVE_LIBUSB_1_0], [Define if USB support is enabled via libusb 1.0]) AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes]) +LIBUSB_1_0="" if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then case $target in *-*-darwin*) @@ -207,11 +211,13 @@ if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then AC_DEFINE([HAVE_LIBUSB_1_0]) AC_CHECK_HEADERS([libusb.h]) fi -AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0) +AC_SUBST([LIBUSB_1_0]) AH_TEMPLATE([HAVE_LIBHIDAPI], [Define if HID support is enabled via libhidapi]) -AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes]) +AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], + [have_libhidapi=yes], [have_libhidapi=no]) +LIBHIDAPI="" if test "x$have_libhidapi" = xyes; then case $target in *-*-darwin*) @@ -224,11 +230,13 @@ if test "x$have_libhidapi" = xyes; then AC_DEFINE([HAVE_LIBHIDAPI]) AC_CHECK_HEADERS([hidapi/hidapi.h]) fi -AC_SUBST(LIBHIDAPI, $LIBHIDAPI) +AC_SUBST([LIBHIDAPI]) AH_TEMPLATE([HAVE_LIBSERIALPORT], [Define if libserialport is found]) -AC_CHECK_LIB([serialport], [sp_open], [have_libserialport=yes]) +AC_CHECK_LIB([serialport], [sp_open], + [have_libserialport=yes], [have_libserialport=no]) +LIBSERIALPORT="" if test "x$have_libserialport" = xyes; then case $target in *) @@ -238,7 +246,7 @@ if test "x$have_libserialport" = xyes; then AC_DEFINE([HAVE_LIBSERIALPORT]) AC_CHECK_HEADERS([libserialport.h]) fi -AC_SUBST(LIBSERIALPORT, $LIBSERIALPORT) +AC_SUBST([LIBSERIALPORT]) AH_TEMPLATE([HAVE_LIBFTDI1], [Define if FTDI support is enabled via libftdi1]) @@ -246,32 +254,42 @@ AH_TEMPLATE([HAVE_LIBFTDI], [Define if FTDI support is enabled via libftdi]) AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H], [Define if libftdi supports FT232H, libftdi version >= 0.20]) -AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0]) -AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb]) +AC_CHECK_LIB([ftdi1], [ftdi_new], + [have_libftdi1=yes], [have_libftdi1=no], [$LIBUSB_1_0]) +AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], + [have_libftdi=yes], [have_libftdi=no], [-lusb]) +LIBFTDI="" +LIBFTDI1="" if test "x$have_libftdi1" = xyes; then LIBFTDI1="-lftdi1" AC_DEFINE([HAVE_LIBFTDI1]) - AC_SUBST(LIBFTDI1, $LIBFTDI1) + AC_SUBST([LIBFTDI1]) LIBS="${LIBS} ${LIBFTDI1}" - AC_CHECK_FUNCS(ftdi_tcioflush) + AC_CHECK_FUNCS([ftdi_tcioflush]) else if test "x$have_libftdi" = xyes; then LIBFTDI="-lftdi -lusb" AC_DEFINE([HAVE_LIBFTDI]) - AC_SUBST(LIBFTDI, $LIBFTDI) - AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include ]]) + AC_SUBST([LIBFTDI]) + AC_CHECK_DECL([TYPE_232H], + [have_libftdi_FT232H=yes], + [have_libftdi_FT232H=no], + [[#include ]]) if test "x$have_libftdi_FT232H" = xyes; then AC_DEFINE([HAVE_LIBFTDI_TYPE_232H]) fi fi fi + AC_CHECK_HEADERS([pthread.h]) -# as there exits header file only pthread implementations for Windows, check if we have a library -AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes]) +# as there exist header file only pthread implementations for Windows, check if we have a library +AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes], [have_pthread=no]) +LIBPTHREAD="" if test "x$have_pthread" = xyes; then LIBPTHREAD="-lpthread" fi -AC_SUBST(LIBPTHREAD, $LIBPTHREAD) +AC_SUBST([LIBPTHREAD]) + # Checks for header files. AC_CHECK_HEADERS([limits.h stdlib.h string.h]) AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h]) @@ -290,6 +308,8 @@ AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strt AC_MSG_CHECKING([for a Win32 HID library]) SAVED_LIBS="${LIBS}" +LIBHID="" +HIDINCLUDE="" case $target in *-*-mingw32* | *-*-cygwin* | *-*-windows*) LIBHID="-lhid -lsetupapi" @@ -321,7 +341,7 @@ else LIBHID="" fi LIBS="${SAVED_LIBS}" -AC_SUBST(LIBHID, $LIBHID) +AC_SUBST([LIBHID]) # Check for types @@ -339,7 +359,7 @@ AC_ARG_ENABLE( [case "${enableval}" in yes) versioned_doc=yes ;; no) versioned_doc=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for versioned-doc option]) ;; esac], [versioned_doc=yes]) @@ -348,6 +368,7 @@ if test "x$versioned_doc" = "xyes"; then else DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude' fi +AC_SUBST([DOC_INST_DIR]) AC_ARG_ENABLE( [doc], @@ -356,7 +377,7 @@ AC_ARG_ENABLE( [case "${enableval}" in yes) enabled_doc=yes ;; no) enabled_doc=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for disable-doc option]) ;; esac], [enabled_doc=no]) @@ -367,10 +388,10 @@ AC_ARG_ENABLE( [case "${enableval}" in yes) enabled_parport=yes ;; no) enabled_parport=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for enable-parport option]) ;; esac], [enabled_parport=no]) - + AC_ARG_ENABLE( [linuxgpio], AS_HELP_STRING([--enable-linuxgpio], @@ -378,7 +399,7 @@ AC_ARG_ENABLE( [case "${enableval}" in yes) enabled_linuxgpio=yes ;; no) enabled_linuxgpio=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for enable-linuxgpio option]) ;; esac], [enabled_linuxgpio=no]) @@ -389,21 +410,18 @@ AC_ARG_ENABLE( [case "${enableval}" in yes) enabled_linuxspi=yes ;; no) enabled_linuxspi=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for enable-linuxspi option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for enable-linuxspi option]) ;; esac], [enabled_linuxspi=no]) -DIST_SUBDIRS_AC='doc' +AC_SUBST([DIST_SUBDIRS_AC], [doc]) if test "x$enabled_doc" = xyes; then SUBDIRS_AC='doc' else SUBDIRS_AC='' fi - -AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR) -AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC) -AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC) +AC_SUBST([SUBDIRS_AC]) # Find the parallel serial device files based on target system @@ -454,15 +472,15 @@ if test "x$enabled_parport" = xyes; then else AC_MSG_RESULT([$DEFAULT_PAR_PORT]) fi - AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT) + AC_SUBST([DEFAULT_PAR_PORT]) fi AC_MSG_CHECKING([for serial device]) AC_MSG_RESULT([$DEFAULT_SER_PORT]) -AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT) +AC_SUBST([DEFAULT_SER_PORT]) if test "x$enabled_parport" = xyes; then - AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled]) + AC_DEFINE([HAVE_PARPORT], [1], [parallel port access enabled]) confsubst="-e /^@HAVE_PARPORT_/d" else confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d" @@ -477,11 +495,11 @@ if test "x$enabled_linuxgpio" = xyes; then else AC_MSG_RESULT([$DEFAULT_LINUXGPIO_PORT]) fi - AC_SUBST(DEFAULT_LINUXGPIO_PORT, $DEFAULT_LINUXGPIO_PORT) + AC_SUBST([DEFAULT_LINUXGPIO_PORT]) fi if test "x$enabled_linuxgpio" = xyes; then - AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled]) + AC_DEFINE([HAVE_LINUXGPIO], [1], [Linux sysfs GPIO support enabled]) confsubst="$confsubst -e /^@HAVE_LINUXGPIO_/d" else confsubst="$confsubst -e /^@HAVE_LINUXGPIO_BEGIN@/,/^@HAVE_LINUXGPIO_END@/d" @@ -489,7 +507,7 @@ fi if test "x$enabled_linuxspi" = xyes; then - AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled]) + AC_DEFINE([HAVE_LINUXSPI], [1], [Linux SPI support enabled]) confsubst="$confsubst -e /^@HAVE_LINUXSPI_/d" else confsubst="$confsubst -e /^@HAVE_LINUXSPI_BEGIN@/,/^@HAVE_LINUXSPI_END@/d" @@ -497,6 +515,7 @@ fi # If we are compiling with gcc, enable all warnings and make warnings errors. +ENABLE_WARNINGS="" if test "x$GCC" = xyes; then ENABLE_WARNINGS="-Wall -Wextra -Wno-unused-parameter" @@ -521,7 +540,7 @@ if test "x$GCC" = xyes; then ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign" fi fi -AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS) +AC_SUBST([ENABLE_WARNINGS]) # See if we need to drop into the windows subdir. case $target in From a690c40e5b69a3750f89ba39f3b0d4669192a4c2 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 8 Feb 2024 04:00:28 +0100 Subject: [PATCH 29/30] 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. --- src/GNUmakefile.in | 20 +-- src/Makefile.am | 4 +- src/build-helpers/package-version | 102 -------------- src/build-helpers/package-version.mk | 26 ---- src/build-helpers/versioninfo.m4 | 73 ++++++++++ src/build-helpers/versioninfo.md | 190 +++++++++++++++++++++++++++ src/build-helpers/versioninfo.mk | 31 +++++ src/build-helpers/versioninfo.sh | 118 +++++++++++++++++ src/configure.ac | 50 ++++--- 9 files changed, 454 insertions(+), 160 deletions(-) delete mode 100755 src/build-helpers/package-version delete mode 100644 src/build-helpers/package-version.mk create mode 100644 src/build-helpers/versioninfo.m4 create mode 100644 src/build-helpers/versioninfo.md create mode 100644 src/build-helpers/versioninfo.mk create mode 100755 src/build-helpers/versioninfo.sh diff --git a/src/GNUmakefile.in b/src/GNUmakefile.in index 760ec926..f7c0c937 100644 --- a/src/GNUmakefile.in +++ b/src/GNUmakefile.in @@ -1,15 +1,15 @@ -# Helps update the version number automatically if using GNU make. +# @configure_input@ + include Makefile -AUTORECONF ?= autoreconf -AUTORECONF_OPTS ?= -vis - -script_version := $(shell $(top_srcdir)/build-helpers/package-version $(top_srcdir) version-stamp) -ifneq ($(PACKAGE_VERSION),$(script_version)) -$(info autoconf and script versions do not match: $(PACKAGE_VERSION) vs $(script_version)) -$(info Removing autom4te.cache and related files and re-running autoreconf) -dummy1 := $(shell rm -rf $(top_srcdir)/autom4te.cache) -dummy2 := $(shell $(AUTORECONF) $(AUTORECONF_OPTS) $(top_srcdir)) +need_to_rerun := $(shell $(top_srcdir)/build-helpers/versioninfo.sh "$(top_srcdir)" "@VERSIONINFO_STAMPFILE@" | { @VERSIONINFO_READ@; \ + if @VERSIONINFO_IS_UNCHANGED@ \ + echo "no"; \ + fi; } ) +ifneq (no,$(need_to_rerun)) +$(info Recorded and current version information do not match.) +$(info Re-running autoreconf via bootstrap.) +dummy1 := $(shell $(top_srcdir)/bootstrap) endif # vim: syntax=make diff --git a/src/Makefile.am b/src/Makefile.am index 8863291a..a4869cad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,7 +40,7 @@ CLEANFILES = \ config_gram.h \ lexer.c -include build-helpers/package-version.mk +include build-helpers/versioninfo.mk BUILT_SOURCES = $(CLEANFILES) @@ -248,4 +248,4 @@ backup-avrdude-conf: ${DESTDIR}${sysconfdir}/avrdude.conf.bak; \ fi -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I build-helpers diff --git a/src/build-helpers/package-version b/src/build-helpers/package-version deleted file mode 100755 index beb5b36c..00000000 --- a/src/build-helpers/package-version +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -# Syntax: -# $0 -# -# may be relative -# is relative to the dist top_srcdir -# -# Test this script by running -# rm -rf autom4te.cache/ && autoreconf -vis . && sed -n "/^# Generated by GNU/p" configure -# -# If we run into an error, we cannot abort the "autoreconf" run by -# exiting with a non-0 error code. (We do exit non-0 in that case -# anyway for help when testing this script.) -# The only thing we can do to report an error is to write to stderr -# which appears as "autoreconf" output, and to write a version number -# to stdout which indicates an error. The "configure" script can -# then check whether $PACKAGE_VERSION indicates such an error. - -# Parse the command line arguments -prog="$(basename "$0")" -top_srcdir="${1-.}" -test -d "$top_srcdir" || { \ - echo "$prog: Error: Could not change to top_srcdir '$1'" >&2; \ - echo "version_error_1" | ${TR-tr} -d '\012' - exit 2; \ -} -version_stamp="${2-version-stamp}" - -# echo "$prog: Error: Some error happend." >&2 -# echo "version_error_2" | ${TR-tr} -d '\012' -# exit 2 - -# Is this a dist source tree? -# If so, use the version number from the version_stamp file. -if test -f "$top_srcdir/$version_stamp"; then - cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012' - exit -fi - -# Is this part of a git checkout or an expanded github snapshot tarball? -test -f "$top_srcdir/../CMakeLists.txt" || { \ - echo "$prog: Error: top-level avrdude CMakeLists.txt file not found" >&2; \ - echo "version_error_3" | ${TR-tr} -d '\012' - exit 2; \ -} - -if PROJECT_VERSION="$(${SED-sed} -n 's/project(avrdude[[:space:]]\{1,\}VERSION[[:space:]]\{1,\}\([0-9\.]\{1,\}\)[[:space:]]\{1,\}.*/\1/p' "$top_srcdir/../CMakeLists.txt")"; then - : -else - echo "$prog: Error parsing top-level avrdude 'CMakeLists.txt'." >&2 - echo "version_error_4" | ${TR-tr} -d '\012' - exit 2 -fi - -test -n "$PROJECT_VERSION" || { \ - echo "$prog: Error: Could not find project(...) in top-level avrdude 'CMakeLists.txt'" >&2; \ - echo "version_error_5" | ${TR-tr} -d '\012' - exit 2; \ -} - -# If GIT_DIR is set, use it. If not, try "$top_srcdir/../.git". -test -n "$GIT_DIR" || { \ - GIT_DIR="$top_srcdir/../.git"; \ - export GIT_DIR; \ -} - -# Working with a git source tree -if test -d "$GIT_DIR"; then - GIT_COMMIT_HASH="$(${GIT-git} log -1 --format=%h)" || { \ - echo "$prog: Error: Cannot run 'git log' for commit hash" >&2; \ - echo "version_error_71" | ${TR-tr} -d '\012'; \ - exit 2; \ - } - GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%cd --date=format:%Y%m%d)" || { \ - echo "$prog: Error: Cannot run 'git log' for commit date" >&2; \ - echo "version_error_72" | ${TR-tr} -d '\012'; \ - exit 2; \ - } - GIT_TAG_HASH="$(${GIT-git} log -1 --tags --format=%h)" || { \ - echo "$prog: Error: Cannot run 'git log' for tag hash" >&2; \ - echo "version_error_73" | ${TR-tr} -d '\012'; \ - exit 2; \ - } - if test "x$GIT_COMMIT_HASH" = "x$GIT_TAG_HASH"; then - echo "${PROJECT_VERSION}" | ${TR-tr} -d '\012' - exit - else - echo "${PROJECT_VERSION}-${GIT_COMMIT_DATE}" | ${TR-tr} -d '\012' - exit - fi -else - # Building 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? - echo "${PROJECT_VERSION}" | ${TR-tr} -d '\012' - exit -fi - -# If everything else has failed, call this version "devel" -echo "devel" | ${TR-tr} -d '\012' -exit 2 diff --git a/src/build-helpers/package-version.mk b/src/build-helpers/package-version.mk deleted file mode 100644 index 01502dfd..00000000 --- a/src/build-helpers/package-version.mk +++ /dev/null @@ -1,26 +0,0 @@ -BUILD_SCRIPT_DIR = build-helpers - -# Check that package version matches git version before creating dist tarballs -dist-hook: cur-version-check cur-version-stamp -distcheck-hook: cur-version-check - -# Note: We cannot run autoreconf from here, because we would need some way to -# restart the whole dist process from the start and there is none. -EXTRA_DIST += $(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version -cur-version-check: - @cur_ver=`$(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version $(top_srcdir) version-stamp`; \ - if test "x$${cur_ver}" = "x$(PACKAGE_VERSION)"; then :; else \ - echo "ERROR: Recorded PACKAGE_VERSION and current version do not match:"; \ - echo " current version: $${cur_ver}"; \ - echo " recorded PACKAGE_VERSION: $(PACKAGE_VERSION)"; \ - rm -rf "$(top_srcdir)/autom4te.cache"; \ - echo "Update PACKAGE_VERSION by running autoreconf(1)."; \ - exit 1; \ - fi - -# Version stamp files can only exist in tarball source trees. -# -# So there is no need to generate them anywhere else or to clean them -# up anywhere. -cur-version-stamp: - echo "$(PACKAGE_VERSION)" > "$(distdir)/version-stamp" diff --git a/src/build-helpers/versioninfo.m4 b/src/build-helpers/versioninfo.m4 new file mode 100644 index 00000000..30e36d6e --- /dev/null +++ b/src/build-helpers/versioninfo.m4 @@ -0,0 +1,73 @@ +# versioninfo.m4 - find avrdude version information for msg -*- Autoconf -*- +# serial 1 +dnl | Increment the above serial number every time you edit this file. +dnl | When it finds multiple m4 files with the same name, +dnl | aclocal will use the one with the highest serial. +dnl +dnl The sequence of version info items to store in the version-stamp file. +dnl This must be the same sequence as the versioninfo script writes. +m4_pattern_forbid([versioninfo_items]) +m4_define([versioninfo_items], [ + [CMAKE_PROJECT_VERSION], + [GIT_COMMIT_DATE], + [GIT_COMMIT_HASH], + [GIT_TAG_HASH] +]) +dnl +dnl Initialize version info from the script command given as macro argument. +m4_pattern_forbid([versioninfo_init]) +m4_define([versioninfo_init], [ + m4_pushdef([versioninfo_split], m4_split(m4_esyscmd($1),m4_newline)) + m4_case(m4_sysval, [0], [ + m4_for([N], [1], m4_count(versioninfo_split), [1], [ + m4_define([versioninfo_]m4_normalize(m4_argn(N, versioninfo_items)), + m4_normalize(m4_argn(N, versioninfo_split))) + ]) + ], [ + m4_fatal([versioninfo script returned non-0]) + ]) +]) +dnl +m4_define([versioninfo_stampfile], [versioninfo-stamp]) +dnl +versioninfo_init([./build-helpers/versioninfo.sh . ]m4_defn([versioninfo_stampfile])) +dnl +dnl +dnl +dnl ======================================================================== +dnl VERSIONINFO_SETUP() +dnl ======================================================================== +dnl +AC_DEFUN([VERSIONINFO_SETUP], [dnl +m4_foreach([ITEM], [versioninfo_items], [dnl + AC_SUBST(m4_normalize(ITEM), [m4_defn([versioninfo_]m4_normalize(ITEM))]) + AC_MSG_CHECKING([versioninfo item ]m4_normalize(ITEM)) + AC_MSG_RESULT([$]m4_normalize(ITEM)) +]) +dnl +dnl Define helper substitutions containing shell code for use inside +dnl make recipes in build-helpers/versioninfo.mk and $(shell ...) +dnl calls in GNUmakefile.in dealing with version info. +dnl +AC_SUBST([VERSIONINFO_STAMPFILE], [m4_defn([versioninfo_stampfile])]) +AM_SUBST_NOTMAKE([VERSIONINFO_WRITE]) +dnl +AC_SUBST([VERSIONINFO_READ], + ['m4_foreach([ITEM], [versioninfo_items], [read m4_normalize(ITEM); ]):']) +AM_SUBST_NOTMAKE([VERSIONINFO_READ]) +dnl +AC_SUBST([VERSIONINFO_WRITE], + ['printf "%s\n"m4_foreach([ITEM], [versioninfo_items], [ "$(m4_normalize(ITEM))"])']) +AM_SUBST_NOTMAKE([VERSIONINFO_WRITE]) +dnl +AC_SUBST([VERSIONINFO_IS_UNCHANGED], + ['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 ']) +AM_SUBST_NOTMAKE([VERSIONINFO_IS_UNCHANGED]) +dnl +])dnl +dnl +dnl #################################################################### +dnl +dnl Local Variables: +dnl mode: autoconf +dnl End: diff --git a/src/build-helpers/versioninfo.md b/src/build-helpers/versioninfo.md new file mode 100644 index 00000000..2e3ae9f7 --- /dev/null +++ b/src/build-helpers/versioninfo.md @@ -0,0 +1,190 @@ +The versioninfo mechanism +========================= + +This describes the versioninfo mechanism which automatically generates +the version information for use in `configure.ac` and then the rest of +the autotools build system. + + +The basic idea +-------------- + +The main goals are + + * Avoid the need for avrdude maintainers to edit the avrdude version + in the autotools buildsystem's `configure.ac` in addition to the + cmake buildsystem's main `CMakeLists.txt` file. + + * Have the autotools buildsystem generate the same version message as + the cmake buildsystem in both the `avrdude.conf` file and the + `avrdude -?` output version message. + +To achieve this, we need to replicate some of the logic from the +top-level `CMakeLists.txt` which creates the `AVRDUDE_FULL_VERSION` +variable. + +We run this logic mostly at bootstrap/autoreconf time, with the +`configure` propagating the information, so that some `make` time +checks can determine whether the bootstrap code needs to be re-run, +and re-run it automatically if possible. + + +All the different build types +----------------------------- + +There are many ways to build avrdude. + +There are three types of source trees: + + * a git clone's working directory with a `.git/` directory + + * an extracted GitHub tarball/zipfile (contains the same as a git + clone's working directory, but no `.git/` directory with its + associated git commit information) + + * from a dist tarball as generated by the autotools buildsystem's + `make dist` or `make distcheck` commands (contains the required + git commit information inside the versioninfo-stamp file) + +In any of these cases, this can be an avrdude release or non-release, +determined by whether the latest commit's hash is equal to the latest +tag's commit's hash (`GIT_COMMIT_HASH == GIT_TAG_HASH`). + +In principle, any of these source types could be built with either the +cmake buildsystem or the autotools buildsystem. With `configure.ac` +being rooted in the `src/` subdirectory though, the dist tarball +generated by `make dist` cannot contain files outside of `src/` which +are required for a cmake build. + +In all types of builds, we want the same version message when building +using the autotools buildsystem as the cmake buildsystem creates: + + * `7.3` for a release + * `7.3-20240213 (9634fd15)` with commit date and commit hash for a + non-release. + +If we abbreviate those types of version messages with `R` for release +and `H` for hash, we can put all cases into a table. `BS` stands for +buildsystem, obviously. + +``` + Version_Message +SOURCE TYPE BS Release? Wanted Actual +git clone wd cm yes R R +git clone wd cm no H H +github tarball cm yes R R +github tarball cm no H R (wrong/missing info) +dist tarball cm yes R cmake build N/A at this time +dist tarball cm no H cmake build N/A at this time + +git clone wd am yes R R +git clone wd am no H H +github tarball am yes R R +github tarball am no H R (wrong/missing info/like cmake) +dist tarball am yes R R +dist tarball am no H H +``` + +As the github tarball (like the github zipfile) does not contain any +commit/tag information, it is impossible for any buildsystem to +determine whether building a release or non-release. + +The dist tarball generated by the autotools buildsystem's `make dist` +does contain the commit/tag information, so builds from such a dist +tarball can correctly determine whether they are building a release or +a non-release source tree. However, only builds using the autotools +buildsystem are possible as long as the `configure.ac` file is located +inside the `src/` subdirectory instead of the top-level directory. + + +The `build-helpers/versioninfo.sh` script file +---------------------------------------------- + +The `versioninfo.sh` script tries to determine the version and git +information from the raw sources: + + * The version number (`7.3`) is determined from the top-level + `CMakeLists.txt` file's `project(... VERSION ...)` line. + + * The information on the latest git commit date and hash and git tag + hash is determined from the `.git/` subdirectory corresponding to + the top-level `CMakeLIsts.txt` file. + +The `versioninfo.sh` script then prints these items, one per line. + + +The `build-helpers/versioninfo.m4` m4 include file +-------------------------------------------------- + +This defines the two parts of the m4 code: + + * The m4 code which calls `versioninfo.sh`, parses its output, and + defines some m4 macros before `AC_INIT`: + + * The `versioninfo_items` macro describes the sequence of + versioninfo items printed in lines by the `versioninfo.sh` + script + + * The `versioninfo_init` macro runs the `versioninfo.sh` script + and parses its output, `m4_define`ing a `versioninfo_` + macro for each `ITEM` from `versioninfo_items` + + * The `versioninfo_stampfile` macro contains the name of the + stamp file which caches the versioninfo items for use in + tarballs. + + * The `versioninfo_init` macro is evaluated once, so that + `versioninfo.sh` is only run once as well. + + The m4 macros with the parsed results can then be evaluated using + `m4_defn(...)` both in the `AC_INIT(...)` invocation for the + `PACKAGE_VERSION`, and also later for defining + `AVRDUDE_FULL_VERSION` and git commit information. + + * The m4 code `AC_DEFUN`s the `VERSIONINFO_SETUP` macro, which in + turn defines `AC_SUBST` substitution and make variables for each + of the versioninfo items, and also defines a few + stubstitution-only (not make) variables for use in make rules in + `versioninfo.mk` and `GNUmakefile.in`, which write, read, parse, + and compare the versioninfo items as defined in + `versioninfo_items`. + + +The `build-helpers/versioninfo.mk` Makefile include file +-------------------------------------------------------- + +To be `include`d into the top-level `Makefile.am`, this does two things: + + * Hooks into the `dist` and `distcheck` targets to check the + recorded version information is the same one `versioninfo.sh` + would detect right now, and prevents builds with out of date + versioninfo items. + + * Writes the stamp file with the versioninfo data when creating a + dist tarball. + + +The `configure.ac` file +----------------------- + +Before `AC_INIT`, uses m4 logic to evaluate what the `PACKAGE_VERSION` +should be. + +Expands the `VERSIONINFO_SETUP` macro both to run its content and to +force `aclocal` to pull in `versioninfo.m4` into `aclocal.m4` so that +the m4 code from `versioninfo.m4` is evaluated before `AC_INIT`. + +Evaluates the `AVRDUDE_FULL_VERSION` message and adds it as both a C +preprocessor macro and a autoconf substitution and make variable. + + +The `GNUmakefile.in` and `GNUmakefile` files +-------------------------------------------- + +If you are running GNU make, the `GNUmakefile` file generated from the +`GNUmakefile.in` file will update the versioninfo automatically before +executing any possible make recipes. + +If you are not running GNU make, you will need to run the command to +update the versioninfo update command manually. You will be shown that +command if necessary. diff --git a/src/build-helpers/versioninfo.mk b/src/build-helpers/versioninfo.mk new file mode 100644 index 00000000..7978bc2e --- /dev/null +++ b/src/build-helpers/versioninfo.mk @@ -0,0 +1,31 @@ +# -*- makefile-automake -*- + +EXTRA_DIST += build-helpers/versioninfo.m4 +EXTRA_DIST += build-helpers/versioninfo.md +EXTRA_DIST += build-helpers/versioninfo.sh + +# Before creating dist tarballs, check that autom4te version matches +# versioninfo script version. +dist-hook: versioninfo-check versioninfo-stamp +distcheck-hook: versioninfo-check + +# Note: We cannot run autoreconf from this make recipe, because we would +# need some way to restart the whole dist process from the start +# and there is none. +versioninfo-check: + @:; \ + $(top_srcdir)/build-helpers/versioninfo.sh "$(top_srcdir)" "@VERSIONINFO_STAMPFILE@" \ + | ( @VERSIONINFO_READ@; \ + if @VERSIONINFO_IS_UNCHANGED@ \ + exit 0; \ + fi; \ + rm -rf "$(top_srcdir)/autom4te.cache"; \ + echo "Update the recorded version information by re-running bootstrap/autoreconf(1)."; \ + exit 1; ) + +# Version stamp files can only exist in tarball source trees. +# +# So there is no need to generate them anywhere else or to clean them +# up anywhere. +versioninfo-stamp: + @VERSIONINFO_WRITE@ > "$(distdir)/versioninfo-stamp" diff --git a/src/build-helpers/versioninfo.sh b/src/build-helpers/versioninfo.sh new file mode 100755 index 00000000..58ebc9c6 --- /dev/null +++ b/src/build-helpers/versioninfo.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# Syntax: +# $0 +# +# may be relative +# is relative to the dist top_srcdir +# +# Test this script by running something like +# rm -rf autom4te.cache/ && autoreconf -vis . && sed -n "/^# Generated by GNU/p" configure +# +# On error handling +# ----------------- +# +# If we run into an error, we write an error message to stderr and exit +# with a non-0 code. The caller can then check the exit code, and the +# user can read the message from stderr. + + +# Parse the command line arguments +prog="$(basename "$0")" +top_srcdir="${1-.}" +versioninfo_stamp="${2-versioninfo-stamp}" + + +# global settings +verbose=false + + +# Usage example: +# ret_error "Something is wrong: answer != 42" +ret_error() { + printf "$prog: error: %s\n" "$1" >&2 + exit 1 +} + + +# Usage examples: +# ret_ok "7.3" +# ret_ok "7.3" "20231231" +# ret_ok "7.3" "20231231" "0123abcd" +# ret_ok "7.3" "20231231" "0123abcd" "4567cdef" +ret_ok() { + if $verbose; then + printf "$prog: version info from cmake/git: %s\n" "$*" >&2 + fi + printf "%s\n" "$@" + exit 0 +} + + +# Usage example: +# ret_ok_file "$top_srcdir/$versioninfo_stamp" +ret_ok_file() { + if $verbose; then + printf "$prog: version information from file: %s\n" "$1" >&2 + fi + cat "$1" + exit 0 +} + + +# Uncomment the following line to help debug the error case +# ret_error "Some error happened for testing purposes" + + +test -d "$top_srcdir" || \ + ret_error "Could not change to top_srcdir '$1'" + + +# If this is a "make dist" source tree, use info from versioninfo_stamp file. +if test -f "$top_srcdir/$versioninfo_stamp"; then + ret_ok_file "$top_srcdir/$versioninfo_stamp" +fi + + +# This must be part of a git checkout or an expanded github snapshot tarball. +test -f "$top_srcdir/../CMakeLists.txt" || \ + ret_error "top-level avrdude CMakeLists.txt file not found" + + +# Find and parse "project(...)" line in top-level CmakeLists.txt file +if PROJECT_VERSION="$(${SED-sed} -n 's/project(avrdude[[:space:]]\{1,\}VERSION[[:space:]]\{1,\}\([0-9\.]\{1,\}\)[[:space:]]\{1,\}.*/\1/p' "$top_srcdir/../CMakeLists.txt")"; then + : +else + ret_error "Error parsing top-level avrdude 'CMakeLists.txt'." +fi + +test -n "$PROJECT_VERSION" || \ + ret_error "Cannot find project(...) in top-level avrdude 'CMakeLists.txt'" + + +# If GIT_DIR is set, use it. If not, try "$top_srcdir/../.git". +test -n "$GIT_DIR" || { \ + GIT_DIR="$top_srcdir/../.git"; \ + export GIT_DIR; \ +} + + +# If working with a git source tree, determine git information +if test -d "$GIT_DIR" && ${GIT-git} --version > /dev/null 2>&1; then + GIT_COMMIT_HASH="$(${GIT-git} log -1 --format=%h)" || \ + ret_error "$prog: Cannot run 'git log' for commit hash" + GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%cd --date=format:%Y%m%d)" || \ + ret_error "$prog: Error: Cannot run 'git log' for commit date" + GIT_TAG_HASH="$(${GIT-git} log -1 --tags --format=%h)" || \ + 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}" \ + "${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}" +fi + + +# This code should never be reached. +ret_error "$prog: This code should never be reached." diff --git a/src/configure.ac b/src/configure.ac index 1c07f575..42bb8d3c 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -35,14 +35,24 @@ dnl 2013-06-20 automake 1.14 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. +m4_define([versioninfo_AVRDUDE_PACKAGE_VERSION], + m4_case(m4_defn([versioninfo_GIT_COMMIT_HASH]), + m4_defn([versioninfo_GIT_TAG_HASH]), + m4_defn([versioninfo_CMAKE_PROJECT_VERSION]), + m4_defn([versioninfo_CMAKE_PROJECT_VERSION])-m4_defn([versioninfo_GIT_COMMIT_DATE]))) + AC_PREREQ([2.69]) AC_INIT([avrdude], - [m4_esyscmd(./build-helpers/package-version . version-stamp)], + m4_defn([versioninfo_AVRDUDE_PACKAGE_VERSION]), [https://github.com/avrdudes/avrdude/issues]) AC_CONFIG_SRCDIR([main.c]) -AC_CONFIG_HEADERS([ac_cfg.h]) AC_CONFIG_AUX_DIR([auto-aux]) +AC_CONFIG_HEADERS([ac_cfg.h]) AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_BUILD @@ -52,25 +62,31 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([ 1.14 foreign + subdir-objects ]) AM_SILENT_RULES([yes]) -# Check that the build-helpers/package-version script has worked properly. -case "$PACKAGE_VERSION" in - devel|version_error_*) - AC_MSG_ERROR([ -Autogenerating the package version (${PACKAGE_VERSION}) has failed. +VERSIONINFO_SETUP() -Please file an issue at ${PACKAGE_BUGREPORT} +dnl Inform about the derived PACKAGE_VERSION +AC_MSG_CHECKING([versioninfo derived PACKAGE_VERSION]) +AC_MSG_RESULT([$PACKAGE_VERSION]) -You can write some version number to the file version-stamp as a -workaround to allow building avrdude until the filed issue has been -fixed. -]) - ;; -esac +dnl Compose the full version message mirroring the cmake one, inform +dnl about it and pass it on to avrdude.conf and the "avrdude -?" +dnl version message +AC_MSG_CHECKING([versioninfo derived AVRDUDE_FULL_VERSION]) +if test "x$GIT_COMMIT_HASH" = "x$GIT_TAG_HASH"; then + AVRDUDE_FULL_VERSION="$PACKAGE_VERSION" +else + AVRDUDE_FULL_VERSION="$PACKAGE_VERSION ($GIT_COMMIT_HASH)" +fi +AC_MSG_RESULT([$AVRDUDE_FULL_VERSION]) +AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"], + [The full avrdude version as displayed in -? and avrdude.conf]) +AC_SUBST([AVRDUDE_FULL_VERSION]) # Checks for programs. @@ -607,12 +623,6 @@ AC_CONFIG_FILES([ GNUmakefile ]) -# Pass version number into avrdude.conf -dnl AVRDUDE_FULL_VERSION="${PACKAGE_VERSION} (${GIT_COMMIT_HASH})" -AVRDUDE_FULL_VERSION="$PACKAGE_VERSION" -AC_DEFINE_UNQUOTED([AVRDUDE_FULL_VERSION], ["$AVRDUDE_FULL_VERSION"], - [The full avrdude version as displayed in -? and avrdude.conf]) -AC_SUBST([AVRDUDE_FULL_VERSION]) # The procedure to create avrdude.conf involves two steps. First, # normal autoconf substitution will be applied, resulting in From 8553d37c374d94cd91d8506e807c17a2ab2cb6a7 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 19 Feb 2024 04:05:20 +0100 Subject: [PATCH 30/30] Move auto-added m4 files to auto-m4/ subdir Have the autotools place their m4 files into the auto-m4/ subdir to separate them from our own m4 files. Not using AC_CONFIG_MACRO_DIRS for backwards compatibility. --- src/Makefile.am | 2 +- src/auto-m4/.gitignore | 2 ++ src/configure.ac | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/auto-m4/.gitignore diff --git a/src/Makefile.am b/src/Makefile.am index a4869cad..73142d66 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -248,4 +248,4 @@ backup-avrdude-conf: ${DESTDIR}${sysconfdir}/avrdude.conf.bak; \ fi -ACLOCAL_AMFLAGS = -I m4 -I build-helpers +ACLOCAL_AMFLAGS = -I auto-m4 -I build-helpers diff --git a/src/auto-m4/.gitignore b/src/auto-m4/.gitignore new file mode 100644 index 00000000..c2b7208b --- /dev/null +++ b/src/auto-m4/.gitignore @@ -0,0 +1,2 @@ +# Ensure creation of empty directory for autotools to place files into +* diff --git a/src/configure.ac b/src/configure.ac index 42bb8d3c..4b680927 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -53,7 +53,7 @@ AC_INIT([avrdude], AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_AUX_DIR([auto-aux]) AC_CONFIG_HEADERS([ac_cfg.h]) -AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_MACRO_DIR([auto-m4]) AC_CANONICAL_BUILD AC_CANONICAL_HOST