make-w32
[Top][All Lists]
Advanced

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

Re: Problem with Special Macros in GNU make-3.81


From: Paul D. Smith
Subject: Re: Problem with Special Macros in GNU make-3.81
Date: Wed, 28 Jun 2006 15:30:15 -0400

%% "Partha Roy" <address@hidden> writes:

  pr> I am attaching a makefile called maketest.mak.

  pr> I find that $(*F) Special Macro is not being printed under Windows
  pr> platform.

  pr> product.tst: depend.tst
  pr>   @echo $(*F) -- product

  pr> dummy1.o : dummy4.c
  pr>   @echo $(*F) -- dummy1

  pr> C:\Partha\GNU\MAKE\tcbtut63\MAKE\MAKE_TEST>c:\partha\gnu\make\gnumake -f 
maketest.mak
  pr> dummy1 -- dummy1
  pr>  -- product

  pr> Can you please confirm whether it is a BUG or not in GNU Make
  pr> version 3.81?

This is not a bug in GNU make; your makefile is not correct.

Some people think that $* resolves to something like "the target without
the .suffix", but that's not what it means at all.  It stands for the
_stem_ of the target name, after matching a pattern or suffix rule.  So,
in:

    %.o : %.c

Then $* will expand to whatever "%" matches.  Or, in suffix rules:

    .c.o:

Then $* will expand to the part of the target without the suffix.

In many traditional versions of make, $* is empty for ALL explicit rules
(all of your rules above are explicit).

GNU make gives a small enhancement: for explicit rules it will check the
.SUFFIXES list and if the target matches any suffix on it, make will set
$* to that target without the suffix.

That's why your rule dummy1.o : dummy4.c works: even though it's an
explicit rule, the .o suffix is listed in .SUFFIXES by default.

However, .SUFFIXES doesn't list ".txt", so your other explicit rule for
product.tst doesn't match and $* is not set... make has no idea what to
set it to!!  How can make know what the "stem" of this target name is?

You can either add ".txt" to the .SUFFIXES pseudo target, or you can
rewrite your rule to not use $*.


For full details on this, see the GNU make manual section "Automatic
Variables".

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