While trying to build a package that uses guile with autotools, I found a problem in the provided GUILE_PROGS macro.
The macro searches for the executables guile, guild, guile-config, and guile-tools. The problem is that even if the macro is given the version, it only looks for guile, guild, etc. with no version suffix. Version suffixes are commonly used by GNU/Linux distros to allow parallel installations of guile 1.8 and 2.0 (and 2.2 if it is there as well). Though typically one of them, whichever the distro considers to be primary, will have no suffix and will be just plain suffixless guile, guild, etc. I installed 2.1.4 (effective version 2.2) from source with the suffix '-2.2' to use the same style and not risk collisions with the guile already on my system (2.0 is the default). I imagine that others may do this sort of thing as well. Anyhow, GUILE_PROGS looks for suffixless guile and then compares its effective version to what was provided as an argument or set in the variable GUILE_EFFECTIVE_VERSION earlier by the GUILE_PKG macro. On a system with parallel guile installations with use of version suffixes, this means that the desired version of guile cannot be targetted unless that one happens to be suffixless (or have a suffixless symlink). If there is no suffixless guile, then the macro fails outright. If there is one and it is pointing to a version different than given as an argument or through the variable GUILE_EFFECTIVE_VERSION, it throws an error. For example, on my system (Fedora 24), guile 2.0 is installed without suffix and with a 'guile2' symlink by a package from the main repository. I have installed the latest version of guile using the sources on the git (2.1.4) in parallel using the suffix '-2.2' meaning its guile executable is 'guile-2.2'. If I use autoconf with the provided guile.m4 in the same directory as the following configure.ac looking for guile 2.2 with GUILE_PROGS AC_INIT([guile_autoconf_test], [0.1], []) m4_include([guile.m4]) GUILE_PROGS([2.2]) AC_OUTPUT I get the following output from the resulting configure script checking for guile... /usr/bin/guile checking for Guile version >= 2.2... configure: error: Guile 2.2 required, but 2.0.11 found If I instead run GUILE_PKG first and use the GUILE_EFFECTIVE_VERSION set by it AC_INIT([guile_autoconf_test], [0.1], []) m4_include([guile.m4]) GUILE_PKG([2.2]) GUILE_PROGS dnl Get the same results if I do GUILE_PROGS([2.2]) AC_OUTPUT I get a similar error from the configure script checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes configure: checking for guile 2.2 configure: found guile 2.2 checking for guile... /usr/bin/guile configure: error: found development files for Guile 2.2, but /usr/bin/guile has effective version 2.0 Looking at the beginning of the GUILE_PROGS macro in guile.m4 from guile 2.1.4 AC_DEFUN([GUILE_PROGS], [AC_PATH_PROG(GUILE,guile) _guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])" if test -z "$_guile_required_version"; then _guile_required_version=2.0 fi if test "$GUILE" = "" ; then AC_MSG_ERROR([guile required but not found]) fi AC_SUBST(GUILE) The problem comes from AC_PATH_PROG(GUILE,guile) in the very first line and then the error 5 and 6 lines below it when it fails. Further on in the macro, if guile is found, it checks its version against the provided version or against 2.0. I've written a patch that makes GUILE_PROGS first look for the specified version (or default version) of guile first with the version suffix '-X.Y', and if that fails looks for it with the version suffix 'X.Y' (no dash, unlike the first one), and if that fails looks for it without any version suffix. If it finds guile in this way, it then compares the versions. The patched version then uses the same suffix (or lack there of) when finding guild, guile-config, and guile-tools. I've attached the patch against the current development version of guile (well, assuming someone hasn't committed in the last half hour). It changes the macro and updated the documentation as well (the documentation builds successfully). The beginning of the GUILE_PROGS macro is changed to AC_DEFUN([GUILE_PROGS], [_guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])" if test -z "$_guile_required_version"; then _guile_required_version=2.0 fi _guile_suffix=-$_guile_required_version AC_PATH_PROG(GUILE,[guile$_guile_suffix]) if test "$GUILE" = "" ; then _guile_suffix=$_guile_required_version AC_PATH_PROG(GUILE,[guile$_guile_suffix]) if test "$GUILE" = "" ; then _guile_suffix= AC_PATH_PROG(GUILE,[guile$_guile_suffix]) if test "$GUILE" = "" ; then AC_MSG_ERROR([guile required but not found]) fi fi fi AC_SUBST(GUILE) Then, the previous configure.ac except with the new autoconf macro file named new_guile.m4 AC_INIT([guile_autoconf_test], [0.1], []) m4_include([new_guile.m4]) GUILE_PKG([2.2]) GUILE_PROGS AC_OUTPUT The configure script succeeds at finding guile 2.2 checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes configure: checking for guile 2.2 configure: found guile 2.2 checking for guile-2.2... /usr/local/bin/guile-2.2 checking for Guile version >= 2.2... 2.1.4 checking for guild-2.2... /usr/local/bin/guild-2.2 checking for guile-config-2.2... /usr/local/bin/guile-config-2.2 configure: creating ./config.status If configure.ac is changed to not use GUILE_PKG and look for guile 1.8, which is not on my system, AC_INIT([guile_autoconf_test], [0.1], []) m4_include([new_guile.m4]) GUILE_PROGS([1.8]) AC_OUTPUT The configure tries to find guile-1.8 and then guile1.8 unsuccessfully. It then finds guile, whose version (2.0) is at least 1.8 so configure considers that a success (whether that would be considered a bug or a feature is up for debate but that is for another time). checking for guile-1.8... no checking for guile1.8... no checking for guile... /usr/bin/guile checking for Guile version >= 1.8... 2.0.11 checking for guild... /usr/bin/guild checking for guile-config... /usr/bin/guile-config configure: creating ./config.status An alternative way to fix the issue would be to instead make GUILE_PROGS take one or more arbitrary suffixes to try as inputs. Another alternative would be to look for all executables that begin with the string 'guile' and check the version of each one till one is successful. The latter one seems like it would take quite a bit of work to implement and test. Freja Nordsiek
From 7e6d8d989e5778e2508f1ce6235a883764fadd31 Mon Sep 17 00:00:00 2001 From: Freja Nordsiek <fnord...@gmail.com> Date: Mon, 10 Oct 2016 15:50:19 +0700 Subject: [PATCH] Fixed specific version of guile search in autoconf macro GUILE_PROGS. * meta/guile.m4 (GUILE_PROGS): Search for guile with suffixes first ('-X.Y' and 'X.Y' where X.Y denotes the version) before searching for guile with no suffix. --- meta/guile.m4 | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/meta/guile.m4 b/meta/guile.m4 index 9fd4f1a..6d69bb9 100644 --- a/meta/guile.m4 +++ b/meta/guile.m4 @@ -181,7 +181,12 @@ AC_DEFUN([GUILE_SITE_DIR], # # This macro looks for programs @code{guile} and @code{guild}, setting # variables @var{GUILE} and @var{GUILD} to their paths, respectively. -# If @code{guile} is not found, signal an error. +# The macro will attempt to find @code{guile} with the suffix of +# @code{-X.Y}, followed by looking for it with the suffix @code{X.Y}, and +# then fall back to looking for @code{guile} with no suffix. If +# @code{guile} is still not found, signal an error. The suffix, if any, +# that was required to find @code{guile} will be used for @code{guild} +# as well. # # By default, this macro will search for the latest stable version of # Guile (e.g. 2.0). x.y or x.y.z versions can be specified. If an older @@ -198,13 +203,22 @@ AC_DEFUN([GUILE_SITE_DIR], # The variables are marked for substitution, as by @code{AC_SUBST}. # AC_DEFUN([GUILE_PROGS], - [AC_PATH_PROG(GUILE,guile) - _guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])" + [_guile_required_version="m4_default([$1], [$GUILE_EFFECTIVE_VERSION])" if test -z "$_guile_required_version"; then _guile_required_version=2.0 fi + _guile_suffix=-$_guile_required_version + AC_PATH_PROG(GUILE,[guile$_guile_suffix]) if test "$GUILE" = "" ; then - AC_MSG_ERROR([guile required but not found]) + _guile_suffix=$_guile_required_version + AC_PATH_PROG(GUILE,[guile$_guile_suffix]) + if test "$GUILE" = "" ; then + _guile_suffix= + AC_PATH_PROG(GUILE,[guile$_guile_suffix]) + if test "$GUILE" = "" ; then + AC_MSG_ERROR([guile required but not found]) + fi + fi fi AC_SUBST(GUILE) @@ -246,15 +260,15 @@ AC_DEFUN([GUILE_PROGS], fi AC_MSG_RESULT([$_guile_prog_version]) - AC_PATH_PROG(GUILD,guild) + AC_PATH_PROG(GUILD,[guild$_guile_suffix]) AC_SUBST(GUILD) - AC_PATH_PROG(GUILE_CONFIG,guile-config) + AC_PATH_PROG(GUILE_CONFIG,[guile-config$_guile_suffix]) AC_SUBST(GUILE_CONFIG) if test -n "$GUILD"; then GUILE_TOOLS=$GUILD else - AC_PATH_PROG(GUILE_TOOLS,guile-tools) + AC_PATH_PROG(GUILE_TOOLS,[guile-tools$_guile_suffix]) fi AC_SUBST(GUILE_TOOLS) ]) -- 2.7.4