fgregg
fgregg

Reputation: 3249

Clean up unmentioned intermediate files in Make

I have a Makefile that builds a shapefile as an intermediate steps.

.INTERMEDIATE : senate_boundaries.shp
senate_boundaries.shp : Senate\ shape\ files.zip
     unzip -j "$<"

A full shapefile comes with more than just a .shp, but also a .prj file, a .dbf file, and a bunch of others. These files are created when "Senate shape files.zip" is unzipped.

These other files are never an explicit target or dependency.

.INTERMEDIATE : senate_boundaries.prj senate_boundaries.dbf 

does not seem to do anything.

How can I tell Make to clean up these other files?

Upvotes: 0

Views: 232

Answers (1)

bentank
bentank

Reputation: 616

You can add something like this to your recipe:

rm -f $(wildcard Senate\shape\*.prj)

But that will only work for that one file and you would have to manually add each extension to get rid of.

so something like this might do the trick:

rm -f $(shell ls Senate\shape\ | grep -v .shp&)

Another option is to unzip into a temp directory and then copy the file you want out and remove the the temp directory.

Upvotes: 1

Related Questions