%% Gianni Mariani <[EMAIL PROTECTED]> writes:

  gm> Let me clarify this better - I'd like to have one generic Makefile
  gm> fo a huge source tree.  I only want the work directory created in
  gm> directories where it makes sense.  I want to keep that complexity
  gm> away from the developer - or as much as possible away from
  gm> developers.

You can wrap the creation of the directory in a conditional, so it's
only invoked in directories where that makes sense.

The question is, what do you put in the conditional (what do you test)?
That's a question you'll have to answer for yourself.  One idea is that
if you know what variables may be set to what targets or prerequisites
that would cause the directory to be needed, you could test those to see
if they were empty or not.

Also, I took a closer look at the problem you're seeing, using the
original test makefile.

The issue is that make never even gets close to noticing that the
makefile could create that directory; it sees that the target in
question can't be created since the directory doesn't exist, and so it
just stops right there.  It doesn't even try to examine any
prerequisites of that target, to see that some prerequisites of _those_
might create the file.

  $(WORKDIR)/%.out : %.in $(DEPEND_DIR)
          cp $< $@

  /tmp/% : $(WORKDIR)/%
          cp $< $@

When make is trying to decide how to build /tmp/file.inst, it comes
across the second pattern rule above.  It then tries to see if it can
build $(WORKDIR)/file.inst, and right there it sees that $(WORKDIR)
doesn't exist and fails.  It never even gets to looking at the rule with
$(DEPEND_DIR) as the prerequisite.

There is no simple change that can be made to "fix" this, except for the
one you made which basically disables the entire "pruning non-existent
directories" feature.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.ultranet.com/~pauld/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

Reply via email to