diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b1dfdb94..38120150e 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: diff --git a/.gitignore b/.gitignore index c47a39dc8..21bf37087 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 431eda87d..071f50b27 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/GNUmakefile.in b/src/GNUmakefile.in index 760ec9268..f7c0c9370 100644 --- a/src/GNUmakefile.in +++ b/src/GNUmakefile.in @@ -1,15 +1,15 @@ -# Helps update the version number automatically if using GNU make. -include Makefile +# @configure_input@ -AUTORECONF ?= autoreconf -AUTORECONF_OPTS ?= -vis +include Makefile -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 8863291a9..73142d66c 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 auto-m4 -I build-helpers diff --git a/src/auto-aux/.gitignore b/src/auto-aux/.gitignore new file mode 100644 index 000000000..cf0fcab4a --- /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/auto-m4/.gitignore b/src/auto-m4/.gitignore new file mode 100644 index 000000000..c2b7208bc --- /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/autotools-build.sh b/src/autotools-build.sh new file mode 100755 index 000000000..e1843cb61 --- /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 diff --git a/src/bootstrap b/src/bootstrap index 207dc4c20..19d4bb644 100755 --- a/src/bootstrap +++ b/src/bootstrap @@ -1,5 +1,8 @@ #! /bin/sh +cd "$(dirname "$0")" + +: ${AUTORECONF="autoreconf${AC_VER}"} : ${AUTOHEADER="autoheader${AC_VER}"} : ${AUTOCONF="autoconf${AC_VER}"} : ${ACLOCAL="aclocal${AM_VER}"} @@ -17,9 +20,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/build-helpers/package-version b/src/build-helpers/package-version deleted file mode 100755 index cc87d13ee..000000000 --- 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=%ad --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 01502dfd5..000000000 --- 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 000000000..30e36d6e9 --- /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 000000000..2e3ae9f71 --- /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 000000000..7978bc2ec --- /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 000000000..58ebc9c6d --- /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/cmake_config.h.in b/src/cmake_config.h.in index 88f6f39e8..b8e9c2504 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 d24ba689b..4b6809279 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -20,51 +20,85 @@ # $Id$ # -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.60) +# Process this file with autoreconf to produce a configure script. + +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 + + +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_AUX_DIR([auto-aux]) +AC_CONFIG_HEADERS([ac_cfg.h]) +AC_CONFIG_MACRO_DIR([auto-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]) +AM_INIT_AUTOMAKE([ + 1.14 + foreign + subdir-objects +]) -# 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. +AM_SILENT_RULES([yes]) -Please file an issue at ${PACKAGE_BUGREPORT} -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 +VERSIONINFO_SETUP() -LT_INIT() +dnl Inform about the derived PACKAGE_VERSION +AC_MSG_CHECKING([versioninfo derived PACKAGE_VERSION]) +AC_MSG_RESULT([$PACKAGE_VERSION]) + +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]) -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 -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 +AC_PROG_LEX([noyywrap]) +AM_PROG_AR +LT_INIT() + AH_TEMPLATE([HAVE_YYLEX_DESTROY], [Define if lex/flex has yylex_destroy]) # flex should have this @@ -100,11 +134,19 @@ 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]) -if test x$have_libelf = xyes; then +LIBELF="" +if test "x$have_libelf" = xyes; then case $target in *) LIBELF="-lelf" @@ -113,14 +155,15 @@ 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]) -if test x$have_libusb = xyes; then +LIBUSB="" +if test "x$have_libusb" = xyes; then case $target in *-*-darwin*) LIBUSB="-lusb -framework CoreFoundation -framework IOKit" @@ -133,24 +176,25 @@ 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], - 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 ;; - *) 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]) -if test x$have_libusb_1_0 = xyes && test x$enabled_libusb_1_0 = xyes; then +LIBUSB_1_0="" +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" @@ -166,7 +210,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 @@ -183,12 +227,14 @@ 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]) -if test x$have_libhidapi = xyes; then +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*) LIBHIDAPI="-lhidapi -iframework CoreFoundation -framework IOKit" @@ -200,12 +246,14 @@ 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]) -if test x$have_libserialport = xyes; then +AC_CHECK_LIB([serialport], [sp_open], + [have_libserialport=yes], [have_libserialport=no]) +LIBSERIALPORT="" +if test "x$have_libserialport" = xyes; then case $target in *) LIBSERIALPORT="-lserialport" @@ -214,7 +262,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]) @@ -222,32 +270,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]) -if test x$have_libftdi1 = xyes; then +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 + 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 + 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]) -if test x$have_pthread = xyes; then +# 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]) @@ -257,7 +315,7 @@ AC_CHECK_HEADERS([ddk/hidsdi.h],,,[#include # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -AC_HEADER_TIME + AC_CHECK_HEADERS([netinet/in.h]) @@ -266,6 +324,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" @@ -279,10 +339,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; @@ -290,15 +349,15 @@ 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 +if test "x$have_libhid" = xyes; then AC_DEFINE([HAVE_LIBHID]) else LIBHID="" fi LIBS="${SAVED_LIBS}" -AC_SUBST(LIBHID, $LIBHID) +AC_SUBST([LIBHID]) # Check for types @@ -311,81 +370,74 @@ 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 ;; - *) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for versioned-doc option]) ;; 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' fi +AC_SUBST([DOC_INST_DIR]) 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 ;; - *) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for disable-doc option]) ;; esac], [enabled_doc=no]) 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 ;; - *) 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], - 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 ;; - *) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;; + *) AC_MSG_ERROR([bad value ${enableval} for enable-linuxgpio option]) ;; esac], [enabled_linuxgpio=no]) 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 ;; - *) 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 "$enabled_doc" = "yes"; then +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 @@ -428,50 +480,50 @@ 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 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 "$enabled_parport" = "yes"; then - AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled]) +if test "x$enabled_parport" = xyes; then + AC_DEFINE([HAVE_PARPORT], [1], [parallel port access enabled]) confsubst="-e /^@HAVE_PARPORT_/d" else confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d" 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 AC_MSG_RESULT([$DEFAULT_LINUXGPIO_PORT]) fi - AC_SUBST(DEFAULT_LINUXGPIO_PORT, $DEFAULT_LINUXGPIO_PORT) + AC_SUBST([DEFAULT_LINUXGPIO_PORT]) fi -if test "$enabled_linuxgpio" = "yes"; then - AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled]) +if test "x$enabled_linuxgpio" = xyes; then + 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" fi -if test "$enabled_linuxspi" = "yes"; then - AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled]) +if test "x$enabled_linuxspi" = xyes; then + 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" @@ -479,8 +531,9 @@ 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" +ENABLE_WARNINGS="" +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 ]) @@ -488,41 +541,45 @@ 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 ; } ]]) + ], [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 + if test "x$no_pointer_sign" = 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 *-*-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]) 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 ; } ]]) + ], [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 + if test "x$no_cygwin" = xyes; then CFLAGS="${CFLAGS} -mno-cygwin" else AC_MSG_NOTICE([Your compiler does not understand the -mno-cygwin option.]) @@ -537,16 +594,18 @@ 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 ; } ]]) + ], [dnl can_link_static=yes AC_MSG_RESULT([yes]) - ], [ - can_link_static_cygwin=no + ], [dnl + can_link_static=no AC_MSG_RESULT([no]) - ]) + ]) LDFLAGS="$safe_LDFLAGS" - if test x$can_link_static = xyes; then + if test "x$can_link_static" = xyes; then LDFLAGS="${LDFLAGS} -static" fi @@ -563,20 +622,7 @@ 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})" -AC_SUBST([AVRDUDE_FULL_VERSION], ["$PACKAGE_VERSION"]) + # The procedure to create avrdude.conf involves two steps. First, # normal autoconf substitution will be applied, resulting in @@ -596,20 +642,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" @@ -618,13 +664,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 @@ -634,55 +680,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_libreadline" = 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" diff --git a/src/main.c b/src/main.c index fb2b73ae1..7debe44b2 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