GNU bug report logs - #21106
AC_SUBST([FOO_LIB], ['libfoo.la']) breaks dependency checker

Previous Next

Package: automake;

Reported by: Stanislav Brabec <sbrabec <at> suse.com>

Date: Tue, 21 Jul 2015 20:18:02 UTC

Severity: normal

To reply to this bug, email your comments to 21106 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#21106; Package automake. (Tue, 21 Jul 2015 20:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stanislav Brabec <sbrabec <at> suse.com>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Tue, 21 Jul 2015 20:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stanislav Brabec <sbrabec <at> suse.com>
To: bug-automake <at> gnu.org
Subject: AC_SUBST([FOO_LIB], ['libfoo.la']) breaks dependency checker
Date: Tue, 21 Jul 2015 22:17:03 +0200
[Message part 1 (text/plain, inline)]
I just wanted to make an option to link the program either against
in-package instance or external instance.

To make things as easy as possible, I wanted to define FOO_LIB in
configure.ac either as 'libfoo.la' or '-lfoo' using e. g.:

AC_SUBST([FOO_LIB], ['libfoo.la'])

and then in Makefile.am use just:

myprogram_LDADD = $(FOO_LIB)

Everything works well except parallel build. It seems that dependency
checker is not able to see such dependency, and if I try to compile the
project with "make -j7", it fails:

libtool:   error: cannot find the library 'libfoo.la' or unhandled argument 'libfoo.la'

Plain "make" works.

Is it a bug or expected behavior?

Is there any better way how to do such things than use

if USE_BUILTIN_LIBFOO
myprogram_LDADD = libfoo.la
else
myprogram_LDADD = -lfoo
endif

everywhere I need to link with libfoo?

Attaching a minimalistic example.

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec <at> suse.com
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
[libfoo.tar.gz (application/gzip, attachment)]

Information forwarded to bug-automake <at> gnu.org:
bug#21106; Package automake. (Tue, 21 Jul 2015 22:02:01 GMT) Full text and rfc822 format available.

Message #8 received at 21106 <at> debbugs.gnu.org (full text, mbox):

From: Gavin Smith <gavinsmith0123 <at> gmail.com>
To: Stanislav Brabec <sbrabec <at> suse.com>
Cc: 21106 <at> debbugs.gnu.org
Subject: Re: bug#21106: AC_SUBST([FOO_LIB],
 ['libfoo.la']) breaks dependency checker
Date: Tue, 21 Jul 2015 23:01:03 +0100
On 21 July 2015 at 21:17, Stanislav Brabec <sbrabec <at> suse.com> wrote:
> I just wanted to make an option to link the program either against
> in-package instance or external instance.
>
> To make things as easy as possible, I wanted to define FOO_LIB in
> configure.ac either as 'libfoo.la' or '-lfoo' using e. g.:
>
> AC_SUBST([FOO_LIB], ['libfoo.la'])
>
> and then in Makefile.am use just:
>
> myprogram_LDADD = $(FOO_LIB)
>
> Everything works well except parallel build. It seems that dependency
> checker is not able to see such dependency, and if I try to compile the
> project with "make -j7", it fails:
>
> libtool:   error: cannot find the library 'libfoo.la' or unhandled argument 'libfoo.la'
>
> Plain "make" works.
>
> Is it a bug or expected behavior?
>
> Is there any better way how to do such things than use
>
> if USE_BUILTIN_LIBFOO
> myprogram_LDADD = libfoo.la
> else
> myprogram_LDADD = -lfoo
> endif
>
> everywhere I need to link with libfoo?

It seems similar to the questions of conditional sources, which is
covered in the Automake manual. It suggests two approaches, one with
Automake conditionals, which you imply you don't like; the other
similar to the approach you've been trying with a *.la file in the
place of a *.o file, with the exception that the Automake manual uses
an EXTRA_myprogram_SOURCES variable.

I don't know if adding "EXTRA_myprogram_SOURCES = libfoo.c" (or
"EXTRA_myprogram_SOURCES = $(libfoo_la_SOURCES)") is the right
solution?




Information forwarded to bug-automake <at> gnu.org:
bug#21106; Package automake. (Thu, 23 Jul 2015 13:55:02 GMT) Full text and rfc822 format available.

Message #11 received at 21106 <at> debbugs.gnu.org (full text, mbox):

From: Stanislav Brabec <sbrabec <at> suse.com>
To: Gavin Smith <gavinsmith0123 <at> gmail.com>
Cc: 21106 <at> debbugs.gnu.org
Subject: Re: bug#21106: AC_SUBST([FOO_LIB], ['libfoo.la']) breaks dependency
 checker
Date: Thu, 23 Jul 2015 15:54:47 +0200
[Message part 1 (text/plain, inline)]
Gavin Smith wrote:
> On 21 July 2015 at 21:17, Stanislav Brabec <sbrabec <at> suse.com> wrote:
>> Is there any better way how to do such things than use
>>
>> if USE_BUILTIN_LIBFOO
>> myprogram_LDADD = libfoo.la
>> else
>> myprogram_LDADD = -lfoo
>> endif
>>
>> everywhere I need to link with libfoo?
> 
> It seems similar to the questions of conditional sources, which is
> covered in the Automake manual. It suggests two approaches, one with
> Automake conditionals, which you imply you don't like;

I just wanted to avoid it because Makefile.am with hundreds of
conditionals is less readable. But if it is the recommended way,
I'll use it.

> the other
> similar to the approach you've been trying with a *.la file in the
> place of a *.o file, with the exception that the Automake manual uses
> an EXTRA_myprogram_SOURCES variable.

This does not work. It just compiles all sources of the libfoo.la, but
the linking the library itself is run in parallel with linking of
myprogram. Parallel build ends with the same error as before.

But this works:
EXTRA_myprogram_SOURCES = libfoo.la
BUILT_SOURCES = libfoo.la

> I don't know if adding "EXTRA_myprogram_SOURCES = libfoo.c" (or
> "EXTRA_myprogram_SOURCES = $(libfoo_la_SOURCES)") is the right
> solution?
> 
Even in a form mentioned above, it is not allowed:

configure.ac:10: error: 'FOO_LIB' includes configure substitution '@FOO_LIB@'
configure.ac:10: and is referred to from 'EXTRA_myprogram_SOURCES';
configure.ac:10: configure substitutions are not allowed in _SOURCES variables

But following works: Move the if/else from configure.ac to Makefile.am:

if BUILTIN_FOO
FOOLIB = libfoo.la
else
FOOLIB = -lfoo
endif

myprogram_LDADD = $(FOO_LIB)

Now automatic dependency checker is able to expand libfoo.la and properly link
libfoo.la before myprogram, and the conditional is used just once instead of
hundred times.

I propose to improve AC_SUBST documentation. See attached patch.

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec <at> suse.com
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
[0001-Document-that-AC_SUBST-can-break-dependencies.patch (text/x-patch, attachment)]

This bug report was last modified 10 years and 25 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.