GNU make - word position in list

Mathieu Zhang <[email protected]> Tue, 20 Apr 2010 19:59:27 -0700 (PDT)
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <80f62351-f0cf-441d-b96a-a27aac3356bf@x24g2000prc.googlegroups.com>
Hi all,

I have one source pdf file source.pdf, that I want to use pdftk to
split into multiple files such that the n-th file on the target list
is the n-th page from source.pdf

TARGETS = "foo.pdf bar.pdf more_foo.pdf ... "

What I want, is to have a rule like this:

${TARGETS} : source.pdf
    pdftk A=$? cat A# output $@

where # is the position of $@ inside the list ${TARGETS}.  I see a lot
of buildin pattern matching and substitution functions, but I don't
see anything that help find the matching position.

Any idea?

--MZ