Subject: Re: arithmetic in make
To: None <tech-toolchain@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-toolchain
Date: 02/25/2007 19:26:37
On Sun, Feb 25, 2007 at 05:48:17PM +0000, David Laight wrote:
> On Sun, Feb 25, 2007 at 06:35:52PM +0100, Manuel Bouyer wrote:
> > >
> > > .for file in ${MYFILES}${n::=n}
> > > cp ${file} dir/$file${n:[#]}${n::=$n n}
> > > .endfor
> >
> > Well, I don't claim to understand it but it seems to work.
>
> ${<var>::=<str>} assigns <str> to $<var> and expands to nothing.
> ${<var>:[#]} returns the number of 'words' in $<var>.
>
> So on the '.for' line we set ${n} to "n".
> On the 'cp' line we generate the number of words in "n" ie 1,
> the set ${n} to "${n} n" or "n n".
> Rinse and repeat.
OK, thanks for the course !
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--