summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/substitution-refs.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/gnu_make/substitution-refs.html')
-rw-r--r--devdocs/gnu_make/substitution-refs.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/gnu_make/substitution-refs.html b/devdocs/gnu_make/substitution-refs.html
new file mode 100644
index 00000000..4b6b000f
--- /dev/null
+++ b/devdocs/gnu_make/substitution-refs.html
@@ -0,0 +1,12 @@
+ <h1 class="subsection">Substitution References</h1> <p>A <em>substitution reference</em> substitutes the value of a variable with alterations that you specify. It has the form ‘<samp>$(<var>var</var>:<var>a</var>=<var>b</var>)</samp>’ (or ‘<samp>${<var>var</var>:<var>a</var>=<var>b</var>}</samp>’) and its meaning is to take the value of the variable <var>var</var>, replace every <var>a</var> at the end of a word with <var>b</var> in that value, and substitute the resulting string. </p> <p>When we say “at the end of a word”, we mean that <var>a</var> must appear either followed by whitespace or at the end of the value in order to be replaced; other occurrences of <var>a</var> in the value are unaltered. For example: </p> <div class="example"> <pre class="example">foo := a.o b.o l.a c.o
+bar := $(foo:.o=.c)
+</pre>
+</div> <p>sets ‘<samp>bar</samp>’ to ‘<samp>a.c b.c l.a c.c</samp>’. See <a href="setting">Setting Variables</a>. </p> <p>A substitution reference is shorthand for the <code>patsubst</code> expansion function (see <a href="text-functions">Functions for String Substitution and Analysis</a>): ‘<samp>$(<var>var</var>:<var>a</var>=<var>b</var>)</samp>’ is equivalent to ‘<samp>$(patsubst %<var>a</var>,%<var>b</var>,<var>var</var>)</samp>’. We provide substitution references as well as <code>patsubst</code> for compatibility with other implementations of <code>make</code>. </p> <p>Another type of substitution reference lets you use the full power of the <code>patsubst</code> function. It has the same form ‘<samp>$(<var>var</var>:<var>a</var>=<var>b</var>)</samp>’ described above, except that now <var>a</var> must contain a single ‘<samp>%</samp>’ character. This case is equivalent to ‘<samp>$(patsubst <var>a</var>,<var>b</var>,$(<var>var</var>))</samp>’. See <a href="text-functions">Functions for String Substitution and Analysis</a>, for a description of the <code>patsubst</code> function. For example: </p> <div class="example"> <pre class="example">foo := a.o b.o l.a c.o
+bar := $(foo:%.o=%.c)
+</pre>
+</div> <p>sets ‘<samp>bar</samp>’ to ‘<samp>a.c b.c l.a c.c</samp>’. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Free Software Foundation, Inc. <br>Licensed under the GNU Free Documentation License.<br>
+ <a href="https://www.gnu.org/software/make/manual/html_node/Substitution-Refs.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Substitution-Refs.html</a>
+ </p>
+</div>