Using $(shell) to create these directories at each invocation is certainly one way to solve this problem. If you would like to take Noel's suggestion to use order-only prerequisites, you'll need to make one tiny change to his example. (See inline change in quoted message.) To read about order-only prerequisites, you can go here.
Section "4.3 Types of Prerequisites" http://www.gnu.org/software/make/manual/html_chapter/make_4.html#SEC29 An advantage to using order-only prerequisites is that you'll be able to see any error output from mkdir. Also, gmake will only try to create the directory if it doesn't already exist. Ken Smith On Wed, Jun 29, 2005 at 06:03:39PM -0400, Noel Yap wrote: > Have you tried using order dependencies? For example: > > %/.: > mkdir -p $@ > > $(MY_FILE): $(dirname $(MY_FILE))/. $(MY_FILE): | $(dirname $(MY_FILE))/. > > > HTH, > Noel > > Dan Oelke wrote: > > >Adam, > > > >I ran into almost the same problem. > >I had directories that I wanted the makefile to generate, but if I made > >the things in the directories dependent on the directories then I was > >constantly (and needlessly) rebuilding the world. > > > >I *just* solved it by not making those things in the directories > >dependent on the directory itself. Instead I just force a creation of > >the directory every time make is invoked by using := and $(shell). > >mkdir failures are silently ignored. For a small number of directories > >this isn't a big performance hit. The only thing that worries me is > >silently ignoring the mkdir failures. I ignore them because it fails > >once the directory is already there. > >Thanks to John Grahm-Cumming for writing up the idea of using := and shell. > > > >Using your example - it would now look something like this. > > > > # Create folders. > > #$(INTDIR) $(OUTDIR): > > # mkdir -p $@ > > DUMMY := $(shell mkdir -p $(INTDIR) 2>&1) > > DUMMY := $(shell mkdir -p $(OUTDIR) 2>&1) > > > > # Run definitions through the encoder. > > $(TARGET): $(OUTDIR) $(ENCODER) @echo "Generating > >Output..." > > $(ENCODER) gen.def $(OUTDIR) > > > > > >Hope this helps. > > > > > >_______________________________________________ > >Help-make mailing list > >[email protected] > >http://lists.gnu.org/mailman/listinfo/help-make > > > _______________________________________________ > Help-make mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/help-make _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
