automake
[Top][All Lists]
Advanced

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

Re: Problems with conditional sources


From: John Calcote
Subject: Re: Problems with conditional sources
Date: Mon, 25 Aug 2008 13:53:48 -0600
User-agent: Thunderbird 2.0.0.12 (X11/20071114)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Sveningsson wrote:
> Hi, I am having some problems with conditional sources. This is what I
> have in Makefile.am:
> 
> lib_LTLIBRARIES = libfoo.la
> libfoo_la_SOURCES = foo.cpp
> if WANT_BAR
>     libfoo_la_SOURCES += a.cpp
> else
>     libfoo_la_SOURCES += b.cpp
> endif
> 
> AM_CPPFLAGS = -I${top_srcdir}/include
> libfoo_la_LDFLAGS = -version-info 0:0:0
> 
> I have been reading both autoconf and automake manuals and as far as I
> can see the above should work. However the files (a.cpp or b.cpp) is
> always added at the bottom of the generated Makefile and are therefore
> not used in the compilation. No matter what I try I cannot get even the
> above code to generate a correct makefile but obviously I am doing
> something wrong.

David,

Make is a two-pass utility. The first pass completely assimilates all
macro data specified in the Makefile. THEN, the second pass generates
the rule dependency tree. AFTER the second pass, the tree is evaluated
to see what needs to be rebuilt.

Thus, it doesn't matter where macros are assigned, as value assignments
to macros are managed in the first stage, before any macros are ever
expanded when the dependency tree is evaluated.

Yes, as you've noticed Makefile.am conditional (and non-conditional)
macro assignments are added to the bottom of the generated Makefile.in
(and consequently to the bottom of the Makefile itself), but the point
is that it doesn't matter where they're added. The value of an expanded
macro always takes into account the final assignment in the Makefile.

Regards,
John
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAkizDcwACgkQdcgqmRY/OH8NAgCfXOzWSB8JYAMIqJhC0xCcdj9E
j6wAoJxLNUc1t4YPp0pnn0G6PSCOntpY
=uEnf
-----END PGP SIGNATURE-----




reply via email to

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