help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating directories for VPATH to search


From: Paul D. Smith
Subject: Re: Creating directories for VPATH to search
Date: Fri, 6 Jan 2006 08:42:21 -0500

%% "Norman Wilson" <address@hidden> writes:

  nw> Consider:
  nw> VPATH = .:other

  nw> foo: bar
  nw>   ln -s $(<) $(@)

  nw> other/bar: | other
  nw>   touch $(@)

  nw> other:
  nw>   mkdir $(@)

  nw> So, I'm saying if you don't find a file in the current directory
  nw> look in other. The top level target requires bar. I give a rule
  nw> for creating bar under other. I also give rule for creating other.

  nw> I'd expect make to see that there is no bar in the current
  nw> directory, see that there is a rule for creating it under other,
  nw> and that other is in the VPATH, and therefore work out that
  nw> other/bar must be created and then used as the prereq for foo.

No, that's not how make works.  Directories in VPATH are not "implicit";
that is, they don't participate in rule chaining.

  nw> If other exists then this makefile has the desired affect. If
  nw> other does not exist I get:

  nw> make: *** No rule to make target `bar', needed by `foo'.  Stop.

You can use an alternative method of directory creation; this is what I
always use rather than order-only prereqs:

    _dummy := $(shell [ -d other ] || mkdir -p other)

Now, the directory will be created as the makefile is read in, well
before make starts looking for targets to build.  The advantage of this
is (a) you don't have to use o-o prereqs (which you might forget to add
to some important target), and (b) make works properly in situations
such as you describe.

The disadvantage is that the directory will always be created when you
run make, even if none of the targets are built that would otherwise
need it.

  nw> Is this fixed in the beta release?

It's not a bug (at least I don't consider it a bug).  It's how make has
always worked and it follows the documentation, and conforms to the
behavior of other versions of make that support VPATH.

You can file an enhancement request on Savannah though if you like.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]