Sunday, August 19, 2007

Gnu-make: patsubst

is equivalent to
$(patsubst pattern,replacement,$(var))
The second shorthand simplifies one of the most common uses of patsubst:
replacing the suffix at the end of file names.
is equivalent to
$(patsubst %suffix,%replacement,$(var))
For example, you might have a list of object files:
objects = foo.o bar.o baz.o
To get the list of corresponding source files, you could simply write:
instead of using the general form:
$(patsubst %.o,%.c,$(objects))

No comments:

Blog Archive