Subject: AC_SUBST([FOO_LIB], ['libfoo.la']) breaks dependency checker

From: Stanislav Brabec <[email-masked]>
Date: Tue, 21 Jul 2015 22:17:03 +0200

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: [email-masked]
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