tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make: creating a file's parent directory



There must be an easier way doing what I want.

I have a rule generating dir/file and I need to make sure dir exists before 
that rule is run.
Now it's tempting to write

dir:
	test -d ${.TARGET} || ${INSTALL} -d ... ${.TARGET}

dir/file: dir ...
	... >${.TARGET}

but that causes dir/file's rule to be re-run if you touch dir/another_file, 
thus updating dir's time stamp.

I don't want to repeat the rule creating dir over several dir/file*'s rules.

I don't want to create dir unless some dir/file* actually needs to be created.

The best I came to think of was turning the dir rule into a .USEBEFORE and 
adding that to the dir/file* dependencies.

What one would need is a dependency operator insuring the sources do exist 
but not that the target is up-to-date relatively to them, which (I guess) 
doesn't exist.

There's an easier way, right?


Home | Main Index | Thread Index | Old Index