Subject: make: needs a tweak
To: None <tech-toolchain@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 04/06/2004 23:50:51
Given something like:
PRIMES=1 3 5 7 11
NUMBERS=1 2 3 4 5 6 7 8 9 10 11 12
I want to be able to refer to the elements of NUMBERS excluding those
of PRIMES. Right now this can't be done - other than with a hideous
.for loop. Expressions like:
echo "${NUMBERS:@n@$n is ${(${PRIMES:M$n} == ""):?not:} prime,@}"
don't work because ${PRIMES} is expanded to nothing before being
passed to the conditional logic - which insists on having a variable
reference and so chokes. Also
echo "${NUMBERS:@n@$n is ${empty(${PRIMES:M$n}):?not:} prime,@}"
doesn't work either - not exactly sure why...
Of course the real reason I want this isn't for printing non-primes
;-) But for avoiding cycles in auto-generated dependencies.
I can think of several approaches...
1. Allow something like:
${NUMBERS:${PRIMES:S,^,N,:ts}}
Which would be treated as
${NUMBERS:N1:N3:N5:N...}
2. Make cond.c not require a variable reference for string
comparisons. This would allow:
${NUMBERS:@n@${("${PRIMES:M$n}" == ""):?$n:}@}
to work.
3. Provide a means of saying "don't" expand yet, so that ${PRIMES:M$n}
could be passed down to cond.c - or perhaps make that implicit if
:? is present.
4. Make:
${PRIMES:M$n:?:$n}
work as expected? Ie. if ${PRIMES:M$n} is empty, then :? should
eval false.
Thoughts? (on the above ;-)
--sjg