-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoals.html
More file actions
133 lines (106 loc) · 5.86 KB
/
Goals.html
File metadata and controls
133 lines (106 loc) · 5.86 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<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="Goals">Goals</a>,
Next:<a rel="next" accesskey="n" href="Instead-of-Execution.html#Instead%20of%20Execution">Instead of Execution</a>,
Previous:<a rel="previous" accesskey="p" href="Makefile-Arguments.html#Makefile%20Arguments">Makefile Arguments</a>,
Up:<a rel="up" accesskey="u" href="Running.html#Running">Running</a>
<hr><br>
</div>
<h3 class="section">Arguments to Specify the Goals</h3>
<p>The <dfn>goals</dfn> are the targets that <code>make</code> should strive ultimately
to update. Other targets are updated as well if they appear as
prerequisites of goals, or prerequisites of prerequisites of goals, etc.
<p>By default, the goal is the first target in the makefile (not counting
targets that start with a period). Therefore, makefiles are usually
written so that the first target is for compiling the entire program or
programs they describe. If the first rule in the makefile has several
targets, only the first target in the rule becomes the default goal, not
the whole list.
<p>You can specify a different goal or goals with arguments to <code>make</code>.
Use the name of the goal as an argument. If you specify several goals,
<code>make</code> processes each of them in turn, in the order you name them.
<p>Any target in the makefile may be specified as a goal (unless it
starts with <code>-</code> or contains an <code>=</code>, in which case it will be
parsed as a switch or variable definition, respectively). Even
targets not in the makefile may be specified, if <code>make</code> can find
implicit rules that say how to make them.
<p><code>Make</code> will set the special variable <code>MAKECMDGOALS</code> to the
list of goals you specified on the command line. If no goals were given
on the command line, this variable is empty. Note that this variable
should be used only in special circumstances.
<p>An example of appropriate use is to avoid including <code>.d</code> files
during <code>clean</code> rules (see <a href="Automatic-Prerequisites.html#Automatic%20Prerequisites">Automatic Prerequisites</a>), so
<code>make</code> won't create them only to immediately remove them
again:
<pre class="example"> sources = foo.c bar.c
ifneq ($(MAKECMDGOALS),clean)
include $(sources:.c=.d)
endif
</pre>
<p>One use of specifying a goal is if you want to compile only a part of
the program, or only one of several programs. Specify as a goal each
file that you wish to remake. For example, consider a directory containing
several programs, with a makefile that starts like this:
<pre class="example"> .PHONY: all
all: size nm ld ar as
</pre>
<p>If you are working on the program <code>size</code>, you might want to say
<code>make size</code> so that only the files of that program are recompiled.
<p>Another use of specifying a goal is to make files that are not normally
made. For example, there may be a file of debugging output, or a
version of the program that is compiled specially for testing, which has
a rule in the makefile but is not a prerequisite of the default goal.
<p>Another use of specifying a goal is to run the commands associated with
a phony target (see <a href="Phony-Targets.html#Phony%20Targets">Phony Targets</a>) or empty target (see <a href="Empty-Targets.html#Empty%20Targets">Empty Target Files to Record Events</a>). Many makefiles contain
a phony target named <code>clean</code> which deletes everything except source
files. Naturally, this is done only if you request it explicitly with
<code>make clean</code>. Following is a list of typical phony and empty
target names. See <a href="Standard-Targets.html#Standard%20Targets">Standard Targets</a>, for a detailed list of all the
standard target names which GNU software packages use.
<dl>
<dt><code>all</code>
<dd>Make all the top-level targets the makefile knows about.
<br><dt><code>clean</code>
<dd>Delete all files that are normally created by running <code>make</code>.
<br><dt><code>mostlyclean</code>
<dd>Like <code>clean</code>, but may refrain from deleting a few files that people
normally don't want to recompile. For example, the <code>mostlyclean</code>
target for GCC does not delete <code>libgcc.a</code>, because recompiling it
is rarely necessary and takes a lot of time.
<br><dt><code>distclean</code>
<dd><dt><code>realclean</code>
<dd><dt><code>clobber</code>
<dd>Any of these targets might be defined to delete <em>more</em> files than
<code>clean</code> does. For example, this would delete configuration files
or links that you would normally create as preparation for compilation,
even if the makefile itself cannot create these files.
<br><dt><code>install</code>
<dd>Copy the executable file into a directory that users typically search
for commands; copy any auxiliary files that the executable uses into
the directories where it will look for them.
<br><dt><code>print</code>
<dd>Print listings of the source files that have changed.
<br><dt><code>tar</code>
<dd>Create a tar file of the source files.
<br><dt><code>shar</code>
<dd>Create a shell archive (shar file) of the source files.
<br><dt><code>dist</code>
<dd>Create a distribution file of the source files. This might
be a tar file, or a shar file, or a compressed version of one of the
above, or even more than one of the above.
<br><dt><code>TAGS</code>
<dd>Update a tags table for this program.
<br><dt><code>check</code>
<dd><dt><code>test</code>
<dd>Perform self tests on the program this makefile builds.
</dl>
</body></html>