-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInclude.html
More file actions
114 lines (93 loc) · 5.07 KB
/
Include.html
File metadata and controls
114 lines (93 loc) · 5.07 KB
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
<html lang="en">
<head>
<title>GNU `make'</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU `make'">
<meta name="generator" content="makeinfo 4.3">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
</head>
<body>
<div class="node">
<p>
Node:<a name="Include">Include</a>,
Next:<a rel="next" accesskey="n" href="MAKEFILES-Variable.html#MAKEFILES%20Variable">MAKEFILES Variable</a>,
Previous:<a rel="previous" accesskey="p" href="Makefile-Names.html#Makefile%20Names">Makefile Names</a>,
Up:<a rel="up" accesskey="u" href="Makefiles.html#Makefiles">Makefiles</a>
<hr><br>
</div>
<h3 class="section">Including Other Makefiles</h3>
<p>The <code>include</code> directive tells <code>make</code> to suspend reading the
current makefile and read one or more other makefiles before continuing.
The directive is a line in the makefile that looks like this:
<pre class="example"> include <var>filenames</var>...
</pre>
<p><var>filenames</var> can contain shell file name patterns.
<p>Extra spaces are allowed and ignored at the beginning of the line, but
a tab is not allowed. (If the line begins with a tab, it will be
considered a command line.) Whitespace is required between
<code>include</code> and the file names, and between file names; extra
whitespace is ignored there and at the end of the directive. A
comment starting with <code>#</code> is allowed at the end of the line. If
the file names contain any variable or function references, they are
expanded. See <a href="Using-Variables.html#Using%20Variables">How to Use Variables</a>.
<p>For example, if you have three <code>.mk</code> files, <code>a.mk</code>,
<code>b.mk</code>, and <code>c.mk</code>, and <code>$(bar)</code> expands to
<code>bish bash</code>, then the following expression
<pre class="example"> include foo *.mk $(bar)
</pre>
<p>is equivalent to
<pre class="example"> include foo a.mk b.mk c.mk bish bash
</pre>
<p>When <code>make</code> processes an <code>include</code> directive, it suspends
reading of the containing makefile and reads from each listed file in
turn. When that is finished, <code>make</code> resumes reading the
makefile in which the directive appears.
<p>One occasion for using <code>include</code> directives is when several programs,
handled by individual makefiles in various directories, need to use a
common set of variable definitions
(see <a href="Setting.html#Setting">Setting Variables</a>) or pattern rules
(see <a href="Pattern-Rules.html#Pattern%20Rules">Defining and Redefining Pattern Rules</a>).
<p>Another such occasion is when you want to generate prerequisites from
source files automatically; the prerequisites can be put in a file that
is included by the main makefile. This practice is generally cleaner
than that of somehow appending the prerequisites to the end of the main
makefile as has been traditionally done with other versions of
<code>make</code>. See <a href="Automatic-Prerequisites.html#Automatic%20Prerequisites">Automatic Prerequisites</a>.
<p>If the specified name does not start with a slash, and the file is not
found in the current directory, several other directories are searched.
First, any directories you have specified with the <code>-I</code> or
<code>--include-dir</code> option are searched
(see <a href="Options-Summary.html#Options%20Summary">Summary of Options</a>).
Then the following directories (if they exist)
are searched, in this order:
<code></code><var>prefix</var><code>/include</code> (normally <code>/usr/local/include</code>
<a rel="footnote" href="#fn-1"><sup>1</sup></a>)
<code>/usr/gnu/include</code>,
<code>/usr/local/include</code>, <code>/usr/include</code>.
<p>If an included makefile cannot be found in any of these directories, a
warning message is generated, but it is not an immediately fatal error;
processing of the makefile containing the <code>include</code> continues.
Once it has finished reading makefiles, <code>make</code> will try to remake
any that are out of date or don't exist.
See <a href="Remaking-Makefiles.html#Remaking%20Makefiles">How Makefiles Are Remade</a>.
Only after it has tried to find a way to remake a makefile and failed,
will <code>make</code> diagnose the missing makefile as a fatal error.
<p>If you want <code>make</code> to simply ignore a makefile which does not exist
and cannot be remade, with no error message, use the <code>-include</code>
directive instead of <code>include</code>, like this:
<pre class="example"> -include <var>filenames</var>...
</pre>
<p>This acts like <code>include</code> in every way except that there is no
error (not even a warning) if any of the <var>filenames</var> do not exist.
For compatibility with some other <code>make</code> implementations,
<code>sinclude</code> is another name for <code>-include</code>.
<div class="footnote">
<hr>
<h4>Footnotes</h4>
<ol type="1">
<li><a name="fn-1"></a>
<p>GNU Make compiled for MS-DOS and MS-Windows behaves as if
<var>prefix</var> has been defined to be the root of the DJGPP tree
hierarchy.</p>
</ol><hr></div>
</body></html>