On Tue, 2009-09-22 at 11:29 -0700, Derek Clegg wrote:
> I always use order-only prerequisites for directories. For example,
>
> bar/foo.o: foo.c | bar
> cc -o $@ -c $<
>
> bar:
> mkdir -p $@
Yes, this works well. The downside is that EVERY target that needs to
use that directory has to have the order-only prereq defined, which is
kind of a PITA if you have lots of targets for that directory. Of
course if you build with just one or a few pattern rules, not a problem.
Generally I just don't even worry about it, and force all the
directories to be created up-front:
_dummy := $(shell mkdir -p $(SUBDIRS))
this means that just invoking make, even without running any rules, will
cause all the directories to be created, while the OO prereq, etc.,
solutions will only create directories that are going to be needed.
But, most of the time I don't create directories I won't need, and even
if so it doesn't bother me to have some extra empty directories lying
around.
YMMV.
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make