Makefile: .if inside .for

Oliver Eikemeier eikemeier at fillmore-labs.com
Mon Feb 2 21:05:12 PST 2004


Sergey Matveychuk wrote:

> man make says:
>      For loops are expanded before tests, so a fragment such as:
> 
>            .for TMACHINE in ${SHARED_ARCHS}
>            .if ${TMACHINE} = ${MACHINE}
>                 ...
>            .endif
>            .endfor
> 
>      won't work, and should be rewritten the other way around.
> 
> But how can I rewrite it if I need to aggregate file names in 
> PLIST_FILES with a some condition in a loop?

Try

.for TMACHINE in ${SHARED_ARCHS}
.if ${MACHINE} == ${TMACHINE}
     ...
.endif
.endfor

or use a shell loop.


More information about the freebsd-ports mailing list