NetBSD-Users archive

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

Re: make-dependency with multiple targets



In article <20080403005808.GA13630%NetBSD.org@localhost>,
Johnny C. Lam <netbsd-users%netbsd.org@localhost> wrote:
>On Wed, Apr 02, 2008 at 07:42:41PM +0200, Petar Bogdanovic wrote:
>> 
>> I'm just doing my first steps with make(1). The following Makefile
>> should create some postfix maps upon invocation:
>> 
>>      MAPS = client sender
>> 
>>      ${MAPS:S/$/.db/g}: ${MAPS}
>>              postmap ${.ALLSRC}
>> 
>> This does work pretty well but if nothing has to be done, make confuses
>> me with an inconsistent message:
>> 
>>      `client.db' is up to date.
>> 
>
>This is equivalent to this:
>
>       client.db sender.db: client sender
>               postmap client sender
>
>The default target is just the first named target -- in this case,
>``client.db''.
>
>You probably want:
>
>       MAPS=   client sender
>
>       all: ${MAPS:S/$/.db/}
>
>       .for map in MAPS
>       ${map}.db: ${map}
>               postmap ${map}
>       .endfor
>
>This is equivalent to:
>
>       all: client.db sender.db
>
>       client.db: client
>               postmap client
>
>       sender.db: sender
>               postmap sender
>
>Then just typing ``make'' will invoke the ``all'' target, which will
>ensure that both the client.db and sender.db are current.

A better way to so this is:

.SUFFIXES:      .db .null
.NULL:          .null

.null.db:
        postmap hash:${.CURDIR}/${.ALLSRC}

MAPS = client sender
 
DBFILES = ${MAPS:S/$/.db/g}

all: ${DBFILES}

or you can change ALLSRC to IMPSRC etc...

christos



Home | Main Index | Thread Index | Old Index