help-make
[Top][All Lists]
Advanced

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

Re: Preconditions vs. Dependencies


From: Paul D. Smith
Subject: Re: Preconditions vs. Dependencies
Date: Mon, 21 Nov 2005 18:35:02 -0500

%% natch <address@hidden> writes:

  n> I'm having a dependency problem that I can't find a good solution
  n> to.  I want to create files inside a directory other than that in
  n> which make is executing.  The easy solution is that the files
  n> depend on the directory they are in, so make will not try to create
  n> the files unless the directory is created first.  However, if more
  n> than one file is created in that directory, the timestamp on the
  n> directory is updated, and make considers that prerequisite newer
  n> than the target.

I typically recommend using $(shell ...) to create directories.  IMO
it's the simplest way.  Trying to make sure that every target depends on
the right directories is a big PITA.  I just do:

    MKDIRLIST += foo
        ...
    MKDIRLIST += bar
        ...

then at the end of the makefiles I just say something like:

    _dummy := $(shell mkdir -p $(MKDIRLIST) 2>/dev/null)

this ensures they all get created before make starts looking around for
any targets.

The downside is that all directories are created all the time.  That
doesn't bother me but if you simply can't live with it (and you have a
sufficiently new version of GNU make) you can use order-only
prerequisites.

-- 
-------------------------------------------------------------------------------
 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]