sweber
sweber

Reputation: 2986

Make: Dependency on newest file in directory

For a small project, I have the following workflow:

  1. compile code and generate ./data and ./images
  2. run code, which will write many files to ./data
  3. generate images from the data files, place them in ./images
  4. generate a video from the images

I have written a makefile, which can run the code, and compile it before, if necessary. But I don't know how to implement the dependencies of steps 3 and 4, and currently make that targets manually.

So, is there a way to check if e.g. the newest file in ./data is newer than the newest file in ./images ? It's not necessary to do this on a file-by-file basis, and the total number of data / image files is not known.

Upvotes: 1

Views: 79

Answers (1)

John
John

Reputation: 3520

Typically the date of the directory is the date that the last file was added/modified, so you could use the timestamp on the directory itself for dependencies.

images : data
     // generate images

Alternatively, if there is a mapping between the files in the two directories, you could do something like:

images/%.img: data/%.dat
    // generate image...

which would prevent reprocessing data that's already been handled.

Upvotes: 1

Related Questions