[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: basename function does nothing when it appears in prerequisites
From: |
Paul D. Smith |
Subject: |
RE: basename function does nothing when it appears in prerequisites |
Date: |
Sun, 9 Sep 2001 16:18:15 -0400 |
%% Matt Swift <address@hidden> writes:
ms> I understand the explanation, but I do not understand why, if it
ms> applies to the $(basename) function, it does not apply to the
ms> $(addsuffix) function. If addsuffix behaved like basename, then
ms> the dependency list for the target foo.yy would be ".zz" instead
ms> of "foo.yy.zz" (which it is by experiment -- that's why this was
ms> in the test makefile).
Well, it's a little obscure I suppose. Let's look:
ms> foo.yy: %: $(addsuffix .zz, %)
In this case, what does the function expand to? Well, it adds the .zz
suffix to its arguments, so you'll get:
foo.yy: %: %.zz
OK, that works! Because when make goes through to replace the "%"
characters with the proper values, it'll replace the "%" with "foo.yy"
and you'll get "foo.yy.zz" just as you want.
ms> foo.xx: %: $(basename %)
In this case, what is basename of "%"? Just "%" itself, so you end up
with this:
foo.xx: %: %
This is not correct, because it's equivalent to "foo.xx: foo.xx", which
is never a good thing in a makefile :)
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist