make: "dynamic" targets?

kj <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization none
Message-ID <[email protected]>

Pardon the cryptic title, but I don't know the correct terminology...

I want to write Makefile that starts out by downloading a file from
a remote site, but the obstacle I'm facing is that the name of the
downloaded file is not known at the time of writing the Makefile;
it changes over time.  The only thing that remains constant is a
suffix.  E.g. at various times, the downloaded file may be 123_foo.tgz,
786_foo.tgz, 2110_foo.tgz, etc.

I can write the rule for performing this download, but I can't
figure out how to write rules that work with the resulting download.
Just to be concrete, suppose the rule for download is something
like this:

download:
	wget -N ftp://ftp.foobar.org/latest/*_foo.tgz

and assume that the directory ftp.foobar.org/latest always contains
exactly one file matching the pattern *_foo.tgz, though the full
name of this file changes over time.  (BTW, the -N flag tells wget
to download a file only if its latest-modification time is more
recent than the one for a local copy of the same file, but I guess
I don't need to explain this to this crowd :) .)

OK now, how would I write a rule to run "tar xzf" on this downloaded
file *only if* it was "just downloaded"?

This doesn't sound like such an unusual situation but I'm thoroughly
stumped.  For one thing, the directory resulting from running "tar
xzf" on a fresh download doesn't even exist yet, since its name
would have the form *_foo for some novel value of *, so make could
not compare the latest modification times of the new download
against that of this hypothetical directory...

Help!

TIA,

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.