help-make
[Top][All Lists]
Advanced

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

Forcing rebuild of a target marking it PHONY [was: Pre-including a gener


From: Leandro Lucarella
Subject: Forcing rebuild of a target marking it PHONY [was: Pre-including a generated file]
Date: Thu, 13 Aug 2009 11:31:39 -0300
User-agent: mutt-ng/devel-r804 (Debian)

Eric Melski, el 12 de agosto a las 23:59 me escribiste:
> Leandro Lucarella wrote:
> 
> >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.
> 
> You may also find this Mr. Make article useful:
> 
>       http://www.cmcrossroads.com/content/view/6528/268/
> 
> It describes a system for getting gmake to consider targets out-of-date
> when the commands for the target have changed.
> 
> Hope that helps,

Thanks. I saw that, but my solution is a little cleaner from the POV of
writing Makefiles (you don't have to wrap commands in $(call do,...) for
example).

But it's a little weaker in other aspects. For example, you can't use
default make rules because it works adding a PHONY target to the list of
dependencies for outdated commands.

This is because I had to use:
outdated_target1: phony_target
outdated_target2: phony_target
.PHONY: phony_target

So if the target are, for example, .c files, and you try to use the
default Make rules (or make your own rules using $^), phony_target is used
as a compiler source and it fails.

My first approach was to do it using:
.PHONY: outdated_target1
.PHONY: outdated_target2

Directly, but I got random rebuilding of some targets when doing that.

If anyone can think of a cleaner solution that let the user use default
rules and $^ in custom rules it would be very appreciated.

I will release my script soon (under a Free/Libre license, probably GPL),
but if you think it would be a good idea to show the code here to
understand how it works more easily, I will be happy to do it (it's
a 350 LOC Python script).

Thanks!

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
FALTAN 325 DIAS PARA LA PRIMAVERA
        -- Crónica TV





reply via email to

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