miroli
miroli

Reputation: 234

Make contents of compressed archive make target

Suppose I need to download a zipped archive containing thousands of compressed CSV files, and unzip it, and I want to use make for that process. The first step is easy:

myarchive.zip:
    curl -o myarchive.zip 'http://path/to/archive.zip'

But before downloading the archive, I don't know the name of every file in it. This doesn't work.

extracted/*.csv: myarchive.zip
    unzip myarchive.zip -d extracted

How do I let make know that all of these CSV files are targets?

Upvotes: 1

Views: 184

Answers (1)

Beta
Beta

Reputation: 99154

It's not clear exactly what you want, but this is probably close:

ARCHIVE_DIR := extracted

.PHONY: archive
archive: myarchive.zip
    unzip $< -d $(ARCHIVE_DIR)

myarchive.zip:
    curl -o $@ 'http://path/to/archive.zip'

Upvotes: 1

Related Questions