help-make
[Top][All Lists]
Advanced

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

Re: Replacement for .if !target(${foo})


From: Der Herr Hofrat
Subject: Re: Replacement for .if !target(${foo})
Date: Tue, 8 Oct 2002 10:48:26 +0200 (CEST)

> Hello,
>    First off, I'm not on list, so please include me 
> in on the reply.  Does anyone have a clever way to 
> recreate the following bsd make code with gnu make:
> 
> .for stage in pre post
> .for name in download unpack patch configure \
>              build install link package web
> 
> .if !target(${stage}-${name})
> ${stage}-${name}:
>       @${DO_NOTHING}
> .endif
> 
> .endfor
> .endfor
>
you could do:


STAGES := pre post
NAMES := download unpack patch configure \
              build install link package web

TARGETS:=$(foreach stage,$(STAGES),$(foreach name,$(NAMES),$(stage)-$(name)))

.DEFAULT:
        @echo "Doing nothing for $@" 

all: $(TARGETS)

pre-download:
        ....


I don't know if "target" is a BSD-Make builtin or a function you provided,
but as you want to do nothing in the case that the target does not
exist just add .DEFAULT target at the end of the makefile to eliminate the 
errors from non-existing targets and track which targets were not built.

hofrat




reply via email to

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