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/pattern_002dspecific.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 devdocs/gnu_make/pattern_002dspecific.html (limited to 'devdocs/gnu_make/pattern_002dspecific.html') diff --git a/devdocs/gnu_make/pattern_002dspecific.html b/devdocs/gnu_make/pattern_002dspecific.html new file mode 100644 index 00000000..11ff5f30 --- /dev/null +++ b/devdocs/gnu_make/pattern_002dspecific.html @@ -0,0 +1,18 @@ +

Pattern-specific Variable Values

In addition to target-specific variable values (see Target-specific Variable Values), GNU make supports pattern-specific variable values. In this form, the variable is defined for any target that matches the pattern specified.

Set a pattern-specific variable value like this:

pattern … : variable-assignment
+
+

where pattern is a %-pattern. As with target-specific variable values, multiple pattern values create a pattern-specific variable value for each pattern individually. The variable-assignment can be any valid form of assignment. Any command line variable setting will take precedence, unless override is specified.

For example:

%.o : CFLAGS = -O
+
+

will assign CFLAGS the value of ‘-O’ for all targets matching the pattern %.o.

If a target matches more than one pattern, the matching pattern-specific variables with longer stems are interpreted first. This results in more specific variables taking precedence over the more generic ones, for example:

%.o: %.c
+        $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+lib/%.o: CFLAGS := -fPIC -g
+%.o: CFLAGS := -g
+
+all: foo.o lib/bar.o
+
+

In this example the first definition of the CFLAGS variable will be used to update lib/bar.o even though the second one also applies to this target. Pattern-specific variables which result in the same stem length are considered in the order in which they were defined in the makefile.

Pattern-specific variables are searched after any target-specific variables defined explicitly for that target, and before target-specific variables defined for the parent target.

+

+ 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/Pattern_002dspecific.html +

+
-- cgit v1.2.3