help-make
[Top][All Lists]
Advanced

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

Re: exception to Paul's Second Rule?


From: Paul D. Smith
Subject: Re: exception to Paul's Second Rule?
Date: Thu, 16 Oct 2003 16:26:28 -0400

%% "Robert Mecklenburg" <address@hidden> writes:

  rm> Is there a reason why you didn't use either of:

  rm>   @mkdir -p $(dir $(dir $(dir $@)))
  rm>   @mkdir -p $(dir $(patsubst %/../...,%,$@))

  rm> I haven't tried them, but I assume they work. ;-)

Nope.  $(dir ...) is defined very strangely: it leaves the trailing
slash, so multiple dir's are no-ops.  $(dir $(dir ...)) is identical to
just $(dir ...).

Just try it and see:

  $ echo 'all: ; @echo $(dir $(dir /foo/bar/baz))' | make -f-
  /foo/bar

  rm> .PRECIOUS: %.mkdir
  rm> %.mkdir:
  rm>         @mkdir -p $(dir $@)
  rm>         @touch $@

In this case you can just use $*.

  rm> Now I grant you, the "cool factor" of yours is way beyond the
  rm> "slow" version, but this one actually follows Paul's second rule
  rm> at the cost of more files created and visible to the user.  (Not a
  rm> trivial cost, I admit.)

  rm> A very interesting idea!

I don't see how this is that useful.  I prefer the very straightforward:

  OBJDIR = ../../foo/bar

  $(shell [ -d $(OBJDIR) ] || mkdir -p $(OBJDIR))


The downside is directories are created which you might not need, but
it's quite a bit simpler and more reliable.

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