--- make-doc-non-dfsg-3.81.orig/doc/make/make_8.html
+++ make-doc-non-dfsg-3.81/doc/make/make_8.html
@@ -0,0 +1,1451 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
+<html>
+<!-- This file documents the GNU make utility, which determines
+automatically which pieces of a large program need to be recompiled,
+and issues the commands to recompile them.
+
+This is Edition 0.70, last updated 1 April 2006,
+of The GNU Make Manual, for GNU make version 3.81.
+
+Copyright C 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.2 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with the Front-Cover Texts being "A GNU Manual,"
+and with the Back-Cover Texts as in (a) below. A copy of the
+license is included in the section entitled "GNU Free Documentation
+License."
+
+(a) The FSF's Back-Cover Text is: "You have freedom to copy and modify
+this GNU Manual, like GNU software. Copies published by the Free
+Software Foundation raise funds for GNU development."
+
+ -->
+<!-- Created on August, 17 2009 by texi2html 1.78 -->
+<!--
+Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
+ Karl Berry <karl@freefriends.org>
+ Olaf Bachmann <obachman@mathematik.uni-kl.de>
+ and many others.
+Maintained by: Many creative people.
+Send bugs and suggestions to <texi2html-bug@nongnu.org>
+
+-->
+<head>
+<title>GNU make: 8. Functions for Transforming Text</title>
+
+<meta name="description" content="GNU make: 8. Functions for Transforming Text">
+<meta name="keywords" content="GNU make: 8. Functions for Transforming Text">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2html 1.78">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<style type="text/css">
+<!--
+a.summary-letter {text-decoration: none}
+pre.display {font-family: serif}
+pre.format {font-family: serif}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+pre.smalldisplay {font-family: serif; font-size: smaller}
+pre.smallexample {font-size: smaller}
+pre.smallformat {font-family: serif; font-size: smaller}
+pre.smalllisp {font-size: smaller}
+span.roman {font-family:serif; font-weight:normal;}
+span.sansserif {font-family:sans-serif; font-weight:normal;}
+ul.toc {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+
+<a name="Functions"></a>
+<a name="SEC92"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="make_7.html#SEC91" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC93" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make_7.html#SEC88" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h1 class="chapter"> 8. Functions for Transforming Text </h1>
+
+<p><em>Functions</em> allow you to do text processing in the makefile to compute
+the files to operate on or the commands to use. You use a function in a
+<em>function call</em>, where you give the name of the function and some text
+(the <em>arguments</em>) for the function to operate on. The result of the
+function's processing is substituted into the makefile at the point of the
+call, just as a variable might be substituted.
+</p>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a href="#SEC93">8.1 Function Call Syntax</a></td><td> </td><td align="left" valign="top"> How to write a function call.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC94">8.2 Functions for String Substitution and Analysis</a></td><td> </td><td align="left" valign="top"> General-purpose text manipulation functions.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC95">8.3 Functions for File Names</a></td><td> </td><td align="left" valign="top"> Functions for manipulating file names.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC96">8.4 Functions for Conditionals</a></td><td> </td><td align="left" valign="top"> Functions that implement conditions.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC97">8.5 The <code>foreach</code> Function</a></td><td> </td><td align="left" valign="top"> Repeat some text with controlled variation.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC98">8.6 The <code>call</code> Function</a></td><td> </td><td align="left" valign="top"> Expand a user-defined function.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC99">8.7 The <code>value</code> Function</a></td><td> </td><td align="left" valign="top"> Return the un-expanded value of a variable.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC100">8.8 The <code>eval</code> Function</a></td><td> </td><td align="left" valign="top"> Evaluate the arguments as makefile syntax.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC101">8.9 The <code>origin</code> Function</a></td><td> </td><td align="left" valign="top"> Find where a variable got its value.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC102">8.10 The <code>flavor</code> Function</a></td><td> </td><td align="left" valign="top"> Find out the flavor of a variable.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC103">8.11 The <code>shell</code> Function</a></td><td> </td><td align="left" valign="top"> Substitute the output of a shell command.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#SEC104">8.12 Functions That Control Make</a></td><td> </td><td align="left" valign="top"> Functions that control how make runs.
+</td></tr>
+</table>
+
+<hr size="6">
+<a name="Syntax-of-Functions"></a>
+<a name="SEC93"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC92" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC94" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.1 Function Call Syntax </h2>
+
+<p>A function call resembles a variable reference. It looks like this:
+</p>
+<table><tr><td> </td><td><pre class="example">$(<var>function</var> <var>arguments</var>)
+</pre></td></tr></table>
+
+<p>or like this:
+</p>
+<table><tr><td> </td><td><pre class="example">${<var>function</var> <var>arguments</var>}
+</pre></td></tr></table>
+
+<p>Here <var>function</var> is a function name; one of a short list of names
+that are part of <code>make</code>. You can also essentially create your own
+functions by using the <code>call</code> builtin function.
+</p>
+<p>The <var>arguments</var> are the arguments of the function. They are
+separated from the function name by one or more spaces or tabs, and if
+there is more than one argument, then they are separated by commas.
+Such whitespace and commas are not part of an argument's value. The
+delimiters which you use to surround the function call, whether
+parentheses or braces, can appear in an argument only in matching pairs;
+the other kind of delimiters may appear singly. If the arguments
+themselves contain other function calls or variable references, it is
+wisest to use the same kind of delimiters for all the references; write
+‘<samp>$(subst a,b,$(x))</samp>’, not ‘<samp>$(subst a,b,${x})</samp>’. This
+is because it is clearer, and because only one type of delimiter is
+matched to find the end of the reference.
+</p>
+<p>The text written for each argument is processed by substitution of
+variables and function calls to produce the argument value, which
+is the text on which the function acts. The substitution is done in the
+order in which the arguments appear.
+</p>
+<p>Commas and unmatched parentheses or braces cannot appear in the text of an
+argument as written; leading spaces cannot appear in the text of the first
+argument as written. These characters can be put into the argument value
+by variable substitution. First define variables <code>comma</code> and
+<code>space</code> whose values are isolated comma and space characters, then
+substitute these variables where such characters are wanted, like this:
+</p>
+<table><tr><td> </td><td><pre class="example">comma:= ,
+empty:=
+space:= $(empty) $(empty)
+foo:= a b c
+bar:= $(subst $(space),$(comma),$(foo))
+# <span class="roman">bar is now `a,b,c'.</span>
+</pre></td></tr></table>
+
+<p>Here the <code>subst</code> function replaces each space with a comma, through
+the value of <code>foo</code>, and substitutes the result.
+</p>
+<hr size="6">
+<a name="Text-Functions"></a>
+<a name="SEC94"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC93" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC95" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.2 Functions for String Substitution and Analysis </h2>
+
+<p>Here are some functions that operate on strings:
+</p>
+<dl compact="compact">
+<dt> <code>$(subst <var>from</var>,<var>to</var>,<var>text</var>)</code></dt>
+<dd><a name="IDX257"></a>
+<p>Performs a textual replacement on the text <var>text</var>: each occurrence
+of <var>from</var> is replaced by <var>to</var>. The result is substituted for
+the function call. For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(subst ee,EE,feet on the street)
+</pre></td></tr></table>
+
+<p>substitutes the string ‘<samp>fEEt on the strEEt</samp>’.
+</p>
+</dd>
+<dt> <code>$(patsubst <var>pattern</var>,<var>replacement</var>,<var>text</var>)</code></dt>
+<dd><a name="IDX258"></a>
+<p>Finds whitespace-separated words in <var>text</var> that match
+<var>pattern</var> and replaces them with <var>replacement</var>. Here
+<var>pattern</var> may contain a ‘<samp>%</samp>’ which acts as a wildcard,
+matching any number of any characters within a word. If
+<var>replacement</var> also contains a ‘<samp>%</samp>’, the ‘<samp>%</samp>’ is replaced
+by the text that matched the ‘<samp>%</samp>’ in <var>pattern</var>. Only the first
+‘<samp>%</samp>’ in the <var>pattern</var> and <var>replacement</var> is treated this
+way; any subsequent ‘<samp>%</samp>’ is unchanged.
+</p>
+<a name="IDX259"></a>
+<a name="IDX260"></a>
+<a name="IDX261"></a>
+<a name="IDX262"></a>
+<a name="IDX263"></a>
+<p>‘<samp>%</samp>’ characters in <code>patsubst</code> function invocations can be
+quoted with preceding backslashes (‘<samp>\</samp>’). Backslashes that would
+otherwise quote ‘<samp>%</samp>’ characters can be quoted with more backslashes.
+Backslashes that quote ‘<samp>%</samp>’ characters or other backslashes are
+removed from the pattern before it is compared file names or has a stem
+substituted into it. Backslashes that are not in danger of quoting
+‘<samp>%</samp>’ characters go unmolested. For example, the pattern
+‘<tt>the\%weird\\%pattern\\</tt>’ has ‘<samp>the%weird\</samp>’ preceding the
+operative ‘<samp>%</samp>’ character, and ‘<samp>pattern\\</samp>’ following it. The
+final two backslashes are left alone because they cannot affect any
+‘<samp>%</samp>’ character.
+</p>
+<p>Whitespace between words is folded into single space characters;
+leading and trailing whitespace is discarded.
+</p>
+<p>For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(patsubst %.c,%.o,x.c.c bar.c)
+</pre></td></tr></table>
+
+<p>produces the value ‘<samp>x.c.o bar.o</samp>’.
+</p>
+<p>Substitution references (see section <a href="make_6.html#SEC78">Substitution References</a>) are a simpler way to get the effect of the <code>patsubst</code>
+function:
+</p>
+<table><tr><td> </td><td><pre class="example">$(<var>var</var>:<var>pattern</var>=<var>replacement</var>)
+</pre></td></tr></table>
+
+<p>is equivalent to
+</p>
+<table><tr><td> </td><td><pre class="example">$(patsubst <var>pattern</var>,<var>replacement</var>,$(<var>var</var>))
+</pre></td></tr></table>
+
+<p>The second shorthand simplifies one of the most common uses of
+<code>patsubst</code>: replacing the suffix at the end of file names.
+</p>
+<table><tr><td> </td><td><pre class="example">$(<var>var</var>:<var>suffix</var>=<var>replacement</var>)
+</pre></td></tr></table>
+
+<p>is equivalent to
+</p>
+<table><tr><td> </td><td><pre class="example">$(patsubst %<var>suffix</var>,%<var>replacement</var>,$(<var>var</var>))
+</pre></td></tr></table>
+
+<p>For example, you might have a list of object files:
+</p>
+<table><tr><td> </td><td><pre class="example">objects = foo.o bar.o baz.o
+</pre></td></tr></table>
+
+<p>To get the list of corresponding source files, you could simply write:
+</p>
+<table><tr><td> </td><td><pre class="example">$(objects:.o=.c)
+</pre></td></tr></table>
+
+<p>instead of using the general form:
+</p>
+<table><tr><td> </td><td><pre class="example">$(patsubst %.o,%.c,$(objects))
+</pre></td></tr></table>
+
+</dd>
+<dt> <code>$(strip <var>string</var>)</code></dt>
+<dd><a name="IDX264"></a>
+<a name="IDX265"></a>
+<a name="IDX266"></a>
+<a name="IDX267"></a>
+<p>Removes leading and trailing whitespace from <var>string</var> and replaces
+each internal sequence of one or more whitespace characters with a
+single space. Thus, ‘<samp>$(strip a b c )</samp>’ results in ‘<samp>a b c</samp>’.
+</p>
+<p>The function <code>strip</code> can be very useful when used in conjunction
+with conditionals. When comparing something with the empty string
+‘<samp></samp>’ using <code>ifeq</code> or <code>ifneq</code>, you usually want a string of
+just whitespace to match the empty string (see section <a href="make_7.html#SEC88">Conditional Parts of Makefiles</a>).
+</p>
+<p>Thus, the following may fail to have the desired results:
+</p>
+<table><tr><td> </td><td><pre class="example">.PHONY: all
+ifneq "$(needs_made)" ""
+all: $(needs_made)
+else
+all:;@echo 'Nothing to make!'
+endif
+</pre></td></tr></table>
+
+<p>Replacing the variable reference ‘<samp>$(needs_made)</samp>’ with the
+function call ‘<samp>$(strip $(needs_made))</samp>’ in the <code>ifneq</code>
+directive would make it more robust.
+</p>
+</dd>
+<dt> <code>$(findstring <var>find</var>,<var>in</var>)</code></dt>
+<dd><a name="IDX268"></a>
+<a name="IDX269"></a>
+<a name="IDX270"></a>
+<a name="IDX271"></a>
+<p>Searches <var>in</var> for an occurrence of <var>find</var>. If it occurs, the
+value is <var>find</var>; otherwise, the value is empty. You can use this
+function in a conditional to test for the presence of a specific
+substring in a given string. Thus, the two examples,
+</p>
+<table><tr><td> </td><td><pre class="example">$(findstring a,a b c)
+$(findstring a,b c)
+</pre></td></tr></table>
+
+<p>produce the values ‘<samp>a</samp>’ and ‘<samp></samp>’ (the empty string),
+respectively. See section <a href="make_7.html#SEC91">Conditionals that Test Flags</a>, for a practical application of
+<code>findstring</code>.
+</p>
+<a name="IDX272"></a>
+<a name="IDX273"></a>
+<a name="IDX274"></a>
+</dd>
+<dt> <code>$(filter <var>pattern</var>…,<var>text</var>)</code></dt>
+<dd><p>Returns all whitespace-separated words in <var>text</var> that <em>do</em> match
+any of the <var>pattern</var> words, removing any words that <em>do not</em>
+match. The patterns are written using ‘<samp>%</samp>’, just like the patterns
+used in the <code>patsubst</code> function above.
+</p>
+<p>The <code>filter</code> function can be used to separate out different types
+of strings (such as file names) in a variable. For example:
+</p>
+<table><tr><td> </td><td><pre class="example">sources := foo.c bar.c baz.s ugh.h
+foo: $(sources)
+ cc $(filter %.c %.s,$(sources)) -o foo
+</pre></td></tr></table>
+
+<p>says that ‘<tt>foo</tt>’ depends of ‘<tt>foo.c</tt>’, ‘<tt>bar.c</tt>’,
+‘<tt>baz.s</tt>’ and ‘<tt>ugh.h</tt>’ but only ‘<tt>foo.c</tt>’, ‘<tt>bar.c</tt>’ and
+‘<tt>baz.s</tt>’ should be specified in the command to the
+compiler.
+</p>
+</dd>
+<dt> <code>$(filter-out <var>pattern</var>…,<var>text</var>)</code></dt>
+<dd><a name="IDX275"></a>
+<a name="IDX276"></a>
+<a name="IDX277"></a>
+<p>Returns all whitespace-separated words in <var>text</var> that <em>do not</em>
+match any of the <var>pattern</var> words, removing the words that <em>do</em>
+match one or more. This is the exact opposite of the <code>filter</code>
+function.
+</p>
+<p>For example, given:
+</p>
+<table><tr><td> </td><td><pre class="example">objects=main1.o foo.o main2.o bar.o
+mains=main1.o main2.o
+</pre></td></tr></table>
+
+<p>the following generates a list which contains all the object files not
+in ‘<samp>mains</samp>’:
+</p>
+<table><tr><td> </td><td><pre class="example">$(filter-out $(mains),$(objects))
+</pre></td></tr></table>
+
+<a name="IDX278"></a>
+<a name="IDX279"></a>
+</dd>
+<dt> <code>$(sort <var>list</var>)</code></dt>
+<dd><p>Sorts the words of <var>list</var> in lexical order, removing duplicate
+words. The output is a list of words separated by single spaces.
+Thus,
+</p>
+<table><tr><td> </td><td><pre class="example">$(sort foo bar lose)
+</pre></td></tr></table>
+
+<p>returns the value ‘<samp>bar foo lose</samp>’.
+</p>
+<a name="IDX280"></a>
+<a name="IDX281"></a>
+<a name="IDX282"></a>
+<p>Incidentally, since <code>sort</code> removes duplicate words, you can use
+it for this purpose even if you don't care about the sort order.
+</p>
+</dd>
+<dt> <code>$(word <var>n</var>,<var>text</var>)</code></dt>
+<dd><a name="IDX283"></a>
+<a name="IDX284"></a>
+<a name="IDX285"></a>
+<p>Returns the <var>n</var>th word of <var>text</var>. The legitimate values of
+<var>n</var> start from 1. If <var>n</var> is bigger than the number of words
+in <var>text</var>, the value is empty. For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(word 2, foo bar baz)
+</pre></td></tr></table>
+
+<p>returns ‘<samp>bar</samp>’.
+</p>
+</dd>
+<dt> <code>$(wordlist <var>s</var>,<var>e</var>,<var>text</var>)</code></dt>
+<dd><a name="IDX286"></a>
+<a name="IDX287"></a>
+<a name="IDX288"></a>
+<p>Returns the list of words in <var>text</var> starting with word <var>s</var> and
+ending with word <var>e</var> (inclusive). The legitimate values of <var>s</var>
+start from 1; <var>e</var> may start from 0. If <var>s</var> is bigger than the
+number of words in <var>text</var>, the value is empty. If <var>e</var> is
+bigger than the number of words in <var>text</var>, words up to the end of
+<var>text</var> are returned. If <var>s</var> is greater than <var>e</var>, nothing
+is returned. For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(wordlist 2, 3, foo bar baz)
+</pre></td></tr></table>
+
+<p>returns ‘<samp>bar baz</samp>’.
+</p>
+</dd>
+<dt> <code>$(words <var>text</var>)</code></dt>
+<dd><a name="IDX289"></a>
+<a name="IDX290"></a>
+<p>Returns the number of words in <var>text</var>.
+Thus, the last word of <var>text</var> is
+<code>$(word $(words <var>text</var>),<var>text</var>)</code>.
+</p>
+</dd>
+<dt> <code>$(firstword <var>names</var>…)</code></dt>
+<dd><a name="IDX291"></a>
+<a name="IDX292"></a>
+<p>The argument <var>names</var> is regarded as a series of names, separated
+by whitespace. The value is the first name in the series. The rest
+of the names are ignored.
+</p>
+<p>For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(firstword foo bar)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>foo</samp>’. Although <code>$(firstword
+<var>text</var>)</code> is the same as <code>$(word 1,<var>text</var>)</code>, the
+<code>firstword</code> function is retained for its simplicity.
+</p>
+
+</dd>
+<dt> <code>$(lastword <var>names</var>…)</code></dt>
+<dd><a name="IDX293"></a>
+<a name="IDX294"></a>
+<p>The argument <var>names</var> is regarded as a series of names, separated
+by whitespace. The value is the last name in the series.
+</p>
+<p>For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(lastword foo bar)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>bar</samp>’. Although <code>$(lastword
+<var>text</var>)</code> is the same as <code>$(word $(words <var>text</var>),<var>text</var>)</code>,
+the <code>lastword</code> function was added for its simplicity and better
+performance.
+</p></dd>
+</dl>
+
+
+<p>Here is a realistic example of the use of <code>subst</code> and
+<code>patsubst</code>. Suppose that a makefile uses the <code>VPATH</code> variable
+to specify a list of directories that <code>make</code> should search for
+prerequisite files
+(see section <a href="make_4.html#SEC39"><code>VPATH</code> Search Path for All Prerequisites</a>).
+This example shows how to
+tell the C compiler to search for header files in the same list of
+directories.
+</p>
+<p>The value of <code>VPATH</code> is a list of directories separated by colons,
+such as ‘<samp>src:../headers</samp>’. First, the <code>subst</code> function is used to
+change the colons to spaces:
+</p>
+<table><tr><td> </td><td><pre class="example">$(subst :, ,$(VPATH))
+</pre></td></tr></table>
+
+<p>This produces ‘<samp>src ../headers</samp>’. Then <code>patsubst</code> is used to turn
+each directory name into a ‘<samp>-I</samp>’ flag. These can be added to the
+value of the variable <code>CFLAGS</code>, which is passed automatically to the C
+compiler, like this:
+</p>
+<table><tr><td> </td><td><pre class="example">override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH)))
+</pre></td></tr></table>
+
+<p>The effect is to append the text ‘<samp>-Isrc -I../headers</samp>’ to the
+previously given value of <code>CFLAGS</code>. The <code>override</code> directive is
+used so that the new value is assigned even if the previous value of
+<code>CFLAGS</code> was specified with a command argument (see section <a href="make_6.html#SEC83">The <code>override</code> Directive</a>).
+</p>
+<hr size="6">
+<a name="File-Name-Functions"></a>
+<a name="SEC95"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC94" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC96" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.3 Functions for File Names </h2>
+
+<p>Several of the built-in expansion functions relate specifically to
+taking apart file names or lists of file names.
+</p>
+<p>Each of the following functions performs a specific transformation on a
+file name. The argument of the function is regarded as a series of file
+names, separated by whitespace. (Leading and trailing whitespace is
+ignored.) Each file name in the series is transformed in the same way and
+the results are concatenated with single spaces between them.
+</p>
+<dl compact="compact">
+<dt> <code>$(dir <var>names</var>…)</code></dt>
+<dd><a name="IDX295"></a>
+<a name="IDX296"></a>
+<a name="IDX297"></a>
+<p>Extracts the directory-part of each file name in <var>names</var>. The
+directory-part of the file name is everything up through (and
+including) the last slash in it. If the file name contains no slash,
+the directory part is the string ‘<samp>./</samp>’. For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(dir src/foo.c hacks)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>src/ ./</samp>’.
+</p>
+</dd>
+<dt> <code>$(notdir <var>names</var>…)</code></dt>
+<dd><a name="IDX298"></a>
+<a name="IDX299"></a>
+<a name="IDX300"></a>
+<p>Extracts all but the directory-part of each file name in <var>names</var>.
+If the file name contains no slash, it is left unchanged. Otherwise,
+everything through the last slash is removed from it.
+</p>
+<p>A file name that ends with a slash becomes an empty string. This is
+unfortunate, because it means that the result does not always have the
+same number of whitespace-separated file names as the argument had;
+but we do not see any other valid alternative.
+</p>
+<p>For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(notdir src/foo.c hacks)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>foo.c hacks</samp>’.
+</p>
+</dd>
+<dt> <code>$(suffix <var>names</var>…)</code></dt>
+<dd><a name="IDX301"></a>
+<a name="IDX302"></a>
+<a name="IDX303"></a>
+<p>Extracts the suffix of each file name in <var>names</var>. If the file name
+contains a period, the suffix is everything starting with the last
+period. Otherwise, the suffix is the empty string. This frequently
+means that the result will be empty when <var>names</var> is not, and if
+<var>names</var> contains multiple file names, the result may contain fewer
+file names.
+</p>
+<p>For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(suffix src/foo.c src-1.0/bar.c hacks)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>.c .c</samp>’.
+</p>
+</dd>
+<dt> <code>$(basename <var>names</var>…)</code></dt>
+<dd><a name="IDX304"></a>
+<a name="IDX305"></a>
+<a name="IDX306"></a>
+<p>Extracts all but the suffix of each file name in <var>names</var>. If the
+file name contains a period, the basename is everything starting up to
+(and not including) the last period. Periods in the directory part are
+ignored. If there is no period, the basename is the entire file name.
+For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(basename src/foo.c src-1.0/bar hacks)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>src/foo src-1.0/bar hacks</samp>’.
+</p>
+</dd>
+<dt> <code>$(addsuffix <var>suffix</var>,<var>names</var>…)</code></dt>
+<dd><a name="IDX307"></a>
+<a name="IDX308"></a>
+<a name="IDX309"></a>
+<p>The argument <var>names</var> is regarded as a series of names, separated
+by whitespace; <var>suffix</var> is used as a unit. The value of
+<var>suffix</var> is appended to the end of each individual name and the
+resulting larger names are concatenated with single spaces between
+them. For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(addsuffix .c,foo bar)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>foo.c bar.c</samp>’.
+</p>
+</dd>
+<dt> <code>$(addprefix <var>prefix</var>,<var>names</var>…)</code></dt>
+<dd><a name="IDX310"></a>
+<a name="IDX311"></a>
+<a name="IDX312"></a>
+<p>The argument <var>names</var> is regarded as a series of names, separated
+by whitespace; <var>prefix</var> is used as a unit. The value of
+<var>prefix</var> is prepended to the front of each individual name and the
+resulting larger names are concatenated with single spaces between
+them. For example,
+</p>
+<table><tr><td> </td><td><pre class="example">$(addprefix src/,foo bar)
+</pre></td></tr></table>
+
+<p>produces the result ‘<samp>src/foo src/bar</samp>’.
+</p>
+</dd>
+<dt> <code>$(join <var>list1</var>,<var>list2</var>)</code></dt>
+<dd><a name="IDX313"></a>
+<a name="IDX314"></a>
+<a name="IDX315"></a>
+<p>Concatenates the two arguments word by word: the two first words (one
+from each argument) concatenated form the first word of the result, the
+two second words form the second word of the result, and so on. So the
+<var>n</var>th word of the result comes from the <var>n</var>th word of each
+argument. If one argument has more words that the other, the extra
+words are copied unchanged into the result.
+</p>
+<p>For example, ‘<samp>$(join a b,.c .o)</samp>’ produces ‘<samp>a.c b.o</samp>’.
+</p>
+<p>Whitespace between the words in the lists is not preserved; it is
+replaced with a single space.
+</p>
+<p>This function can merge the results of the <code>dir</code> and
+<code>notdir</code> functions, to produce the original list of files which
+was given to those two functions.
+</p>
+</dd>
+<dt> <code>$(wildcard <var>pattern</var>)</code></dt>
+<dd><a name="IDX316"></a>
+<a name="IDX317"></a>
+<p>The argument <var>pattern</var> is a file name pattern, typically containing
+wildcard characters (as in shell file name patterns). The result of
+<code>wildcard</code> is a space-separated list of the names of existing files
+that match the pattern.
+See section <a href="make_4.html#SEC34">Using Wildcard Characters in File Names</a>.
+</p>
+</dd>
+<dt> <code>$(realpath <var>names</var>…)</code></dt>
+<dd><a name="IDX318"></a>
+<a name="IDX319"></a>
+<a name="IDX320"></a>
+<p>For each file name in <var>names</var> return the canonical absolute name.
+A canonical name does not contain any <code>.</code> or <code>..</code> components,
+nor any repeated path separators (<code>/</code>) or symlinks. In case of a
+failure the empty string is returned. Consult the <code>realpath(3)</code>
+documentation for a list of possible failure causes.
+</p>
+</dd>
+<dt> <code>$(abspath <var>names</var>…)</code></dt>
+<dd><a name="IDX321"></a>
+<a name="IDX322"></a>
+<a name="IDX323"></a>
+<p>For each file name in <var>names</var> return an absolute name that does
+not contain any <code>.</code> or <code>..</code> components, nor any repeated path
+separators (<code>/</code>). Note that, in contrast to <code>realpath</code>
+function, <code>abspath</code> does not resolve symlinks and does not require
+the file names to refer to an existing file or directory. Use the
+<code>wildcard</code> function to test for existence.
+</p></dd>
+</dl>
+
+<hr size="6">
+<a name="Conditional-Functions"></a>
+<a name="SEC96"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC95" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC97" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.4 Functions for Conditionals </h2>
+<p>There are three functions that provide conditional expansion. A key
+aspect of these functions is that not all of the arguments are
+expanded initially. Only those arguments which need to be expanded,
+will be expanded.
+</p>
+<dl compact="compact">
+<dt> <code>$(if <var>condition</var>,<var>then-part</var>[,<var>else-part</var>])</code></dt>
+<dd><a name="IDX324"></a>
+<p>The <code>if</code> function provides support for conditional expansion in a
+functional context (as opposed to the GNU <code>make</code> makefile
+conditionals such as <code>ifeq</code> (see section <a href="make_7.html#SEC90">Syntax of Conditionals</a>).
+</p>
+<p>The first argument, <var>condition</var>, first has all preceding and
+trailing whitespace stripped, then is expanded. If it expands to any
+non-empty string, then the condition is considered to be true. If it
+expands to an empty string, the condition is considered to be false.
+</p>
+<p>If the condition is true then the second argument, <var>then-part</var>, is
+evaluated and this is used as the result of the evaluation of the entire
+<code>if</code> function.
+</p>
+<p>If the condition is false then the third argument, <var>else-part</var>, is
+evaluated and this is the result of the <code>if</code> function. If there is
+no third argument, the <code>if</code> function evaluates to nothing (the
+empty string).
+</p>
+<p>Note that only one of the <var>then-part</var> or the <var>else-part</var> will be
+evaluated, never both. Thus, either can contain side-effects (such as
+<code>shell</code> function calls, etc.)
+</p>
+</dd>
+<dt> <code>$(or <var>condition1</var>[,<var>condition2</var>[,<var>condition3</var>…]])</code></dt>
+<dd><a name="IDX325"></a>
+<p>The <code>or</code> function provides a “short-circuiting” OR operation.
+Each argument is expanded, in order. If an argument expands to a
+non-empty string the processing stops and the result of the expansion
+is that string. If, after all arguments are expanded, all of them are
+false (empty), then the result of the expansion is the empty string.
+</p>
+</dd>
+<dt> <code>$(and <var>condition1</var>[,<var>condition2</var>[,<var>condition3</var>…]])</code></dt>
+<dd><a name="IDX326"></a>
+<p>The <code>and</code> function provides a “short-circuiting” AND operation.
+Each argument is expanded, in order. If an argument expands to an
+empty string the processing stops and the result of the expansion is
+the empty string. If all arguments expand to a non-empty string then
+the result of the expansion is the expansion of the last argument.
+</p>
+</dd>
+</dl>
+
+<hr size="6">
+<a name="Foreach-Function"></a>
+<a name="SEC97"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC96" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC98" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.5 The <code>foreach</code> Function </h2>
+
+<p>The <code>foreach</code> function is very different from other functions. It
+causes one piece of text to be used repeatedly, each time with a different
+substitution performed on it. It resembles the <code>for</code> command in the
+shell <code>sh</code> and the <code>foreach</code> command in the C-shell <code>csh</code>.
+</p>
+<p>The syntax of the <code>foreach</code> function is:
+</p>
+<table><tr><td> </td><td><pre class="example">$(foreach <var>var</var>,<var>list</var>,<var>text</var>)
+</pre></td></tr></table>
+
+<p>The first two arguments, <var>var</var> and <var>list</var>, are expanded before
+anything else is done; note that the last argument, <var>text</var>, is
+<strong>not</strong> expanded at the same time. Then for each word of the expanded
+value of <var>list</var>, the variable named by the expanded value of <var>var</var>
+is set to that word, and <var>text</var> is expanded. Presumably <var>text</var>
+contains references to that variable, so its expansion will be different
+each time.
+</p>
+<p>The result is that <var>text</var> is expanded as many times as there are
+whitespace-separated words in <var>list</var>. The multiple expansions of
+<var>text</var> are concatenated, with spaces between them, to make the result
+of <code>foreach</code>.
+</p>
+<p>This simple example sets the variable ‘<samp>files</samp>’ to the list of all files
+in the directories in the list ‘<samp>dirs</samp>’:
+</p>
+<table><tr><td> </td><td><pre class="example">dirs := a b c d
+files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
+</pre></td></tr></table>
+
+<p>Here <var>text</var> is ‘<samp>$(wildcard $(dir)/*)</samp>’. The first repetition
+finds the value ‘<samp>a</samp>’ for <code>dir</code>, so it produces the same result
+as ‘<samp>$(wildcard a/*)</samp>’; the second repetition produces the result
+of ‘<samp>$(wildcard b/*)</samp>’; and the third, that of ‘<samp>$(wildcard c/*)</samp>’.
+</p>
+<p>This example has the same result (except for setting ‘<samp>dirs</samp>’) as
+the following example:
+</p>
+<table><tr><td> </td><td><pre class="example">files := $(wildcard a/* b/* c/* d/*)
+</pre></td></tr></table>
+
+<p>When <var>text</var> is complicated, you can improve readability by giving it
+a name, with an additional variable:
+</p>
+<table><tr><td> </td><td><pre class="example">find_files = $(wildcard $(dir)/*)
+dirs := a b c d
+files := $(foreach dir,$(dirs),$(find_files))
+</pre></td></tr></table>
+
+<p>Here we use the variable <code>find_files</code> this way. We use plain ‘<samp>=</samp>’
+to define a recursively-expanding variable, so that its value contains an
+actual function call to be reexpanded under the control of <code>foreach</code>;
+a simply-expanded variable would not do, since <code>wildcard</code> would be
+called only once at the time of defining <code>find_files</code>.
+</p>
+<p>The <code>foreach</code> function has no permanent effect on the variable
+<var>var</var>; its value and flavor after the <code>foreach</code> function call are
+the same as they were beforehand. The other values which are taken from
+<var>list</var> are in effect only temporarily, during the execution of
+<code>foreach</code>. The variable <var>var</var> is a simply-expanded variable
+during the execution of <code>foreach</code>. If <var>var</var> was undefined
+before the <code>foreach</code> function call, it is undefined after the call.
+See section <a href="make_6.html#SEC76">The Two Flavors of Variables</a>.
+</p>
+<p>You must take care when using complex variable expressions that result in
+variable names because many strange things are valid variable names, but
+are probably not what you intended. For example,
+</p>
+<table><tr><td> </td><td><pre class="smallexample">files := $(foreach Esta escrito en espanol!,b c ch,$(find_files))
+</pre></td></tr></table>
+
+<p>might be useful if the value of <code>find_files</code> references the variable
+whose name is ‘<samp>Esta escrito en espanol!</samp>’ (es un nombre bastante largo,
+no?), but it is more likely to be a mistake.
+</p>
+<hr size="6">
+<a name="Call-Function"></a>
+<a name="SEC98"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC97" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC99" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.6 The <code>call</code> Function </h2>
+
+<p>The <code>call</code> function is unique in that it can be used to create new
+parameterized functions. You can write a complex expression as the
+value of a variable, then use <code>call</code> to expand it with different
+values.
+</p>
+<p>The syntax of the <code>call</code> function is:
+</p>
+<table><tr><td> </td><td><pre class="example">$(call <var>variable</var>,<var>param</var>,<var>param</var>,…)
+</pre></td></tr></table>
+
+<p>When <code>make</code> expands this function, it assigns each <var>param</var> to
+temporary variables <code>$(1)</code>, <code>$(2)</code>, etc. The variable
+<code>$(0)</code> will contain <var>variable</var>. There is no maximum number of
+parameter arguments. There is no minimum, either, but it doesn't make
+sense to use <code>call</code> with no parameters.
+</p>
+<p>Then <var>variable</var> is expanded as a <code>make</code> variable in the context
+of these temporary assignments. Thus, any reference to <code>$(1)</code> in
+the value of <var>variable</var> will resolve to the first <var>param</var> in the
+invocation of <code>call</code>.
+</p>
+<p>Note that <var>variable</var> is the <em>name</em> of a variable, not a
+<em>reference</em> to that variable. Therefore you would not normally use
+a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use a
+variable reference in the name if you want the name not to be a
+constant.)
+</p>
+<p>If <var>variable</var> is the name of a builtin function, the builtin function
+is always invoked (even if a <code>make</code> variable by that name also
+exists).
+</p>
+<p>The <code>call</code> function expands the <var>param</var> arguments before
+assigning them to temporary variables. This means that <var>variable</var>
+values containing references to builtin functions that have special
+expansion rules, like <code>foreach</code> or <code>if</code>, may not work as you
+expect.
+</p>
+<p>Some examples may make this clearer.
+</p>
+<p>This macro simply reverses its arguments:
+</p>
+<table><tr><td> </td><td><pre class="smallexample">reverse = $(2) $(1)
+
+foo = $(call reverse,a,b)
+</pre></td></tr></table>
+
+<p>Here <var>foo</var> will contain ‘<samp>b a</samp>’.
+</p>
+<p>This one is slightly more interesting: it defines a macro to search for
+the first instance of a program in <code>PATH</code>:
+</p>
+<table><tr><td> </td><td><pre class="smallexample">pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
+
+LS := $(call pathsearch,ls)
+</pre></td></tr></table>
+
+<p>Now the variable LS contains <code>/bin/ls</code> or similar.
+</p>
+<p>The <code>call</code> function can be nested. Each recursive invocation gets
+its own local values for <code>$(1)</code>, etc. that mask the values of
+higher-level <code>call</code>. For example, here is an implementation of a
+<em>map</em> function:
+</p>
+<table><tr><td> </td><td><pre class="smallexample">map = $(foreach a,$(2),$(call $(1),$(a)))
+</pre></td></tr></table>
+
+<p>Now you can <var>map</var> a function that normally takes only one argument,
+such as <code>origin</code>, to multiple values in one step:
+</p>
+<table><tr><td> </td><td><pre class="smallexample">o = $(call map,origin,o map MAKE)
+</pre></td></tr></table>
+
+<p>and end up with <var>o</var> containing something like ‘<samp>file file default</samp>’.
+</p>
+<p>A final caution: be careful when adding whitespace to the arguments to
+<code>call</code>. As with other functions, any whitespace contained in the
+second and subsequent arguments is kept; this can cause strange
+effects. It's generally safest to remove all extraneous whitespace when
+providing parameters to <code>call</code>.
+</p>
+<hr size="6">
+<a name="Value-Function"></a>
+<a name="SEC99"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC98" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC100" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.7 The <code>value</code> Function </h2>
+
+<p>The <code>value</code> function provides a way for you to use the value of a
+variable <em>without</em> having it expanded. Please note that this
+does not undo expansions which have already occurred; for example if
+you create a simply expanded variable its value is expanded during the
+definition; in that case the <code>value</code> function will return the
+same result as using the variable directly.
+</p>
+<p>The syntax of the <code>value</code> function is:
+</p>
+<table><tr><td> </td><td><pre class="example">$(value <var>variable</var>)
+</pre></td></tr></table>
+
+<p>Note that <var>variable</var> is the <em>name</em> of a variable; not a
+<em>reference</em> to that variable. Therefore you would not normally
+use a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use
+a variable reference in the name if you want the name not to be a
+constant.)
+</p>
+<p>The result of this function is a string containing the value of
+<var>variable</var>, without any expansion occurring. For example, in this
+makefile:
+</p>
+<table><tr><td> </td><td><pre class="example">FOO = $PATH
+
+all:
+ @echo $(FOO)
+ @echo $(value FOO)
+</pre></td></tr></table>
+
+<p>The first output line would be <code>ATH</code>, since the “$P” would be
+expanded as a <code>make</code> variable, while the second output line would
+be the current value of your <code>$PATH</code> environment variable, since
+the <code>value</code> function avoided the expansion.
+</p>
+<p>The <code>value</code> function is most often used in conjunction with the
+<code>eval</code> function (see section <a href="#SEC100">The <code>eval</code> Function</a>).
+</p>
+<hr size="6">
+<a name="Eval-Function"></a>
+<a name="SEC100"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC99" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC101" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.8 The <code>eval</code> Function </h2>
+
+<p>The <code>eval</code> function is very special: it allows you to define new
+makefile constructs that are not constant; which are the result of
+evaluating other variables and functions. The argument to the
+<code>eval</code> function is expanded, then the results of that expansion
+are parsed as makefile syntax. The expanded results can define new
+<code>make</code> variables, targets, implicit or explicit rules, etc.
+</p>
+<p>The result of the <code>eval</code> function is always the empty string;
+thus, it can be placed virtually anywhere in a makefile without
+causing syntax errors.
+</p>
+<p>It's important to realize that the <code>eval</code> argument is expanded
+<em>twice</em>; first by the <code>eval</code> function, then the results of
+that expansion are expanded again when they are parsed as makefile
+syntax. This means you may need to provide extra levels of escaping
+for “$” characters when using <code>eval</code>. The <code>value</code>
+function (see section <a href="#SEC99">The <code>value</code> Function</a>) can sometimes be useful in these
+situations, to circumvent unwanted expansions.
+</p>
+<p>Here is an example of how <code>eval</code> can be used; this example
+combines a number of concepts and other functions. Although it might
+seem overly complex to use <code>eval</code> in this example, rather than
+just writing out the rules, consider two things: first, the template
+definition (in <code>PROGRAM_template</code>) could need to be much more
+complex than it is here; and second, you might put the complex,
+“generic” part of this example into another makefile, then include
+it in all the individual makefiles. Now your individual makefiles are
+quite straightforward.
+</p>
+<table><tr><td> </td><td><pre class="example">PROGRAMS = server client
+
+server_OBJS = server.o server_priv.o server_access.o
+server_LIBS = priv protocol
+
+client_OBJS = client.o client_api.o client_mem.o
+client_LIBS = protocol
+
+# Everything after this is generic
+
+.PHONY: all
+all: $(PROGRAMS)
+
+define PROGRAM_template
+ $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%)
+ ALL_OBJS += $$($(1)_OBJS)
+endef
+
+$(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))
+
+$(PROGRAMS):
+ $(LINK.o) $^ $(LDLIBS) -o $@
+
+clean:
+ rm -f $(ALL_OBJS) $(PROGRAMS)
+</pre></td></tr></table>
+
+<hr size="6">
+<a name="Origin-Function"></a>
+<a name="SEC101"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC100" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC102" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.9 The <code>origin</code> Function </h2>
+
+<p>The <code>origin</code> function is unlike most other functions in that it does
+not operate on the values of variables; it tells you something <em>about</em>
+a variable. Specifically, it tells you where it came from.
+</p>
+<p>The syntax of the <code>origin</code> function is:
+</p>
+<table><tr><td> </td><td><pre class="example">$(origin <var>variable</var>)
+</pre></td></tr></table>
+
+<p>Note that <var>variable</var> is the <em>name</em> of a variable to inquire about;
+not a <em>reference</em> to that variable. Therefore you would not normally
+use a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use a
+variable reference in the name if you want the name not to be a constant.)
+</p>
+<p>The result of this function is a string telling you how the variable
+<var>variable</var> was defined:
+</p>
+<dl compact="compact">
+<dt> ‘<samp>undefined</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was never defined.
+</p>
+</dd>
+<dt> ‘<samp>default</samp>’</dt>
+<dd>
+<p>if <var>variable</var> has a default definition, as is usual with <code>CC</code>
+and so on. See section <a href="make_10.html#SEC116">Variables Used by Implicit Rules</a>.
+Note that if you have redefined a default variable, the <code>origin</code>
+function will return the origin of the later definition.
+</p>
+</dd>
+<dt> ‘<samp>environment</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was defined as an environment variable and the
+‘<samp>-e</samp>’ option is <em>not</em> turned on (see section <a href="make_9.html#SEC112">Summary of Options</a>).
+</p>
+</dd>
+<dt> ‘<samp>environment override</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was defined as an environment variable and the
+‘<samp>-e</samp>’ option <em>is</em> turned on (see section <a href="make_9.html#SEC112">Summary of Options</a>).
+</p>
+</dd>
+<dt> ‘<samp>file</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was defined in a makefile.
+</p>
+</dd>
+<dt> ‘<samp>command line</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was defined on the command line.
+</p>
+</dd>
+<dt> ‘<samp>override</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was defined with an <code>override</code> directive in a
+makefile (see section <a href="make_6.html#SEC83">The <code>override</code> Directive</a>).
+</p>
+</dd>
+<dt> ‘<samp>automatic</samp>’</dt>
+<dd>
+<p>if <var>variable</var> is an automatic variable defined for the
+execution of the commands for each rule
+(see section <a href="make_10.html#SEC121">Automatic Variables</a>).
+</p></dd>
+</dl>
+
+<p>This information is primarily useful (other than for your curiosity) to
+determine if you want to believe the value of a variable. For example,
+suppose you have a makefile ‘<tt>foo</tt>’ that includes another makefile
+‘<tt>bar</tt>’. You want a variable <code>bletch</code> to be defined in ‘<tt>bar</tt>’
+if you run the command ‘<samp>make -f bar</samp>’, even if the environment contains
+a definition of <code>bletch</code>. However, if ‘<tt>foo</tt>’ defined
+<code>bletch</code> before including ‘<tt>bar</tt>’, you do not want to override that
+definition. This could be done by using an <code>override</code> directive in
+‘<tt>foo</tt>’, giving that definition precedence over the later definition in
+‘<tt>bar</tt>’; unfortunately, the <code>override</code> directive would also
+override any command line definitions. So, ‘<tt>bar</tt>’ could
+include:
+</p>
+<table><tr><td> </td><td><pre class="example">ifdef bletch
+ifeq "$(origin bletch)" "environment"
+bletch = barf, gag, etc.
+endif
+endif
+</pre></td></tr></table>
+
+<p>If <code>bletch</code> has been defined from the environment, this will redefine
+it.
+</p>
+<p>If you want to override a previous definition of <code>bletch</code> if it came
+from the environment, even under ‘<samp>-e</samp>’, you could instead write:
+</p>
+<table><tr><td> </td><td><pre class="example">ifneq "$(findstring environment,$(origin bletch))" ""
+bletch = barf, gag, etc.
+endif
+</pre></td></tr></table>
+
+<p>Here the redefinition takes place if ‘<samp>$(origin bletch)</samp>’ returns either
+‘<samp>environment</samp>’ or ‘<samp>environment override</samp>’.
+See section <a href="#SEC94">Functions for String Substitution and Analysis</a>.
+</p>
+<hr size="6">
+<a name="Flavor-Function"></a>
+<a name="SEC102"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC101" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC103" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.10 The <code>flavor</code> Function </h2>
+
+<p>The <code>flavor</code> function is unlike most other functions (and like
+<code>origin</code> function) in that it does not operate on the values of
+variables; it tells you something <em>about</em> a variable.
+Specifically, it tells you the flavor of a variable (see section <a href="make_6.html#SEC76">The Two Flavors of Variables</a>).
+</p>
+<p>The syntax of the <code>flavor</code> function is:
+</p>
+<table><tr><td> </td><td><pre class="example">$(flavor <var>variable</var>)
+</pre></td></tr></table>
+
+<p>Note that <var>variable</var> is the <em>name</em> of a variable to inquire about;
+not a <em>reference</em> to that variable. Therefore you would not normally
+use a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use a
+variable reference in the name if you want the name not to be a constant.)
+</p>
+<p>The result of this function is a string that identifies the flavor of the
+variable <var>variable</var>:
+</p>
+<dl compact="compact">
+<dt> ‘<samp>undefined</samp>’</dt>
+<dd>
+<p>if <var>variable</var> was never defined.
+</p>
+</dd>
+<dt> ‘<samp>recursive</samp>’</dt>
+<dd>
+<p>if <var>variable</var> is a recursively expanded variable.
+</p>
+</dd>
+<dt> ‘<samp>simple</samp>’</dt>
+<dd>
+<p>if <var>variable</var> is a simply expanded variable.
+</p>
+</dd>
+</dl>
+
+
+<hr size="6">
+<a name="Shell-Function"></a>
+<a name="SEC103"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC102" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC104" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.11 The <code>shell</code> Function </h2>
+
+<p>The <code>shell</code> function is unlike any other function other than the
+<code>wildcard</code> function
+(see section <a href="make_4.html#SEC37">The Function <code>wildcard</code></a>) in that it
+communicates with the world outside of <code>make</code>.
+</p>
+<p>The <code>shell</code> function performs the same function that backquotes
+(‘<samp>`</samp>’) perform in most shells: it does <em>command expansion</em>.
+This means that it takes as an argument a shell command and evaluates
+to the output of the command. The only processing <code>make</code> does on
+the result is to convert each newline (or carriage-return / newline
+pair) to a single space. If there is a trailing (carriage-return
+and) newline it will simply be removed.
+</p>
+<p>The commands run by calls to the <code>shell</code> function are run when the
+function calls are expanded (see section <a href="make_3.html#SEC22">How <code>make</code> Reads a Makefile</a>). Because this function involves
+spawning a new shell, you should carefully consider the performance
+implications of using the <code>shell</code> function within recursively
+expanded variables vs. simply expanded variables (see section <a href="make_6.html#SEC76">The Two Flavors of Variables</a>).
+</p>
+<p>Here are some examples of the use of the <code>shell</code> function:
+</p>
+<table><tr><td> </td><td><pre class="example">contents := $(shell cat foo)
+</pre></td></tr></table>
+
+<p>sets <code>contents</code> to the contents of the file ‘<tt>foo</tt>’, with a space
+(rather than a newline) separating each line.
+</p>
+<table><tr><td> </td><td><pre class="example">files := $(shell echo *.c)
+</pre></td></tr></table>
+
+<p>sets <code>files</code> to the expansion of ‘<samp>*.c</samp>’. Unless <code>make</code> is
+using a very strange shell, this has the same result as
+‘<samp>$(wildcard *.c)</samp>’ (as long as at least one ‘<samp>.c</samp>’ file
+exists).
+</p>
+<hr size="6">
+<a name="Make-Control-Functions"></a>
+<a name="SEC104"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC103" title="Previous section in reading order"> < </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next section in reading order"> > </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="#SEC92" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section"> 8.12 Functions That Control Make </h2>
+
+<p>These functions control the way make runs. Generally, they are used to
+provide information to the user of the makefile or to cause make to stop
+if some sort of environmental error is detected.
+</p>
+<dl compact="compact">
+<dt> <code>$(error <var>text</var>…)</code></dt>
+<dd><a name="IDX327"></a>
+<a name="IDX328"></a>
+<a name="IDX329"></a>
+<p>Generates a fatal error where the message is <var>text</var>. Note that the
+error is generated whenever this function is evaluated. So, if you put
+it inside a command script or on the right side of a recursive variable
+assignment, it won't be evaluated until later. The <var>text</var> will be
+expanded before the error is generated.
+</p>
+<p>For example,
+</p>
+<table><tr><td> </td><td><pre class="example">ifdef ERROR1
+$(error error is $(ERROR1))
+endif
+</pre></td></tr></table>
+
+<p>will generate a fatal error during the read of the makefile if the
+<code>make</code> variable <code>ERROR1</code> is defined. Or,
+</p>
+<table><tr><td> </td><td><pre class="example">ERR = $(error found an error!)
+
+.PHONY: err
+err: ; $(ERR)
+</pre></td></tr></table>
+
+<p>will generate a fatal error while <code>make</code> is running, if the
+<code>err</code> target is invoked.
+</p>
+</dd>
+<dt> <code>$(warning <var>text</var>…)</code></dt>
+<dd><a name="IDX330"></a>
+<a name="IDX331"></a>
+<a name="IDX332"></a>
+<p>This function works similarly to the <code>error</code> function, above,
+except that <code>make</code> doesn't exit. Instead, <var>text</var> is expanded
+and the resulting message is displayed, but processing of the makefile
+continues.
+</p>
+<p>The result of the expansion of this function is the empty string.
+</p>
+</dd>
+<dt> <code>$(info <var>text</var>…)</code></dt>
+<dd><a name="IDX333"></a>
+<a name="IDX334"></a>
+<p>This function does nothing more than print its (expanded) argument(s)
+to standard output. No makefile name or line number is added. The
+result of the expansion of this function is the empty string.
+</p></dd>
+</dl>
+
+<hr size="6">
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#SEC92" title="Beginning of this chapter or previous chapter"> << </a>]</td>
+<td valign="middle" align="left">[<a href="make_9.html#SEC105" title="Next chapter"> >> </a>]</td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left"> </td>
+<td valign="middle" align="left">[<a href="make.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="make_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="make_19.html#SEC148" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="make_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<p>
+ <font size="-1">
+ This document was generated by <em>Manoj Srivastava</em> on <em>August, 17 2009</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
+ </font>
+ <br>
+
+</p>
+</body>
+</html>