[Top][All Lists]

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

Re: Mixing BUILT_SOURCES, double quote include and separation of source

From: Ralf Wildenhues
Subject: Re: Mixing BUILT_SOURCES, double quote include and separation of source and binary directory
Date: Wed, 30 Mar 2005 17:44:19 +0200
User-agent: Mutt/1.4.1i

Hi Simon,

* Simon Perreault wrote on Wed, Mar 30, 2005 at 04:13:23PM CEST:
> I have a problem which I figure must be fairly common, although I found no 
> reference to it anywhere. I think it must be common because the SCons manual 
> says they fixed it. [1] Anyway...

Looks like they traded disk space in return, yes.

> Let's say I have two directories, "src" and "include". I place main.c in src 
> and inc.h in include. main.c includes inc.h this way:
> #include "../include/inc.h"

which is not portable, by the way (but I can see if you don't care about
that part of the world).

> and inc.h includes built.h this way:
> #include "built.h"
> Now, my src/ contains something like this:
> BUILT_SOURCES = ../include/built.h
> ../include/built.h:
>       mkdir -p $(@D)
>       touch $@

which is not portable, by the way.  Use $(mkdir_p).  If you want to
support borked `make's on weird systems, look at how AS_DIRNAME works.
Or just spell out the directory name.

If you put this rule in several directories, it might lead to race
conditions with parallel make.  (Your example suggests you might be
doing this.)

> Everything works fine as long as I am building in the source directory. If I 
> make a build directory and invoke configure and make from that directory, 
> inc.h can't find built.h. And that's normal, since built.h is in 
> build/include instead of include. Because it is not in the same directory as 
> inc.h, including it using double quotes can't work.
> The quick fix is to add the location of inc.h, prefixed with $(top_builddir). 
> However, in my real project I have hundreds of such files with hundreds of 
> such locations. I would quickly hit the limit on command-line arguments.

Now does this mean you have hundreds of built headers which also live in
different directories each?  This strikes me as suboptimal design, but
then again it might just be natural for your problem.

> How should I fix this problem?

Couple possibilies come to mind:
- put all build headers in one (or few) directories (you already knew
  that, I guess).
- change the rule above to create a symlink to the current directory
  or a central directory, for that matter
  (be sure to look at $(LN_S) semantics in the Autoconf docs!).
  Have `make clean' remove the links.

You should use only one rule per header which actually creates the
header, and you should make sure it is executed before any of the above
rules will be executed.

Also see for some limitations on BUILT_SOURCES in the Automake manual.


> [1]

reply via email to

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