bug-automake
[Top][All Lists]
Advanced

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

bug#21106: AC_SUBST([FOO_LIB], ['libfoo.la']) breaks dependency checker


From: Stanislav Brabec
Subject: bug#21106: AC_SUBST([FOO_LIB], ['libfoo.la']) breaks dependency checker
Date: Thu, 23 Jul 2015 15:54:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Gavin Smith wrote:
> On 21 July 2015 at 21:17, Stanislav Brabec <address@hidden> 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: address@hidden
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

Attachment: 0001-Document-that-AC_SUBST-can-break-dependencies.patch
Description: Text Data


reply via email to

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