bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Potential bug in AC_CONFIG_SRCDIR


From: Nick Bowler
Subject: Re: Potential bug in AC_CONFIG_SRCDIR
Date: Mon, 7 Jan 2019 14:11:41 -0500

Hi Michael,
On 2019-01-07, Michael Cress <address@hidden> wrote:
> I am observing some strange behavior ( see comments in snippet ) with the
> AC_CONFIG_SRCDIR macro when using the configure.ac snippet below.
[...]
> #Define a subdirectory which contains the source files ( a separate Git repo
> )
> DCMSGSRCDIR=DockControllerImplv1_Messages_src
> AC_SUBST([DCMSGSRCDIR], [$DCMSGSRCDIR])
[...]
> #This also works
> AC_CONFIG_SRCDIR([$DCMSGSRCDIR/src/dockcontrollermsg.c])
> AC_CONFIG_SRCDIR([DockControllerImplv1_Messages_src/include/dockcontrollermsg.h])

The reason this works is because the second expansion of AC_CONFIG_SRCDIR
replaces the first one, hiding the problematic variable reference.

> # This ***does not*** work
>
> # This second use of the variable doesn't work and fails with ‘configure:
> error: cannot find sources (/include/dockcontrollermsg.h) in . or ..’.
>
> # Is this a bug?

I'd say no, although the documentation perhaps could be improved to
help the programmer understand the limitations.

> AC_CONFIG_SRCDIR([$DCMSGSRCDIR/src/dockcontrollermsg.c])
> AC_CONFIG_SRCDIR([$DCMSGSRCDIR/include/dockcontrollermsg.h])

This one fails because the last AC_CONFIG_SRCDIR expansion has the
problematic variable reference.

The "problem" is that AC_CONFIG_SRCDIR does its stuff very early in the
configure script: long before any normal shell assignments you put in
your script.  So DCMSGSRCDIR is not defined at the point it is used,
and so you get the wrong filename.

If you really want to reference shell variables in AC_CONFIG_SRCDIR you
need to be sure they are set in the DEFAULTS diversion.  But there seems
to be little point.  The only thing AC_CONFIG_SRCDIR really does is help
detect "operator error" if they botch the --srcdir option to configure,
so configure can print a better error message in this case.  Just point
it at any one file you want (ideally choose a file that is unlikely to
exist in other people's packages) and don't use any shell variables.

Cheers,
  Nick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]