help-make
[Top][All Lists]
Advanced

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

Re: Pre-including a generated file


From: Leandro Lucarella
Subject: Re: Pre-including a generated file
Date: Wed, 12 Aug 2009 21:24:01 -0300
User-agent: mutt-ng/devel-r804 (Debian)

Paul Smith, el 12 de agosto a las 14:45 me escribiste:
> On Wed, 2009-08-12 at 14:37 -0300, Leandro Lucarella wrote:
> > Paul Smith, el 12 de agosto a las 12:22 me escribiste:
> > > If you really want that command run every single time, probably simpler
> > > is to remove the rule to build it and just use $(shell ...), like this:
> > > 
> > >   __dummy := $(shell ./gen_file)
> > >   include file
> > 
> > I tried to do that too, but I had some problems. The thing is, I use make
> > to generate the file. Maybe it's time to explain what I'm trying to do
> > with some more detail =)
> > 
> > To invoke the script I use:
> > 
> >     ./gen_file $(MAKE) $(MAKECMDGOALS)
> > 
> > If I put this in the Makefile:
> > 
> >     __dummy := $(shell ./gen_file $(MAKE) $(MAKECMDGOALS))
> >     include file
> > 
> > And then run make CFLAGS=-Wall, for example, it looks like the make -Bn
> > that I run inside gen_file is not getting the CFLAGS, and thus not
> > detecting any changes in the command line used to build the targets.
> 
> You probably want to look at the "Communicating Options to a Sub-'make'"
> section of the GNU make manual, in particular the section on
> MAKEOVERRIDES.

Thanks!

This worked:

    __dummy := $(shell ./gen_file $(MAKE) $(if $(MAKEFLAGS),-$(MAKEFLAGS),) \
                       $(MAKEOVERRIDES) $(MAKECMDGOALS))
    sinclude file

It's a little dirtier than I what expected to be (and well, what I'm doing
is pretty dirty itself =), but seems to works rather well.

Please let me know if you find any flaws on this approach.

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Un barco con animales, amigos míos.
Creyendo salvarse de la inundación.
Mientras yo, sufro la ruptura de mi corazón.





reply via email to

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