From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/gnu_make/substitution-refs.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 devdocs/gnu_make/substitution-refs.html (limited to 'devdocs/gnu_make/substitution-refs.html') 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 @@ +

Substitution References

A substitution reference substitutes the value of a variable with alterations that you specify. It has the form ‘$(var:a=b)’ (or ‘${var:a=b}’) and its meaning is to take the value of the variable var, replace every a at the end of a word with b in that value, and substitute the resulting string.

When we say “at the end of a word”, we mean that a must appear either followed by whitespace or at the end of the value in order to be replaced; other occurrences of a in the value are unaltered. For example:

foo := a.o b.o l.a c.o
+bar := $(foo:.o=.c)
+
+

sets ‘bar’ to ‘a.c b.c l.a c.c’. See Setting Variables.

A substitution reference is shorthand for the patsubst expansion function (see Functions for String Substitution and Analysis): ‘$(var:a=b)’ is equivalent to ‘$(patsubst %a,%b,var)’. We provide substitution references as well as patsubst for compatibility with other implementations of make.

Another type of substitution reference lets you use the full power of the patsubst function. It has the same form ‘$(var:a=b)’ described above, except that now a must contain a single ‘%’ character. This case is equivalent to ‘$(patsubst a,b,$(var))’. See Functions for String Substitution and Analysis, for a description of the patsubst function. For example:

foo := a.o b.o l.a c.o
+bar := $(foo:%.o=%.c)
+
+

sets ‘bar’ to ‘a.c b.c l.a c.c’.

+

+ 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.
Licensed under the GNU Free Documentation License.
+ https://www.gnu.org/software/make/manual/html_node/Substitution-Refs.html +

+
-- cgit v1.2.3