This file is indexed.

/usr/share/doc/make-doc/make.html/Conditionals.html is in make-doc 4.2.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/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.74, last updated 21 May 2016,
of The GNU Make Manual, for GNU make version 4.2.1.

Copyright (C) 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 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.3 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 the freedom to copy and
modify this GNU manual.  Buying copies from the FSF supports it in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Conditionals (GNU make)</title>

<meta name="description" content="Conditionals (GNU make)">
<meta name="keywords" content="Conditionals (GNU make)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="index.html#Top" rel="up" title="Top">
<link href="Functions.html#Functions" rel="next" title="Functions">
<link href="Using-Variables.html#Special-Variables" rel="prev" title="Special Variables">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<a name="Conditionals"></a>
<div class="header">
<p>
Next: <a href="Functions.html#Functions" accesskey="n" rel="next">Functions</a>, Previous: <a href="Using-Variables.html#Using-Variables" accesskey="p" rel="prev">Using Variables</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Conditional-Parts-of-Makefiles"></a>
<h2 class="chapter">7 Conditional Parts of Makefiles</h2>

<a name="index-conditionals"></a>
<p>A <em>conditional</em> directive causes part of a makefile to be obeyed
or ignored depending on the values of variables.  Conditionals can
compare the value of one variable to another, or the value of a
variable to a constant string.  Conditionals control what <code>make</code>
actually &ldquo;sees&rdquo; in the makefile, so they <em>cannot</em> be used to
control recipes at the time of execution.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Conditional-Example" accesskey="1">Conditional Example</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example of a conditional
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Conditional-Syntax" accesskey="2">Conditional Syntax</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The syntax of conditionals.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Testing-Flags" accesskey="3">Testing Flags</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Conditionals that test flags.
</td></tr>
</table>

<hr>
<a name="Conditional-Example"></a>
<div class="header">
<p>
Next: <a href="#Conditional-Syntax" accesskey="n" rel="next">Conditional Syntax</a>, Previous: <a href="#Conditionals" accesskey="p" rel="prev">Conditionals</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-of-a-Conditional"></a>
<h3 class="section">7.1 Example of a Conditional</h3>

<p>The following example of a conditional tells <code>make</code> to use one
set of libraries if the <code>CC</code> variable is &lsquo;<samp>gcc</samp>&rsquo;, and a
different set of libraries otherwise.  It works by controlling which
of two recipe lines will be used for the rule.  The result is that
&lsquo;<samp>CC=gcc</samp>&rsquo; as an argument to <code>make</code> changes not only which
compiler is used but also which libraries are linked.
</p>
<div class="example">
<pre class="example">libs_for_gcc = -lgnu
normal_libs =

foo: $(objects)
ifeq ($(CC),gcc)
        $(CC) -o foo $(objects) $(libs_for_gcc)
else
        $(CC) -o foo $(objects) $(normal_libs)
endif
</pre></div>

<p>This conditional uses three directives: one <code>ifeq</code>, one <code>else</code>
and one <code>endif</code>.
</p>
<p>The <code>ifeq</code> directive begins the conditional, and specifies the
condition.  It contains two arguments, separated by a comma and surrounded
by parentheses.  Variable substitution is performed on both arguments and
then they are compared.  The lines of the makefile following the
<code>ifeq</code> are obeyed if the two arguments match; otherwise they are
ignored.
</p>
<p>The <code>else</code> directive causes the following lines to be obeyed if the
previous conditional failed.  In the example above, this means that the
second alternative linking command is used whenever the first alternative
is not used.  It is optional to have an <code>else</code> in a conditional.
</p>
<p>The <code>endif</code> directive ends the conditional.  Every conditional must
end with an <code>endif</code>.  Unconditional makefile text follows.
</p>
<p>As this example illustrates, conditionals work at the textual level:
the lines of the conditional are treated as part of the makefile, or
ignored, according to the condition.  This is why the larger syntactic
units of the makefile, such as rules, may cross the beginning or the
end of the conditional.
</p>
<p>When the variable <code>CC</code> has the value &lsquo;<samp>gcc</samp>&rsquo;, the above example has
this effect:
</p>
<div class="example">
<pre class="example">foo: $(objects)
        $(CC) -o foo $(objects) $(libs_for_gcc)
</pre></div>

<p>When the variable <code>CC</code> has any other value, the effect is this:
</p>
<div class="example">
<pre class="example">foo: $(objects)
        $(CC) -o foo $(objects) $(normal_libs)
</pre></div>

<p>Equivalent results can be obtained in another way by conditionalizing a
variable assignment and then using the variable unconditionally:
</p>
<div class="example">
<pre class="example">libs_for_gcc = -lgnu
normal_libs =

ifeq ($(CC),gcc)
  libs=$(libs_for_gcc)
else
  libs=$(normal_libs)
endif

foo: $(objects)
        $(CC) -o foo $(objects) $(libs)
</pre></div>

<hr>
<a name="Conditional-Syntax"></a>
<div class="header">
<p>
Next: <a href="#Testing-Flags" accesskey="n" rel="next">Testing Flags</a>, Previous: <a href="#Conditional-Example" accesskey="p" rel="prev">Conditional Example</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Syntax-of-Conditionals"></a>
<h3 class="section">7.2 Syntax of Conditionals</h3>
<a name="index-ifdef"></a>
<a name="index-ifeq"></a>
<a name="index-ifndef"></a>
<a name="index-ifneq"></a>
<a name="index-else"></a>
<a name="index-endif"></a>

<p>The syntax of a simple conditional with no <code>else</code> is as follows:
</p>
<div class="example">
<pre class="example"><var>conditional-directive</var>
<var>text-if-true</var>
endif
</pre></div>

<p>The <var>text-if-true</var> may be any lines of text, to be considered as part
of the makefile if the condition is true.  If the condition is false, no
text is used instead.
</p>
<p>The syntax of a complex conditional is as follows:
</p>
<div class="example">
<pre class="example"><var>conditional-directive</var>
<var>text-if-true</var>
else
<var>text-if-false</var>
endif
</pre></div>

<p>or:
</p>
<div class="example">
<pre class="example"><var>conditional-directive-one</var>
<var>text-if-one-is-true</var>
else <var>conditional-directive-two</var>
<var>text-if-two-is-true</var>
else
<var>text-if-one-and-two-are-false</var>
endif
</pre></div>

<p>There can be as many &ldquo;<code>else</code> <var>conditional-directive</var>&rdquo;
clauses as necessary.  Once a given condition is true,
<var>text-if-true</var> is used and no other clause is used; if no
condition is true then <var>text-if-false</var> is used.  The
<var>text-if-true</var> and <var>text-if-false</var> can be any number of lines
of text.
</p>
<p>The syntax of the <var>conditional-directive</var> is the same whether the
conditional is simple or complex; after an <code>else</code> or not.  There
are four different directives that test different conditions.  Here is
a table of them:
</p>
<dl compact="compact">
<dt><code>ifeq (<var>arg1</var>, <var>arg2</var>)</code></dt>
<dt><code>ifeq '<var>arg1</var>' '<var>arg2</var>'</code></dt>
<dt><code>ifeq &quot;<var>arg1</var>&quot; &quot;<var>arg2</var>&quot;</code></dt>
<dt><code>ifeq &quot;<var>arg1</var>&quot; '<var>arg2</var>'</code></dt>
<dt><code>ifeq '<var>arg1</var>' &quot;<var>arg2</var>&quot;</code></dt>
<dd><p>Expand all variable references in <var>arg1</var> and <var>arg2</var> and
compare them.  If they are identical, the <var>text-if-true</var> is
effective; otherwise, the <var>text-if-false</var>, if any, is effective.
</p>
<p>Often you want to test if a variable has a non-empty value.  When the
value results from complex expansions of variables and functions,
expansions you would consider empty may actually contain whitespace
characters and thus are not seen as empty.  However, you can use the
<code>strip</code> function (see <a href="Functions.html#Text-Functions">Text Functions</a>) to avoid interpreting
whitespace as a non-empty value.  For example:
</p>
<div class="example">
<pre class="example">ifeq ($(strip $(foo)),)
<var>text-if-empty</var>
endif
</pre></div>

<p>will evaluate <var>text-if-empty</var> even if the expansion of
<code>$(foo)</code> contains whitespace characters.
</p>
</dd>
<dt><code>ifneq (<var>arg1</var>, <var>arg2</var>)</code></dt>
<dt><code>ifneq '<var>arg1</var>' '<var>arg2</var>'</code></dt>
<dt><code>ifneq &quot;<var>arg1</var>&quot; &quot;<var>arg2</var>&quot;</code></dt>
<dt><code>ifneq &quot;<var>arg1</var>&quot; '<var>arg2</var>'</code></dt>
<dt><code>ifneq '<var>arg1</var>' &quot;<var>arg2</var>&quot;</code></dt>
<dd><p>Expand all variable references in <var>arg1</var> and <var>arg2</var> and
compare them.  If they are different, the <var>text-if-true</var> is
effective; otherwise, the <var>text-if-false</var>, if any, is effective.
</p>
</dd>
<dt><code>ifdef <var>variable-name</var></code></dt>
<dd><p>The <code>ifdef</code> form takes the <em>name</em> of a variable as its
argument, not a reference to a variable.  If the value of that
variable has a non-empty value, the <var>text-if-true</var> is effective;
otherwise, the <var>text-if-false</var>, if any, is effective.  Variables
that have never been defined have an empty value.  The text
<var>variable-name</var> is expanded, so it could be a variable or function
that expands to the name of a variable.  For example:
</p>
<div class="example">
<pre class="example">bar = true
foo = bar
ifdef $(foo)
frobozz = yes
endif
</pre></div>

<p>The variable reference <code>$(foo)</code> is expanded, yielding <code>bar</code>,
which is considered to be the name of a variable.  The variable
<code>bar</code> is not expanded, but its value is examined to determine if
it is non-empty.
</p>
<p>Note that <code>ifdef</code> only tests whether a variable has a value.  It
does not expand the variable to see if that value is nonempty.
Consequently, tests using <code>ifdef</code> return true for all definitions
except those like <code>foo =</code>.  To test for an empty value, use
<code>ifeq&nbsp;($(foo),)</code><!-- /@w -->.  For example,
</p>
<div class="example">
<pre class="example">bar =
foo = $(bar)
ifdef foo
frobozz = yes
else
frobozz = no
endif
</pre></div>

<p>sets &lsquo;<samp>frobozz</samp>&rsquo; to &lsquo;<samp>yes</samp>&rsquo;, while:
</p>
<div class="example">
<pre class="example">foo =
ifdef foo
frobozz = yes
else
frobozz = no
endif
</pre></div>

<p>sets &lsquo;<samp>frobozz</samp>&rsquo; to &lsquo;<samp>no</samp>&rsquo;.
</p>
</dd>
<dt><code>ifndef <var>variable-name</var></code></dt>
<dd><p>If the variable <var>variable-name</var> has an empty value, the
<var>text-if-true</var> is effective; otherwise, the <var>text-if-false</var>,
if any, is effective.  The rules for expansion and testing of
<var>variable-name</var> are identical to the <code>ifdef</code> directive.
</p></dd>
</dl>

<p>Extra spaces are allowed and ignored at the beginning of the
conditional directive line, but a tab is not allowed.  (If the line
begins with a tab, it will be considered part of a recipe for a rule.)
Aside from this, extra spaces or tabs may be inserted with no effect
anywhere except within the directive name or within an argument.  A
comment starting with &lsquo;<samp>#</samp>&rsquo; may appear at the end of the line.
</p>
<p>The other two directives that play a part in a conditional are <code>else</code>
and <code>endif</code>.  Each of these directives is written as one word, with no
arguments.  Extra spaces are allowed and ignored at the beginning of the
line, and spaces or tabs at the end.  A comment starting with &lsquo;<samp>#</samp>&rsquo; may
appear at the end of the line.
</p>
<p>Conditionals affect which lines of the makefile <code>make</code> uses.  If
the condition is true, <code>make</code> reads the lines of the
<var>text-if-true</var> as part of the makefile; if the condition is false,
<code>make</code> ignores those lines completely.  It follows that syntactic
units of the makefile, such as rules, may safely be split across the
beginning or the end of the conditional.
</p>
<p><code>make</code> evaluates conditionals when it reads a makefile.
Consequently, you cannot use automatic variables in the tests of
conditionals because they are not defined until recipes are run
(see <a href="Implicit-Rules.html#Automatic-Variables">Automatic Variables</a>).
</p>
<p>To prevent intolerable confusion, it is not permitted to start a
conditional in one makefile and end it in another.  However, you may
write an <code>include</code> directive within a conditional, provided you do
not attempt to terminate the conditional inside the included file.
</p>
<hr>
<a name="Testing-Flags"></a>
<div class="header">
<p>
Previous: <a href="#Conditional-Syntax" accesskey="p" rel="prev">Conditional Syntax</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Conditionals-that-Test-Flags"></a>
<h3 class="section">7.3 Conditionals that Test Flags</h3>

<p>You can write a conditional that tests <code>make</code> command flags such as
&lsquo;<samp>-t</samp>&rsquo; by using the variable <code>MAKEFLAGS</code> together with the
<code>findstring</code> function
(see <a href="Functions.html#Text-Functions">Functions for String Substitution and Analysis</a>).
This is useful when <code>touch</code> is not enough to make a file appear up
to date.
</p>
<p>The <code>findstring</code> function determines whether one string appears as a
substring of another.  If you want to test for the &lsquo;<samp>-t</samp>&rsquo; flag,
use &lsquo;<samp>t</samp>&rsquo; as the first string and the value of <code>MAKEFLAGS</code> as
the other.
</p>
<p>For example, here is how to arrange to use &lsquo;<samp>ranlib -t</samp>&rsquo; to finish
marking an archive file up to date:
</p>
<div class="example">
<pre class="example">archive.a: &hellip;
ifneq (,$(findstring t,$(MAKEFLAGS)))
        +touch archive.a
        +ranlib -t archive.a
else
        ranlib archive.a
endif
</pre></div>

<p>The &lsquo;<samp>+</samp>&rsquo; prefix marks those recipe lines as &ldquo;recursive&rdquo; so that
they will be executed despite use of the &lsquo;<samp>-t</samp>&rsquo; flag.
See <a href="Recipes.html#Recursion">Recursive Use of <code>make</code></a>.
</p>
<hr>
<div class="header">
<p>
Previous: <a href="#Conditional-Syntax" accesskey="p" rel="prev">Conditional Syntax</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>