简体   繁体   中英

Makefile: assume file is up to date for a specific target?

I'm using GNU Make to build graphs for a paper. I have two targets:

  • data which rebuilds the data/*.csv folder. This is very computationally expensive. (Also in terms of money.)
  • plot which rebuilds the plots from the data/ folder

Now, because of how expensive data is to compute, I committed the resulting files in git. I'd like to avoid changing them whenever possible. But when someone clones the git repository, it messes the mtime of the files, so make plot wants to rebuild data , even though they're already there.

That said, I don't want to remove the target dependency! If, for some reason, I recompute something in data , I want the plots to see that and to be able to rebuild themselves. Also, if one csv is missing, I want it to be computed.

I think ideally, what I want is to have a way to say "if these files are present, assume that they are up to date". Is there a way to do that in GNU Make?

Thanks to the comment of Renaud Pacalet, I used order-only dependencies to rewrite my rule like this:

data/%.csv: | source/%.py
    ...

Using this | allows make to never rebuild a CSV file already present.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM