> From: "Paul D. Smith" <[EMAIL PROTECTED]> > > rm> .PRECIOUS: %.mkdir > rm> %.mkdir: > rm> @mkdir -p $(dir $@) > rm> @touch $@ > > In this case you can just use $*.
I don't understand. If % expands to, say out/foo (because of %.o: %.c %.mkdir) then @mkdir -p $* => @mkdir -p out/foo @touch $* => @touch out/foo This isn't what you meant. > I don't see how this is that useful. I prefer the very straightforward: > > OBJDIR = ../../foo/bar > $(shell [ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)) > > The downside is directories are created which you might not need, but > it's quite a bit simpler and more reliable. I basically agree with you, Paul. I've been using this approach for quite a while (after reading your post about it). However, if you have many source files across many directories this can be troublesome: # Find the source. sources := $(shell find . -name '*.c') # Gather the directories to create. dirs := $(sort $(dir $(sources))) # Create them $(shell for d in $(dirs); do [ -d $$d ] || mkdir -p $$d; done) # or $(foreach d,$(dirs),$(shell [ -d $$d ] || mkdir -p $$d)) # of $(foreach d,$(dirs),$(if $(wildcard $d),,$(shell mkdir -p $$d))) Again, untested ;-) Cheers, Robert _______________________________________________ Help-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/help-make
