help-make
[Top][All Lists]
Advanced

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

Re: Initialization targets


From: Rafael Garabato
Subject: Re: Initialization targets
Date: Wed, 16 Jan 2008 16:02:45 -0200

Hi ken,

    Thanks for the tip, it looks advanced... I like it. However, if I execute "make all", wouldn't this execute the always rule twice. Once for dep1 and once for dep2?

Thanks,
          Rafael.

On Jan 16, 2008 3:43 PM, Ken Smith <address@hidden> wrote:
On Jan 16, 2008 7:14 AM, Rafael Garabato <address@hidden> wrote:

>        I would like to know if it exists a way to define a target that will
> always be executed once and prior to any other target,  regardless of the
> target that is specified.

As Paul said, the only way to do this is to make always a prerequisite
of every target.  It turns out that it isn't that hard to do.
Consider:

deps := dep1 dep2

all: $(deps);
       echo all

dep1:
       echo dep1

dep2:
       echo dep2

# make always a prerequisite of every target listed in $(deps)
$(foreach d,$(deps),$(eval $(d): always))

.PHONY: always
always:
       echo always

#EOF

Making always a .PHONY target ensures that it is run every time the
makefile is run.

  Ken


reply via email to

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