help-make
[Top][All Lists]
Advanced

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

Re: about subst


From: Danny Boelens
Subject: Re: about subst
Date: Mon, 28 Aug 2006 10:16:23 +0200

----- Original Message ----- 
From: "Lin George" <address@hidden>
To: <address@hidden>
Sent: Sunday, August 27, 2006 2:18 PM
Subject: about subst


> Foo:
>     rm $(subst /,\,$@)
>
> Could anyone tell me what means $(subst /,\,$@)? Which
> page in the make manual covers this point?

There are multiple pages covering this single line.

First of all, this is a rule for Foo, the target, and the rule has no
prerequisites, only commands. See Chapter 4, Writing Rules.

Then we have the subst function (see 8.2 Functions for String Substitution
and Analysis) which is used as argument for rm. And just in case: rm is the
unix command to remove files are directories. Since the syntax is $(subst
fro, to, something) it is clear that this will replace forward slashes (/)
by backward slashes (\) in something ($@ in this case).

And finally we have $@, which is the file name of the target of the rule (or
the name of the archive file is the target is an archive member). See 10.5.3
Automatic Variables.

In your example the subst isn't doing much as there are no forward slashes
in your target. To give a better example:

some/dir/with/foo :
    rm $(subst /,\,$@)

is a rule for some/dir/with/foo, and when its commands are executed it will
(try to) remove some\dir\with\foo.

Hope this helps,
Danny





reply via email to

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