[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: folder deps
Re: folder deps
Thu, 30 Jun 2005 11:28:32 -0400
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"
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.
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))/.
> Dan Oelke wrote:
> >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
> > $(ENCODER) gen.def $(OUTDIR)
> >Hope this helps.
> >Help-make mailing list
> Help-make mailing list