Is it possible to have make
create a temp directory before it executes the first target? Maybe using some hack, some additional target etc.?
All commands in the Makefile would be able to refer to the automatically created directory as $TMPDIR
, and the directory would be automatically removed when the make
command ends.
With GNU make, at least,
TMPDIR := $(shell mktemp -d)
will get you your temporary directory. I can't come up with a good way to clean it up at the end, other than the obvious rmdir "$(TMPDIR)"
as part of the all
target.