public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* Cygport configure script argument handling
@ 2022-03-10 16:41 Adam Dinwoodie
  2022-03-11  5:38 ` Yaakov Selkowitz
  0 siblings, 1 reply; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-10 16:41 UTC (permalink / raw)
  To: cygwin-apps

I've fallen down a slight rabbit hole looking at the cygconf function in
Cygport's autotools.cygclass.  The specific bit of code that's causing
me consternation is thus:

	case "x${confver}" in
		x2.6[0-9]*)
			confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
			;;
		*)
			confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
			;;
	esac

Firstly, I think the glob is incorrect: it looks like it was intended to
match files that came from Autoconf versions 2.60 and up -- 2.60 is when
Autoconf added the docdir and htmldir arguments -- but it has stopped
working as expected: Autoconf released 2.70 in December 2020, and is now
up to 2.71.  The above code won't match those versions.

Secondly -- and I'm not sure if this is intended or not -- I don't
understand why --infodir and --mandir are only defined for versions
prior to 2.60 (and, apparently unintentionally, 2.70 onwards).  Those
are valid both before and after 2.60.  My best guess is that the intent
was for the first option to fall through to the second, so for 2.60+ all
four options would be defined, but that would have required `;&` or
`;;&` rather than `;;`.

Can anyone explain what the intent of this code is?  Are these both the
bugs that I think they are, or am I missing the intent?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Cygport configure script argument handling
  2022-03-10 16:41 Cygport configure script argument handling Adam Dinwoodie
@ 2022-03-11  5:38 ` Yaakov Selkowitz
  2022-03-11  9:05   ` Adam Dinwoodie
  0 siblings, 1 reply; 11+ messages in thread
From: Yaakov Selkowitz @ 2022-03-11  5:38 UTC (permalink / raw)
  To: cygwin-apps

On Thu, 2022-03-10 at 16:41 +0000, Adam Dinwoodie wrote:
> I've fallen down a slight rabbit hole looking at the cygconf function in
> Cygport's autotools.cygclass.  The specific bit of code that's causing
> me consternation is thus:
> 
>         case "x${confver}" in
>                 x2.6[0-9]*)
>                         confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
>                         ;;
>                 *)
>                         confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
>                         ;;
>         esac
> 
> Firstly, I think the glob is incorrect: it looks like it was intended to
> match files that came from Autoconf versions 2.60 and up -- 2.60 is when
> Autoconf added the docdir and htmldir arguments -- but it has stopped
> working as expected: Autoconf released 2.70 in December 2020, and is now
> up to 2.71.  The above code won't match those versions.

Yes, this likely needs to be updated for 2.70+.

> Secondly -- and I'm not sure if this is intended or not -- I don't
> understand why --infodir and --mandir are only defined for versions
> prior to 2.60 (and, apparently unintentionally, 2.70 onwards).  Those
> are valid both before and after 2.60.  My best guess is that the intent
> was for the first option to fall through to the second, so for 2.60+ all
> four options would be defined, but that would have required `;&` or
> `;;&` rather than `;;`.

No. 2.60 included changes for these (and other) directory values:

https://lists.gnu.org/archive/html/autotools-announce/2006-06/msg00002.html

docdir and htmldir were added in 2.60, hence we don't want to pass them when
<=2.59 is detected.  infodir and mandir were changed in 2.60, from
$prefix/{info,man} (which cygport needed to override for FHS compliance) to
$datarootdir/{info,man}, where the new datarootdir is $prefix/share, meaning
they no longer needed to be overriden by cygport.

HTH,

-- 
Yaakov


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Cygport configure script argument handling
  2022-03-11  5:38 ` Yaakov Selkowitz
@ 2022-03-11  9:05   ` Adam Dinwoodie
  2022-03-11 22:40     ` [PATCH cygport] autotools.cygclass: correctly detect Autoconf 2.70+ Adam Dinwoodie
  0 siblings, 1 reply; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-11  9:05 UTC (permalink / raw)
  To: cygwin-apps

On Fri, Mar 11, 2022 at 12:38:47AM -0500, Yaakov Selkowitz wrote:
> On Thu, 2022-03-10 at 16:41 +0000, Adam Dinwoodie wrote:
> > I've fallen down a slight rabbit hole looking at the cygconf function in
> > Cygport's autotools.cygclass.  The specific bit of code that's causing
> > me consternation is thus:
> > 
> >         case "x${confver}" in
> >                 x2.6[0-9]*)
> >                         confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
> >                         ;;
> >                 *)
> >                         confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
> >                         ;;
> >         esac
> > 
> > Firstly, I think the glob is incorrect: it looks like it was intended to
> > match files that came from Autoconf versions 2.60 and up -- 2.60 is when
> > Autoconf added the docdir and htmldir arguments -- but it has stopped
> > working as expected: Autoconf released 2.70 in December 2020, and is now
> > up to 2.71.  The above code won't match those versions.
> 
> Yes, this likely needs to be updated for 2.70+.

Grand, I'll see if I can offer a patch shortly :)

> > Secondly -- and I'm not sure if this is intended or not -- I don't
> > understand why --infodir and --mandir are only defined for versions
> > prior to 2.60 (and, apparently unintentionally, 2.70 onwards).  Those
> > are valid both before and after 2.60.  My best guess is that the intent
> > was for the first option to fall through to the second, so for 2.60+ all
> > four options would be defined, but that would have required `;&` or
> > `;;&` rather than `;;`.
> 
> No. 2.60 included changes for these (and other) directory values:
> 
> https://lists.gnu.org/archive/html/autotools-announce/2006-06/msg00002.html
> 
> docdir and htmldir were added in 2.60, hence we don't want to pass them when
> <=2.59 is detected.  infodir and mandir were changed in 2.60, from
> $prefix/{info,man} (which cygport needed to override for FHS compliance) to
> $datarootdir/{info,man}, where the new datarootdir is $prefix/share, meaning
> they no longer needed to be overriden by cygport.

Ah!  Yes, that makes sense.  Thank you for the explanation!

Adam

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH cygport] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-11  9:05   ` Adam Dinwoodie
@ 2022-03-11 22:40     ` Adam Dinwoodie
  2022-03-12 13:02       ` Jon Turney
  0 siblings, 1 reply; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-11 22:40 UTC (permalink / raw)
  To: cygwin-apps

The latest version of Autoconf is 2.71, but the version detection
incorrectly considers 2.70 and higher as being the same as 2.59 and
lower for the purposes of specifying documentation directories.  Correct
that, and make the version detection a bit more future-proof by parsing
out the actual version parts and performing numeric comparison.

While we're at it, add a bit more commentary explaining the intent of
the different behaviour over the different Autoconf versions.
---
 cygclass/autotools.cygclass | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
index cce9be0..2ab5626 100644
--- a/cygclass/autotools.cygclass
+++ b/cygclass/autotools.cygclass
@@ -619,6 +619,8 @@ cygconf() {
 	local confdir;
 	local configure;
 	local confver;
+	local confver_maj;
+	local confver_min;
 	local f;
 	local foo_config;
 	local prefix;
@@ -651,6 +653,8 @@ cygconf() {
 
 	configure="${confdir}/configure"
 	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
+	confver_maj=${confver%%.*}
+	confver_min=${confver##*.}
 
 	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
 	eval $(grep -h '^ac_config_files=' ${configure})
@@ -678,18 +682,26 @@ cygconf() {
 		confargs+=" --libdir=${prefix}/${MULTILIB_LIBDIR}"
 	fi
 
-	case "x${confver}" in
-		x2.6[0-9]*)
-			confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
-			;;
-		*)
-			confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
-			;;
-	esac
+	if [ $confver_maj -ge 2 -a $confver_min -ge 60 ] || [ $confver_maj -ge 3 ]
+	then
+		# Autoconf version supports --docdir and --htmldir, which will
+		# need to be specified manually.  It also supports --infodir
+		# and --mandir, but the defaults for those match the FHS.
+		confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
+	else
+		# Autoconf version does not support --docdir or --htmldir, so
+		# don't specify those.  Set --infodir and --mandir, as those
+		# have defaults that don't match the FHS.
+		confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
+	fi
 
-	case "x${confver}" in
-		x2.[5-9]*)	confargs+=" -C" ;;
-	esac
+
+	if [ $confver_maj -ge 2 -a $confver_min -ge 50 ] || [ $confver_maj -ge 3 ]
+	then
+		# Always use a cache file; prior to 2.50, this was the default,
+		# thereafter it needs to be requested explicitly.
+		confargs+=" -C"
+	fi
 
 	if cross_compiling || inherited toolchain
 	then
-- 
2.35.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH cygport] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-11 22:40     ` [PATCH cygport] autotools.cygclass: correctly detect Autoconf 2.70+ Adam Dinwoodie
@ 2022-03-12 13:02       ` Jon Turney
  2022-03-13 20:31         ` Adam Dinwoodie
  2022-03-13 20:44         ` [PATCH cygport v2] " Adam Dinwoodie
  0 siblings, 2 replies; 11+ messages in thread
From: Jon Turney @ 2022-03-12 13:02 UTC (permalink / raw)
  To: Adam Dinwoodie, cygwin-apps

On 11/03/2022 22:40, Adam Dinwoodie wrote:
> The latest version of Autoconf is 2.71, but the version detection
> incorrectly considers 2.70 and higher as being the same as 2.59 and
> lower for the purposes of specifying documentation directories.  Correct
> that, and make the version detection a bit more future-proof by parsing
> out the actual version parts and performing numeric comparison.
> 
> While we're at it, add a bit more commentary explaining the intent of
> the different behaviour over the different Autoconf versions.
> ---
>   cygclass/autotools.cygclass | 34 +++++++++++++++++++++++-----------
>   1 file changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
> index cce9be0..2ab5626 100644
> --- a/cygclass/autotools.cygclass
> +++ b/cygclass/autotools.cygclass
> @@ -619,6 +619,8 @@ cygconf() {
>   	local confdir;
>   	local configure;
>   	local confver;
> +	local confver_maj;
> +	local confver_min;
>   	local f;
>   	local foo_config;
>   	local prefix;
> @@ -651,6 +653,8 @@ cygconf() {
>   
>   	configure="${confdir}/configure"
>   	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
> +	confver_maj=${confver%%.*}
> +	confver_min=${confver##*.}
>   
>   	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
>   	eval $(grep -h '^ac_config_files=' ${configure})
> @@ -678,18 +682,26 @@ cygconf() {
>   		confargs+=" --libdir=${prefix}/${MULTILIB_LIBDIR}"
>   	fi
>   
> -	case "x${confver}" in
> -		x2.6[0-9]*)
> -			confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
> -			;;
> -		*)
> -			confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
> -			;;
> -	esac
> +	if [ $confver_maj -ge 2 -a $confver_min -ge 60 ] || [ $confver_maj -ge 3 ]

Great. Thanks.

I think it would be acceptable to error on autoconf >=3.0, rather than 
assuming it's going to be autoconf 2.6+ compatible.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH cygport] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-12 13:02       ` Jon Turney
@ 2022-03-13 20:31         ` Adam Dinwoodie
  2022-03-13 20:44         ` [PATCH cygport v2] " Adam Dinwoodie
  1 sibling, 0 replies; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-13 20:31 UTC (permalink / raw)
  To: cygwin-apps

On Sat, Mar 12, 2022 at 01:02:39PM +0000, Jon Turney wrote:
> On 11/03/2022 22:40, Adam Dinwoodie wrote:
> > -	case "x${confver}" in
> > -		x2.6[0-9]*)
> > -			confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
> > -			;;
> > -		*)
> > -			confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
> > -			;;
> > -	esac
> > +	if [ $confver_maj -ge 2 -a $confver_min -ge 60 ] || [ $confver_maj -ge 3 ]
> 
> Great. Thanks.
> 
> I think it would be acceptable to error on autoconf >=3.0, rather than
> assuming it's going to be autoconf 2.6+ compatible.

No problem, I'll respin now.  I'd thought about doing exactly that, but
the current code looked like it was designed to assume things would be
fine unless there was a specific reason to bail out, so I tried to
follow that paradigm rather than bail out when there was no known reason
for doing so.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH cygport v2] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-12 13:02       ` Jon Turney
  2022-03-13 20:31         ` Adam Dinwoodie
@ 2022-03-13 20:44         ` Adam Dinwoodie
  2022-03-14 19:05           ` Jon Turney
  1 sibling, 1 reply; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-13 20:44 UTC (permalink / raw)
  To: cygwin-apps

The latest version of Autoconf is 2.71, but the version detection
incorrectly considers 2.70 and higher as being the same as 2.59 and
lower for the purposes of specifying documentation directories.  Correct
that, and make the version detection a bit more future-proof by parsing
out the actual version parts and performing numeric comparison.

While we're at it, add a bit more commentary explaining the intent of
the different behaviour over the different Autoconf versions.
---
Interdiff against v1:
  diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
  index 2ab5626..38ac8f0 100644
  --- a/cygclass/autotools.cygclass
  +++ b/cygclass/autotools.cygclass
  @@ -655,6 +655,10 @@ cygconf() {
   	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
   	confver_maj=${confver%%.*}
   	confver_min=${confver##*.}
  +	if [ $confver_maj -ne 2 ]
  +	then
  +		error "unexpected autoconf version";
  +	fi
   
   	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
   	eval $(grep -h '^ac_config_files=' ${configure})
  @@ -682,7 +686,7 @@ cygconf() {
   		confargs+=" --libdir=${prefix}/${MULTILIB_LIBDIR}"
   	fi
   
  -	if [ $confver_maj -ge 2 -a $confver_min -ge 60 ] || [ $confver_maj -ge 3 ]
  +	if [ $confver_min -ge 60 ]
   	then
   		# Autoconf version supports --docdir and --htmldir, which will
   		# need to be specified manually.  It also supports --infodir
  @@ -696,7 +700,7 @@ cygconf() {
   	fi
   
   
  -	if [ $confver_maj -ge 2 -a $confver_min -ge 50 ] || [ $confver_maj -ge 3 ]
  +	if [ $confver_min -ge 50 ]
   	then
   		# Always use a cache file; prior to 2.50, this was the default,
   		# thereafter it needs to be requested explicitly.

 cygclass/autotools.cygclass | 38 ++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
index cce9be0..38ac8f0 100644
--- a/cygclass/autotools.cygclass
+++ b/cygclass/autotools.cygclass
@@ -619,6 +619,8 @@ cygconf() {
 	local confdir;
 	local configure;
 	local confver;
+	local confver_maj;
+	local confver_min;
 	local f;
 	local foo_config;
 	local prefix;
@@ -651,6 +653,12 @@ cygconf() {
 
 	configure="${confdir}/configure"
 	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
+	confver_maj=${confver%%.*}
+	confver_min=${confver##*.}
+	if [ $confver_maj -ne 2 ]
+	then
+		error "unexpected autoconf version";
+	fi
 
 	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
 	eval $(grep -h '^ac_config_files=' ${configure})
@@ -678,18 +686,26 @@ cygconf() {
 		confargs+=" --libdir=${prefix}/${MULTILIB_LIBDIR}"
 	fi
 
-	case "x${confver}" in
-		x2.6[0-9]*)
-			confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
-			;;
-		*)
-			confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
-			;;
-	esac
+	if [ $confver_min -ge 60 ]
+	then
+		# Autoconf version supports --docdir and --htmldir, which will
+		# need to be specified manually.  It also supports --infodir
+		# and --mandir, but the defaults for those match the FHS.
+		confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
+	else
+		# Autoconf version does not support --docdir or --htmldir, so
+		# don't specify those.  Set --infodir and --mandir, as those
+		# have defaults that don't match the FHS.
+		confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
+	fi
 
-	case "x${confver}" in
-		x2.[5-9]*)	confargs+=" -C" ;;
-	esac
+
+	if [ $confver_min -ge 50 ]
+	then
+		# Always use a cache file; prior to 2.50, this was the default,
+		# thereafter it needs to be requested explicitly.
+		confargs+=" -C"
+	fi
 
 	if cross_compiling || inherited toolchain
 	then
-- 
2.35.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH cygport v2] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-13 20:44         ` [PATCH cygport v2] " Adam Dinwoodie
@ 2022-03-14 19:05           ` Jon Turney
  2022-03-14 21:05             ` Adam Dinwoodie
  0 siblings, 1 reply; 11+ messages in thread
From: Jon Turney @ 2022-03-14 19:05 UTC (permalink / raw)
  To: Adam Dinwoodie, cygwin-apps

On 13/03/2022 20:44, Adam Dinwoodie wrote:
>   
>   	configure="${confdir}/configure"
>   	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
> +	confver_maj=${confver%%.*}
> +	confver_min=${confver##*.}
> +	if [ $confver_maj -ne 2 ]
> +	then
> +		error "unexpected autoconf version";
> +	fi
>   
>   	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
>   	eval $(grep -h '^ac_config_files=' ${configure})

When I test this locally, it fails, as (note the full stop at the end of 
the line):

> $ grep -m1 Autoconf configure
> # Generated by GNU Autoconf 2.71.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH cygport v2] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-14 19:05           ` Jon Turney
@ 2022-03-14 21:05             ` Adam Dinwoodie
  2022-03-14 22:15               ` [PATCH cygport v3] " Adam Dinwoodie
  0 siblings, 1 reply; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-14 21:05 UTC (permalink / raw)
  To: cygwin-apps

On Mon, Mar 14, 2022 at 07:05:20PM +0000, Jon Turney wrote:
> On 13/03/2022 20:44, Adam Dinwoodie wrote:
> >   	configure="${confdir}/configure"
> >   	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
> > +	confver_maj=${confver%%.*}
> > +	confver_min=${confver##*.}
> > +	if [ $confver_maj -ne 2 ]
> > +	then
> > +		error "unexpected autoconf version";
> > +	fi
> >   	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
> >   	eval $(grep -h '^ac_config_files=' ${configure})
> 
> When I test this locally, it fails, as (note the full stop at the end of the
> line):
> 
> > $ grep -m1 Autoconf configure
> > # Generated by GNU Autoconf 2.71.

Huh.  Apparently that string has a less consistent format than I'd
assumed; I'd tested that line against the configure script for Git, but
that gets different behaviour:

    $ grep -m1 Autoconf git-2.35.1-2.x86_64/build/configure
    # Generated by GNU Autoconf 2.71 for git 2.35.1.

I'll try to come up with something a bit less fragile...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH cygport v3] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-14 21:05             ` Adam Dinwoodie
@ 2022-03-14 22:15               ` Adam Dinwoodie
  2022-04-13 17:58                 ` Jon Turney
  0 siblings, 1 reply; 11+ messages in thread
From: Adam Dinwoodie @ 2022-03-14 22:15 UTC (permalink / raw)
  To: cygwin-apps

The latest version of Autoconf is 2.71, but the version detection
incorrectly considers 2.70 and higher as being the same as 2.59 and
lower for the purposes of specifying documentation directories.  Correct
that, and make the version detection a bit more future-proof by parsing
out the actual version parts and performing numeric comparison.

While we're at it, add a bit more commentary explaining the intent of
the different behaviour over the different Autoconf versions.
---
Interdiff against v2:
  diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
  index 38ac8f0..b40828b 100644
  --- a/cygclass/autotools.cygclass
  +++ b/cygclass/autotools.cygclass
  @@ -652,7 +652,7 @@ cygconf() {
   	fi
   
   	configure="${confdir}/configure"
  -	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
  +	confver="$("$configure" --version | sed -rn 's/.*GNU Autoconf ([0-9\.]+)/\1/p')"
   	confver_maj=${confver%%.*}
   	confver_min=${confver##*.}
   	if [ $confver_maj -ne 2 ]

 cygclass/autotools.cygclass | 40 ++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
index cce9be0..b40828b 100644
--- a/cygclass/autotools.cygclass
+++ b/cygclass/autotools.cygclass
@@ -619,6 +619,8 @@ cygconf() {
 	local confdir;
 	local configure;
 	local confver;
+	local confver_maj;
+	local confver_min;
 	local f;
 	local foo_config;
 	local prefix;
@@ -650,7 +652,13 @@ cygconf() {
 	fi
 
 	configure="${confdir}/configure"
-	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
+	confver="$("$configure" --version | sed -rn 's/.*GNU Autoconf ([0-9\.]+)/\1/p')"
+	confver_maj=${confver%%.*}
+	confver_min=${confver##*.}
+	if [ $confver_maj -ne 2 ]
+	then
+		error "unexpected autoconf version";
+	fi
 
 	# AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
 	eval $(grep -h '^ac_config_files=' ${configure})
@@ -678,18 +686,26 @@ cygconf() {
 		confargs+=" --libdir=${prefix}/${MULTILIB_LIBDIR}"
 	fi
 
-	case "x${confver}" in
-		x2.6[0-9]*)
-			confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
-			;;
-		*)
-			confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
-			;;
-	esac
+	if [ $confver_min -ge 60 ]
+	then
+		# Autoconf version supports --docdir and --htmldir, which will
+		# need to be specified manually.  It also supports --infodir
+		# and --mandir, but the defaults for those match the FHS.
+		confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
+	else
+		# Autoconf version does not support --docdir or --htmldir, so
+		# don't specify those.  Set --infodir and --mandir, as those
+		# have defaults that don't match the FHS.
+		confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
+	fi
 
-	case "x${confver}" in
-		x2.[5-9]*)	confargs+=" -C" ;;
-	esac
+
+	if [ $confver_min -ge 50 ]
+	then
+		# Always use a cache file; prior to 2.50, this was the default,
+		# thereafter it needs to be requested explicitly.
+		confargs+=" -C"
+	fi
 
 	if cross_compiling || inherited toolchain
 	then
-- 
2.35.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH cygport v3] autotools.cygclass: correctly detect Autoconf 2.70+
  2022-03-14 22:15               ` [PATCH cygport v3] " Adam Dinwoodie
@ 2022-04-13 17:58                 ` Jon Turney
  0 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2022-04-13 17:58 UTC (permalink / raw)
  To: cygwin-apps, Adam Dinwoodie

On 14/03/2022 22:15, Adam Dinwoodie wrote:
> The latest version of Autoconf is 2.71, but the version detection
> incorrectly considers 2.70 and higher as being the same as 2.59 and
> lower for the purposes of specifying documentation directories.  Correct
> that, and make the version detection a bit more future-proof by parsing
> out the actual version parts and performing numeric comparison.
> 
> While we're at it, add a bit more commentary explaining the intent of
> the different behaviour over the different Autoconf versions.

I applied this.

But it seems no good deed goes unpunished...

>   	configure="${confdir}/configure"
> -	confver=$(grep -m 1 'GNU Autoconf' ${configure} | cut -d ' ' -f 6)
> +	confver="$("$configure" --version | sed -rn 's/.*GNU Autoconf ([0-9\.]+)/\1/p')"
> +	confver_maj=${confver%%.*}
> +	confver_min=${confver##*.}
> +	if [ $confver_maj -ne 2 ]
> +	then
> +		error "unexpected autoconf version";
> +	fi

When rebuilding 'dialog' to update the SRC_URI, I get:

> /usr/share/cygport/cygclass/autotools.cygclass: line 658: [: -ne: unary operator expected
> /usr/share/cygport/cygclass/autotools.cygclass: line 689: [: -ge: unary operator expected
> /usr/share/cygport/cygclass/autotools.cygclass: line 703: [: -ge: unary operator expected

It seems that the configure script for that it customized somehow and 
doesn't output anything matching that regex:

> $ ./configure --version
> 
> Copyright 2003-2020,2021        Thomas E. Dickey
> Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
> Free Software Foundation, Inc.
> This configure script is free software; the Free Software Foundation
> gives unlimited permission to copy, distribute and modify it.

I think that if $confver is empty, that should be an error, and then 
perhaps there needs to be a variable which can be set to override 
autodection of the ./configure script version (e.g. something like 
'CONF_VERSION=2.60')


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-04-13 17:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 16:41 Cygport configure script argument handling Adam Dinwoodie
2022-03-11  5:38 ` Yaakov Selkowitz
2022-03-11  9:05   ` Adam Dinwoodie
2022-03-11 22:40     ` [PATCH cygport] autotools.cygclass: correctly detect Autoconf 2.70+ Adam Dinwoodie
2022-03-12 13:02       ` Jon Turney
2022-03-13 20:31         ` Adam Dinwoodie
2022-03-13 20:44         ` [PATCH cygport v2] " Adam Dinwoodie
2022-03-14 19:05           ` Jon Turney
2022-03-14 21:05             ` Adam Dinwoodie
2022-03-14 22:15               ` [PATCH cygport v3] " Adam Dinwoodie
2022-04-13 17:58                 ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).