conditional builds

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

conditional builds

Brian Gerkey
hi,

When writing an automake file (Makefile.am), you must NOT define or  
modify SUBDIRS conditionally.  If you do this, then when it comes  
time to make a distribution (with 'make dist'), the conditionally-
included subdirectories will only be included if the system on which  
the distribution is made passes the relevant tests.  This it not what  
you want.

SUBDIRS must be defined unconditionally to include all subdirectories  
that might ever be needed, on any system.

The right way to handle conditionally building parts of the codebase  
is modify the Makefile.am in the directory where the conditionally-
built code resides.  Using automake conditionals, you can add to (via  
+=) the appropriate target (e.g., lib_LTLIBRARIES, or bin_PROGRAMS).

     brian.

--
Brian Gerkey
[hidden email]
http://gerkey.org





-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Playerstage-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-developers
Reply | Threaded
Open this post in threaded view
|

Re: conditional builds

Richard vaughan

On 26-Sep-05, at 3:01 PM, Brian Gerkey wrote:

hi,

When writing an automake file (Makefile.am), you must NOT define or modify SUBDIRS conditionally.  If you do this, then when it comes time to make a distribution (with 'make dist'), the conditionally-included subdirectories will only be included if the system on which the distribution is made passes the relevant tests.  This it not what you want.

SUBDIRS must be defined unconditionally to include all subdirectories that might ever be needed, on any system.

The right way to handle conditionally building parts of the codebase is modify the Makefile.am in the directory where the conditionally-built code resides.  Using automake conditionals, you can add to (via +=) the appropriate target (e.g., lib_LTLIBRARIES, or bin_PROGRAMS).


My bad, thanks for the correction.

The reason I did it that way at all is because I couldn't figure out the syntax for a two-condition conditional.

Here's your code:

noinst_PROGRAMS =
if INCLUDE_BOOST_SIGNALS
  noinst_PROGRAMS += test
endif

but originally building test also depended on BUILD_TESTS (or similar) being set. Automake's 'if' only allows one variable to be tested, and I couldn't get a test-within a test to work.

If BUILD_TESTS is no longer to be used, the problem goes away. But multiple conditions might come up elsewhere...?

R/


    brian.

-- 
Brian Gerkey





-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Playerstage-developers mailing list


--

Richard Vaughan

School of Computing Science / Simon Fraser University



Reply | Threaded
Open this post in threaded view
|

Re: conditional builds

Brian Gerkey

On Sep 26, 2005, at 4:23 PM, Richard vaughan wrote:

>
> The reason I did it that way at all is because I couldn't figure  
> out the syntax for a two-condition conditional.
>
> Here's your code:
>
> noinst_PROGRAMS =
> if INCLUDE_BOOST_SIGNALS
>   noinst_PROGRAMS += test
> endif
>
> but originally building test also depended on BUILD_TESTS (or  
> similar) being set. Automake's 'if' only allows one variable to be  
> tested, and I couldn't get a test-within a test to work.
>
> If BUILD_TESTS is no longer to be used, the problem goes away. But  
> multiple conditions might come up elsewhere...?

That's a good point; I guess I had thrown away WITH_TESTS along the  
way...

According to the automake docs, you can nest conditionals to any  
depth.  I've just checked in the following (in client_libs/libplayerc+
+/test/Makefile.am):

noinst_PROGRAMS =
if INCLUDE_BOOST_SIGNALS
if WITH_TESTS
   noinst_PROGRAMS += test
endif
endif

automake accepts this syntax and 'test' does not get built on my  
machine (which is correct, since I don't have Boost installed).

     brian.

--
Brian Gerkey
[hidden email]
http://gerkey.org





-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Playerstage-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-developers