11 76193d7c 2003-09-30 devnull .if t .BR \\$1 \\$2
12 76193d7c 2003-09-30 devnull .if n .RB ` \\$1 '\\$2
16 76193d7c 2003-09-30 devnull .if t .B \\$1
17 76193d7c 2003-09-30 devnull .if n .RB ` \\$1 '
20 76193d7c 2003-09-30 devnull mk \- maintain (make) related files
21 76193d7c 2003-09-30 devnull .SH SYNOPSIS
25 76193d7c 2003-09-30 devnull .I mkfile
28 76193d7c 2003-09-30 devnull .I option ...
31 76193d7c 2003-09-30 devnull .I target ...
33 76193d7c 2003-09-30 devnull .SH DESCRIPTION
35 76193d7c 2003-09-30 devnull uses the dependency rules specified in
36 76193d7c 2003-09-30 devnull .I mkfile
37 76193d7c 2003-09-30 devnull to control the update (usually by compilation) of
38 76193d7c 2003-09-30 devnull .I targets
39 76193d7c 2003-09-30 devnull (usually files)
40 76193d7c 2003-09-30 devnull from the source files upon which they depend.
42 76193d7c 2003-09-30 devnull .I mkfile
44 76193d7c 2003-09-30 devnull .LR mkfile )
45 76193d7c 2003-09-30 devnull contains a
47 76193d7c 2003-09-30 devnull for each target that identifies the files and other
48 76193d7c 2003-09-30 devnull targets upon which it depends and an
49 76193d7c 2003-09-30 devnull .IR sh (1)
50 76193d7c 2003-09-30 devnull script, a
51 76193d7c 2003-09-30 devnull .IR recipe ,
52 76193d7c 2003-09-30 devnull to update the target.
53 76193d7c 2003-09-30 devnull The script is run if the target does not exist
54 76193d7c 2003-09-30 devnull or if it is older than any of the files it depends on.
55 76193d7c 2003-09-30 devnull .I Mkfile
56 76193d7c 2003-09-30 devnull may also contain
57 76193d7c 2003-09-30 devnull .I meta-rules
58 76193d7c 2003-09-30 devnull that define actions for updating implicit targets.
60 76193d7c 2003-09-30 devnull .I target
61 76193d7c 2003-09-30 devnull is specified, the target of the first rule (not meta-rule) in
62 76193d7c 2003-09-30 devnull .I mkfile
63 76193d7c 2003-09-30 devnull is updated.
65 76193d7c 2003-09-30 devnull The environment variable
66 76193d7c 2003-09-30 devnull .B $NPROC
67 76193d7c 2003-09-30 devnull determines how many targets may be updated simultaneously;
68 76193d7c 2003-09-30 devnull Some operating systems, e.g., Plan 9, set
69 76193d7c 2003-09-30 devnull .B $NPROC
70 76193d7c 2003-09-30 devnull automatically to the number of CPUs on the current machine.
72 76193d7c 2003-09-30 devnull Options are:
73 76193d7c 2003-09-30 devnull .TP \w'\fL-d[egp]\ 'u
75 76193d7c 2003-09-30 devnull Assume all targets to be out of date.
76 76193d7c 2003-09-30 devnull Thus, everything is updated.
79 76193d7c 2003-09-30 devnull .BR -d [ egp ]
80 76193d7c 2003-09-30 devnull Produce debugging output
82 76193d7c 2003-09-30 devnull is for parsing,
84 76193d7c 2003-09-30 devnull for graph building,
86 76193d7c 2003-09-30 devnull for execution).
89 76193d7c 2003-09-30 devnull Explain why each target is made.
92 76193d7c 2003-09-30 devnull Force any missing intermediate targets to be made.
95 76193d7c 2003-09-30 devnull Do as much work as possible in the face of errors.
98 76193d7c 2003-09-30 devnull Print, but do not execute, the commands
99 76193d7c 2003-09-30 devnull needed to update the targets.
102 76193d7c 2003-09-30 devnull Make the command line arguments sequentially rather than in parallel.
105 76193d7c 2003-09-30 devnull Touch (update the modified date of) file targets, without
106 76193d7c 2003-09-30 devnull executing any recipes.
108 76193d7c 2003-09-30 devnull .BI -w target1 , target2,...
109 76193d7c 2003-09-30 devnull Pretend the modify time for each
110 76193d7c 2003-09-30 devnull .I target
111 76193d7c 2003-09-30 devnull is the current time; useful in conjunction with
113 76193d7c 2003-09-30 devnull to learn what updates would be triggered by
114 76193d7c 2003-09-30 devnull modifying the
115 76193d7c 2003-09-30 devnull .IR targets .
117 76193d7c 2003-09-30 devnull .SS The \fLmkfile\fP
119 76193d7c 2003-09-30 devnull .I mkfile
120 76193d7c 2003-09-30 devnull consists of
121 76193d7c 2003-09-30 devnull .I assignments
122 76193d7c 2003-09-30 devnull (described under `Environment') and
123 76193d7c 2003-09-30 devnull .IR rules .
124 76193d7c 2003-09-30 devnull A rule contains
125 76193d7c 2003-09-30 devnull .I targets
127 76193d7c 2003-09-30 devnull .IR tail .
128 76193d7c 2003-09-30 devnull A target is a literal string
129 76193d7c 2003-09-30 devnull and is normally a file name.
130 76193d7c 2003-09-30 devnull The tail contains zero or more
131 76193d7c 2003-09-30 devnull .I prerequisites
132 76193d7c 2003-09-30 devnull and an optional
133 76193d7c 2003-09-30 devnull .IR recipe ,
134 76193d7c 2003-09-30 devnull which is an
135 76193d7c 2003-09-30 devnull .B shell
137 76193d7c 2003-09-30 devnull Each line of the recipe must begin with white space.
138 76193d7c 2003-09-30 devnull A rule takes the form
141 76193d7c 2003-09-30 devnull target: prereq1 prereq2
142 76193d7c 2003-09-30 devnull \f2recipe using\fP prereq1, prereq2 \f2to build\fP target
145 76193d7c 2003-09-30 devnull When the recipe is executed,
146 76193d7c 2003-09-30 devnull the first character on every line is elided.
148 76193d7c 2003-09-30 devnull After the colon on the target line, a rule may specify
149 76193d7c 2003-09-30 devnull .IR attributes ,
150 76193d7c 2003-09-30 devnull described below.
153 76193d7c 2003-09-30 devnull .I meta-rule
154 76193d7c 2003-09-30 devnull has a target of the form
155 76193d7c 2003-09-30 devnull .IB A % B
160 76193d7c 2003-09-30 devnull are (possibly empty) strings.
161 76193d7c 2003-09-30 devnull A meta-rule acts as a rule for any potential target whose
162 76193d7c 2003-09-30 devnull name matches
163 76193d7c 2003-09-30 devnull .IB A % B
166 76193d7c 2003-09-30 devnull replaced by an arbitrary string, called the
167 76193d7c 2003-09-30 devnull .IR stem .
168 76193d7c 2003-09-30 devnull In interpreting a meta-rule,
169 76193d7c 2003-09-30 devnull the stem is substituted for all occurrences of
171 76193d7c 2003-09-30 devnull in the prerequisite names.
172 76193d7c 2003-09-30 devnull In the recipe of a meta-rule, the environment variable
173 76193d7c 2003-09-30 devnull .B $stem
174 76193d7c 2003-09-30 devnull contains the string matched by the
176 76193d7c 2003-09-30 devnull For example, a meta-rule to compile a C program using
177 76193d7c 2003-09-30 devnull .IR cc (1)
178 76193d7c 2003-09-30 devnull might be:
182 76193d7c 2003-09-30 devnull cc -c $stem.c
183 76193d7c 2003-09-30 devnull cc -o $stem $stem.o
186 76193d7c 2003-09-30 devnull Meta-rules may contain an ampersand
188 76193d7c 2003-09-30 devnull rather than a percent sign
192 76193d7c 2003-09-30 devnull matches a maximal length string of any characters;
195 76193d7c 2003-09-30 devnull matches a maximal length string of any characters except period
196 76193d7c 2003-09-30 devnull or slash.
198 76193d7c 2003-09-30 devnull The text of the
199 76193d7c 2003-09-30 devnull .I mkfile
200 76193d7c 2003-09-30 devnull is processed as follows.
201 76193d7c 2003-09-30 devnull Lines beginning with
203 76193d7c 2003-09-30 devnull followed by a file name are replaced by the contents of the named
205 76193d7c 2003-09-30 devnull Lines beginning with
207 76193d7c 2003-09-30 devnull followed by a file name are replaced by the output
208 76193d7c 2003-09-30 devnull of the execution of the named
210 76193d7c 2003-09-30 devnull Blank lines and comments, which run from unquoted
212 76193d7c 2003-09-30 devnull characters to the following newline, are deleted.
213 76193d7c 2003-09-30 devnull The character sequence backslash-newline is deleted,
214 76193d7c 2003-09-30 devnull so long lines in
215 76193d7c 2003-09-30 devnull .I mkfile
216 76193d7c 2003-09-30 devnull may be folded.
217 76193d7c 2003-09-30 devnull Non-recipe lines are processed by substituting for
218 76193d7c 2003-09-30 devnull .BI `{ command }
219 76193d7c 2003-09-30 devnull the output of the
220 76193d7c 2003-09-30 devnull .I command
221 76193d7c 2003-09-30 devnull when run by
222 76193d7c 2003-09-30 devnull .IR sh .
223 76193d7c 2003-09-30 devnull References to variables are replaced by the variables' values.
224 76193d7c 2003-09-30 devnull Special characters may be quoted using single quotes
225 76193d7c 2003-09-30 devnull .BR \&''
227 76193d7c 2003-09-30 devnull .IR sh (1).
229 76193d7c 2003-09-30 devnull Assignments and rules are distinguished by
230 76193d7c 2003-09-30 devnull the first unquoted occurrence of
235 76193d7c 2003-09-30 devnull (assignment).
237 76193d7c 2003-09-30 devnull A later rule may modify or override an existing rule under the
238 76193d7c 2003-09-30 devnull following conditions:
241 76193d7c 2003-09-30 devnull If the targets of the rules exactly match and one rule
242 76193d7c 2003-09-30 devnull contains only a prerequisite clause and no recipe, the
243 76193d7c 2003-09-30 devnull clause is added to the prerequisites of the other rule.
244 76193d7c 2003-09-30 devnull If either or both targets are virtual, the recipe is
245 76193d7c 2003-09-30 devnull always executed.
248 76193d7c 2003-09-30 devnull If the targets of the rules match exactly and the
249 76193d7c 2003-09-30 devnull prerequisites do not match and both rules
250 76193d7c 2003-09-30 devnull contain recipes,
252 76193d7c 2003-09-30 devnull reports an ``ambiguous recipe'' error.
255 76193d7c 2003-09-30 devnull If the target and prerequisites of both rules match exactly,
256 76193d7c 2003-09-30 devnull the second rule overrides the first.
257 76193d7c 2003-09-30 devnull .SS Environment
258 76193d7c 2003-09-30 devnull Rules may make use of
260 76193d7c 2003-09-30 devnull environment variables.
261 76193d7c 2003-09-30 devnull A legal reference of the form
264 76193d7c 2003-09-30 devnull .B ${name}
265 76193d7c 2003-09-30 devnull is expanded as in
266 76193d7c 2003-09-30 devnull .IR sh (1).
267 76193d7c 2003-09-30 devnull A reference of the form
268 76193d7c 2003-09-30 devnull .BI ${name: A % B = C\fL%\fID\fL}\fR,
270 76193d7c 2003-09-30 devnull .I A, B, C, D
271 76193d7c 2003-09-30 devnull are (possibly empty) strings,
272 76193d7c 2003-09-30 devnull has the value formed by expanding
273 76193d7c 2003-09-30 devnull .B $name
274 76193d7c 2003-09-30 devnull and substituting
282 76193d7c 2003-09-30 devnull in each word in
283 76193d7c 2003-09-30 devnull .B $name
284 76193d7c 2003-09-30 devnull that matches pattern
285 76193d7c 2003-09-30 devnull .IB A % B\f1.
287 76193d7c 2003-09-30 devnull Variables can be set by
288 76193d7c 2003-09-30 devnull assignments of the form
290 76193d7c 2003-09-30 devnull var\fL=\fR[\fIattr\fL=\fR]\fIvalue\fR
292 76193d7c 2003-09-30 devnull Blanks in the
293 76193d7c 2003-09-30 devnull .I value
294 76193d7c 2003-09-30 devnull break it into words.
295 76193d7c 2003-09-30 devnull Such variables are exported
296 76193d7c 2003-09-30 devnull to the environment of
297 76193d7c 2003-09-30 devnull recipes as they are executed, unless
299 76193d7c 2003-09-30 devnull the only legal attribute
300 76193d7c 2003-09-30 devnull .IR attr ,
301 76193d7c 2003-09-30 devnull is present.
302 76193d7c 2003-09-30 devnull The initial value of a variable is
303 76193d7c 2003-09-30 devnull taken from (in increasing order of precedence)
304 76193d7c 2003-09-30 devnull the default values below,
306 76193d7c 2003-09-30 devnull environment, the
307 76193d7c 2003-09-30 devnull .IR mkfiles ,
308 76193d7c 2003-09-30 devnull and any command line assignment as an argument to
309 76193d7c 2003-09-30 devnull .IR mk .
310 76193d7c 2003-09-30 devnull A variable assignment argument overrides the first (but not any subsequent)
311 76193d7c 2003-09-30 devnull assignment to that variable.
312 76193d7c 2003-09-30 devnull The variable
313 76193d7c 2003-09-30 devnull .B MKFLAGS
314 76193d7c 2003-09-30 devnull contains all the option arguments (arguments starting with
316 76193d7c 2003-09-30 devnull or containing
319 76193d7c 2003-09-30 devnull .B MKARGS
320 76193d7c 2003-09-30 devnull contains all the targets in the call to
321 76193d7c 2003-09-30 devnull .IR mk .
323 76193d7c 2003-09-30 devnull Dynamic information may be included in the mkfile by using a line of the form
325 76193d7c 2003-09-30 devnull \fR<|\fIcommand\fR \fIargs\fR
327 76193d7c 2003-09-30 devnull This runs the command
328 76193d7c 2003-09-30 devnull .I command
329 76193d7c 2003-09-30 devnull with the given arguments
331 76193d7c 2003-09-30 devnull and pipes its standard output to
333 76193d7c 2003-09-30 devnull to be included as part of the mkfile. For instance, the Inferno kernels
334 76193d7c 2003-09-30 devnull use this technique
335 76193d7c 2003-09-30 devnull to run a shell command with an awk script and a configuration
336 76193d7c 2003-09-30 devnull file as arguments in order for
339 76193d7c 2003-09-30 devnull script to process the file and output a set of variables and their values.
340 76193d7c 2003-09-30 devnull .SS Execution
342 76193d7c 2003-09-30 devnull During execution,
344 76193d7c 2003-09-30 devnull determines which targets must be updated, and in what order,
345 76193d7c 2003-09-30 devnull to build the
346 76193d7c 2003-09-30 devnull .I names
347 76193d7c 2003-09-30 devnull specified on the command line.
348 76193d7c 2003-09-30 devnull It then runs the associated recipes.
350 76193d7c 2003-09-30 devnull A target is considered up to date if it has no prerequisites or
351 76193d7c 2003-09-30 devnull if all its prerequisites are up to date and it is newer
352 76193d7c 2003-09-30 devnull than all its prerequisites.
353 76193d7c 2003-09-30 devnull Once the recipe for a target has executed, the target is
354 76193d7c 2003-09-30 devnull considered up to date.
356 76193d7c 2003-09-30 devnull The date stamp
357 76193d7c 2003-09-30 devnull used to determine if a target is up to date is computed
358 76193d7c 2003-09-30 devnull differently for different types of targets.
359 76193d7c 2003-09-30 devnull If a target is
360 76193d7c 2003-09-30 devnull .I virtual
361 76193d7c 2003-09-30 devnull (the target of a rule with the
363 76193d7c 2003-09-30 devnull attribute),
364 76193d7c 2003-09-30 devnull its date stamp is initially zero; when the target is
365 76193d7c 2003-09-30 devnull updated the date stamp is set to
366 76193d7c 2003-09-30 devnull the most recent date stamp of its prerequisites.
367 76193d7c 2003-09-30 devnull Otherwise, if a target does not exist as a file,
368 76193d7c 2003-09-30 devnull its date stamp is set to the most recent date stamp of its prerequisites,
369 76193d7c 2003-09-30 devnull or zero if it has no prerequisites.
370 76193d7c 2003-09-30 devnull Otherwise, the target is the name of a file and
371 76193d7c 2003-09-30 devnull the target's date stamp is always that file's modification date.
372 76193d7c 2003-09-30 devnull The date stamp is computed when the target is needed in
373 76193d7c 2003-09-30 devnull the execution of a rule; it is not a static value.
375 76193d7c 2003-09-30 devnull Nonexistent targets that have prerequisites
376 76193d7c 2003-09-30 devnull and are themselves prerequisites are treated specially.
377 76193d7c 2003-09-30 devnull Such a target
379 76193d7c 2003-09-30 devnull is given the date stamp of its most recent prerequisite
380 76193d7c 2003-09-30 devnull and if this causes all the targets which have
382 76193d7c 2003-09-30 devnull as a prerequisite to be up to date,
384 76193d7c 2003-09-30 devnull is considered up to date.
385 76193d7c 2003-09-30 devnull Otherwise,
387 76193d7c 2003-09-30 devnull is made in the normal fashion.
390 76193d7c 2003-09-30 devnull flag overrides this special treatment.
392 76193d7c 2003-09-30 devnull Files may be made in any order that respects
393 76193d7c 2003-09-30 devnull the preceding restrictions.
395 76193d7c 2003-09-30 devnull A recipe is executed by supplying the recipe as standard input to
396 76193d7c 2003-09-30 devnull the command
397 76193d7c 2003-09-30 devnull .BR /bin/sh .
398 76193d7c 2003-09-30 devnull (Note that unlike
399 76193d7c 2003-09-30 devnull .IR make ,
401 76193d7c 2003-09-30 devnull feeds the entire recipe to the shell rather than running each line
402 76193d7c 2003-09-30 devnull of the recipe separately.)
403 76193d7c 2003-09-30 devnull The environment is augmented by the following variables:
405 76193d7c 2003-09-30 devnull .B $alltarget
406 76193d7c 2003-09-30 devnull all the targets of this rule.
408 76193d7c 2003-09-30 devnull .B $newprereq
409 76193d7c 2003-09-30 devnull the prerequisites that caused this rule to execute.
411 76193d7c 2003-09-30 devnull .B $newmember
412 76193d7c 2003-09-30 devnull the prerequisites that are members of an aggregate
413 76193d7c 2003-09-30 devnull that caused this rule to execute.
414 76193d7c 2003-09-30 devnull When the prerequisites of a rule are members of an
415 76193d7c 2003-09-30 devnull aggregate,
416 76193d7c 2003-09-30 devnull .B $newprereq
417 76193d7c 2003-09-30 devnull contains the name of the aggregate and out of date
418 76193d7c 2003-09-30 devnull members, while
419 76193d7c 2003-09-30 devnull .B $newmember
420 76193d7c 2003-09-30 devnull contains only the name of the members.
422 76193d7c 2003-09-30 devnull .B $nproc
423 76193d7c 2003-09-30 devnull the process slot for this recipe.
424 76193d7c 2003-09-30 devnull It satisfies
425 76193d7c 2003-09-30 devnull .RB 0≤ $nproc < $NPROC .
428 76193d7c 2003-09-30 devnull the process id for the
430 76193d7c 2003-09-30 devnull executing the recipe.
432 76193d7c 2003-09-30 devnull .B $prereq
433 76193d7c 2003-09-30 devnull all the prerequisites for this rule.
435 76193d7c 2003-09-30 devnull .B $stem
436 76193d7c 2003-09-30 devnull if this is a meta-rule,
437 76193d7c 2003-09-30 devnull .B $stem
438 76193d7c 2003-09-30 devnull is the string that matched
442 76193d7c 2003-09-30 devnull Otherwise, it is empty.
443 76193d7c 2003-09-30 devnull For regular expression meta-rules (see below), the variables
444 76193d7c 2003-09-30 devnull .LR stem0 ", ...,"
445 76193d7c 2003-09-30 devnull .L stem9
446 76193d7c 2003-09-30 devnull are set to the corresponding subexpressions.
448 76193d7c 2003-09-30 devnull .B $target
449 76193d7c 2003-09-30 devnull the targets for this rule that need to be remade.
451 76193d7c 2003-09-30 devnull These variables are available only during the execution of a recipe,
452 76193d7c 2003-09-30 devnull not while evaluating the
453 76193d7c 2003-09-30 devnull .IR mkfile .
455 76193d7c 2003-09-30 devnull Unless the rule has the
457 76193d7c 2003-09-30 devnull attribute,
458 76193d7c 2003-09-30 devnull the recipe is printed prior to execution
459 76193d7c 2003-09-30 devnull with recognizable environment variables expanded.
460 76193d7c 2003-09-30 devnull Commands returning error status
463 76193d7c 2003-09-30 devnull to terminate.
465 76193d7c 2003-09-30 devnull Recipes and backquoted
467 76193d7c 2003-09-30 devnull commands in places such as assignments
468 76193d7c 2003-09-30 devnull execute in a copy of
470 76193d7c 2003-09-30 devnull environment; changes they make to
471 76193d7c 2003-09-30 devnull environment variables are not visible from
472 76193d7c 2003-09-30 devnull .IR mk .
474 76193d7c 2003-09-30 devnull Variable substitution in a rule is done when
475 76193d7c 2003-09-30 devnull the rule is read; variable substitution in the recipe is done
476 76193d7c 2003-09-30 devnull when the recipe is executed. For example:
480 76193d7c 2003-09-30 devnull foo: $bar
481 76193d7c 2003-09-30 devnull $CC -o foo $bar
485 76193d7c 2003-09-30 devnull will compile
488 76193d7c 2003-09-30 devnull .BR foo ,
491 76193d7c 2003-09-30 devnull is newer than
492 76193d7c 2003-09-30 devnull .BR foo .
493 76193d7c 2003-09-30 devnull .SS Aggregates
494 76193d7c 2003-09-30 devnull Names of the form
495 76193d7c 2003-09-30 devnull .IR a ( b )
496 76193d7c 2003-09-30 devnull refer to member
498 76193d7c 2003-09-30 devnull of the aggregate
500 76193d7c 2003-09-30 devnull Currently, the only aggregates supported are
501 76193d7c 2003-09-30 devnull .IR ar (1)
502 76193d7c 2003-09-30 devnull archives.
503 76193d7c 2003-09-30 devnull .SS Attributes
504 76193d7c 2003-09-30 devnull The colon separating the target from the prerequisites
506 76193d7c 2003-09-30 devnull immediately followed by
507 76193d7c 2003-09-30 devnull .I attributes
508 76193d7c 2003-09-30 devnull and another colon.
509 76193d7c 2003-09-30 devnull The attributes are:
512 76193d7c 2003-09-30 devnull If the recipe exits with a non-null status, the target is deleted.
515 76193d7c 2003-09-30 devnull Continue execution if the recipe draws errors.
518 76193d7c 2003-09-30 devnull If there is no recipe, the target has its time updated.
521 76193d7c 2003-09-30 devnull The rule is a meta-rule that cannot be a target of a virtual rule.
522 76193d7c 2003-09-30 devnull Only files match the pattern in the target.
525 76193d7c 2003-09-30 devnull The characters after the
527 76193d7c 2003-09-30 devnull until the terminating
529 76193d7c 2003-09-30 devnull are taken as a program name.
530 76193d7c 2003-09-30 devnull It will be invoked as
531 76193d7c 2003-09-30 devnull .B "sh -c prog 'arg1' 'arg2'"
532 76193d7c 2003-09-30 devnull and should return a zero exit status
533 76193d7c 2003-09-30 devnull if and only if arg1 is up to date with respect to arg2.
534 76193d7c 2003-09-30 devnull Date stamps are still propagated in the normal way.
537 76193d7c 2003-09-30 devnull The recipe is not printed prior to execution.
540 76193d7c 2003-09-30 devnull The rule is a meta-rule using regular expressions.
541 76193d7c 2003-09-30 devnull In the rule,
543 76193d7c 2003-09-30 devnull has no special meaning.
544 76193d7c 2003-09-30 devnull The target is interpreted as a regular expression as defined in
545 76193d7c 2003-09-30 devnull .IR regexp (6).
546 76193d7c 2003-09-30 devnull The prerequisites may contain references
547 76193d7c 2003-09-30 devnull to subexpressions in form
548 76193d7c 2003-09-30 devnull .BI \e n\f1,
549 76193d7c 2003-09-30 devnull as in the substitute command of
550 76193d7c 2003-09-30 devnull .IR sed (1).
553 76193d7c 2003-09-30 devnull The targets are considered to have been updated
554 76193d7c 2003-09-30 devnull even if the recipe did not do so.
557 76193d7c 2003-09-30 devnull The targets of this rule are marked as virtual.
558 76193d7c 2003-09-30 devnull They are distinct from files of the same name.
560 76193d7c 2003-09-30 devnull .SH EXAMPLES
561 76193d7c 2003-09-30 devnull A simple mkfile to compile a program:
564 76193d7c 2003-09-30 devnull .ta 8n +8n +8n +8n +8n +8n +8n
565 76193d7c 2003-09-30 devnull </$objtype/mkfile
567 76193d7c 2003-09-30 devnull prog: a.$O b.$O c.$O
568 76193d7c 2003-09-30 devnull $LD $LDFLAGS -o $target $prereq
570 76193d7c 2003-09-30 devnull %.$O: %.c
571 76193d7c 2003-09-30 devnull $CC $CFLAGS $stem.c
574 76193d7c 2003-09-30 devnull Override flag settings in the mkfile:
577 76193d7c 2003-09-30 devnull % mk target 'CFLAGS=-S -w'
580 76193d7c 2003-09-30 devnull Maintain a library:
583 76193d7c 2003-09-30 devnull libc.a(%.$O):N: %.$O
584 76193d7c 2003-09-30 devnull libc.a: libc.a(abs.$O) libc.a(access.$O) libc.a(alarm.$O) ...
585 76193d7c 2003-09-30 devnull ar r libc.a $newmember
588 76193d7c 2003-09-30 devnull String expression variables to derive names from a master list:
591 76193d7c 2003-09-30 devnull NAMES=alloc arc bquote builtins expand main match mk var word
592 76193d7c 2003-09-30 devnull OBJ=${NAMES:%=%.$O}
595 76193d7c 2003-09-30 devnull Regular expression meta-rules:
598 76193d7c 2003-09-30 devnull ([^/]*)/(.*)\e.$O:R: \e1/\e2.c
599 76193d7c 2003-09-30 devnull cd $stem1; $CC $CFLAGS $stem2.c
602 76193d7c 2003-09-30 devnull A correct way to deal with
603 76193d7c 2003-09-30 devnull .IR yacc (1)
604 76193d7c 2003-09-30 devnull grammars.
605 76193d7c 2003-09-30 devnull The file
606 76193d7c 2003-09-30 devnull .B lex.c
607 76193d7c 2003-09-30 devnull includes the file
608 76193d7c 2003-09-30 devnull .B x.tab.h
609 76193d7c 2003-09-30 devnull rather than
610 76193d7c 2003-09-30 devnull .B y.tab.h
611 76193d7c 2003-09-30 devnull in order to reflect changes in content, not just modification time.
614 76193d7c 2003-09-30 devnull lex.$O: x.tab.h
615 76193d7c 2003-09-30 devnull x.tab.h: y.tab.h
616 76193d7c 2003-09-30 devnull cmp -s x.tab.h y.tab.h || cp y.tab.h x.tab.h
617 76193d7c 2003-09-30 devnull y.tab.c y.tab.h: gram.y
618 76193d7c 2003-09-30 devnull $YACC -d gram.y
621 76193d7c 2003-09-30 devnull The above example could also use the
623 76193d7c 2003-09-30 devnull attribute for the
624 76193d7c 2003-09-30 devnull .B x.tab.h
628 76193d7c 2003-09-30 devnull x.tab.h:Pcmp -s: y.tab.h
629 76193d7c 2003-09-30 devnull cp y.tab.h x.tab.h
631 76193d7c 2003-09-30 devnull .SH SEE ALSO
632 76193d7c 2003-09-30 devnull .IR sh (1),
633 76193d7c 2003-09-30 devnull .IR regexp9 (7)
635 76193d7c 2003-09-30 devnull A. Hume,
636 76193d7c 2003-09-30 devnull ``Mk: a Successor to Make''
637 76193d7c 2003-09-30 devnull (Tenth Edition Research Unix Manuals).
639 76193d7c 2003-09-30 devnull Andrew G. Hume and Bob Flandrena,
640 76193d7c 2003-09-30 devnull ``Maintaining Files on Plan 9 with Mk''.
641 76193d7c 2003-09-30 devnull DOCPREFIX/doc/mk.pdf
642 76193d7c 2003-09-30 devnull .SH HISTORY
643 76193d7c 2003-09-30 devnull Andrew Hume wrote
645 76193d7c 2003-09-30 devnull for Tenth Edition Research Unix.
646 76193d7c 2003-09-30 devnull It was later ported to Plan 9.
647 76193d7c 2003-09-30 devnull This software is a port of the Plan 9 version back to Unix.
648 76193d7c 2003-09-30 devnull .SH BUGS
649 76193d7c 2003-09-30 devnull Identical recipes for regular expression meta-rules only have one target.
651 76193d7c 2003-09-30 devnull Seemingly appropriate input like
652 76193d7c 2003-09-30 devnull .B CFLAGS=-DHZ=60
653 76193d7c 2003-09-30 devnull is parsed as an erroneous attribute; correct it by inserting
654 76193d7c 2003-09-30 devnull a space after the first
657 76193d7c 2003-09-30 devnull The recipes printed by
659 76193d7c 2003-09-30 devnull before being passed to
661 76193d7c 2003-09-30 devnull for execution are sometimes erroneously expanded
662 76193d7c 2003-09-30 devnull for printing. Don't trust what's printed; rely