mk.ms 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  1. .TL
  2. Maintaining Files on Plan 9 with Mk
  3. .AU
  4. Andrew G. Hume
  5. andrew@research.att.com
  6. Bob Flandrena
  7. bobf@plan9.bell-labs.com
  8. .AB
  9. .PP
  10. .CW Mk
  11. is a tool
  12. for describing and maintaining dependencies between
  13. files.
  14. It is similar to the
  15. UNIX program
  16. .CW make ,
  17. but provides several new capabilities.
  18. .CW Mk\fR'\fPs
  19. flexible rule specifications, implied
  20. dependency derivation, and parallel
  21. execution of maintenance actions are
  22. well-suited to the Plan 9 environment.
  23. Almost all Plan 9 maintenance procedures
  24. are automated using
  25. .CW mk .
  26. .AE
  27. .NH 1
  28. Introduction
  29. .PP
  30. .CW Mk
  31. performs the same task as
  32. .CW make
  33. [Feld79] but is different in many ways.
  34. This document describes
  35. .CW mk\fR'\fPs
  36. capabilities and discusses how they are
  37. used in Plan 9. There are occasional references
  38. to differences between
  39. .CW mk
  40. and
  41. .CW make ,
  42. but
  43. an appendix summarizes the details.
  44. .PP
  45. .CW Mk
  46. works well in the Plan 9 environment.
  47. It supports program construction
  48. in a heterogeneous environment and
  49. exploits the power of multiprocessors by executing
  50. maintenance actions in parallel.
  51. It interacts seamlessly with the Plan 9 command
  52. interpreter
  53. .CW rc
  54. and accepts pattern-based dependency specifications
  55. that are not limited to describing
  56. rules for program construction.
  57. The result is a tool that is flexible enough to
  58. perform many maintenance tasks including
  59. database maintenance,
  60. hardware design, and document production.
  61. .PP
  62. This document begins by discussing
  63. the syntax of the input file,
  64. the pattern matching capabilities, and
  65. the special rules for maintaining archives.
  66. A brief description of
  67. .CW mk\fR'\fPs
  68. algorithm for deriving dependencies
  69. is followed by a discussion
  70. of the conventions used to resolve ambiguous
  71. specifications. The final sections
  72. describe parallel execution
  73. and special features.
  74. .PP
  75. An earlier paper [Hume87]
  76. provides a detailed discussion of
  77. .CW mk\fR'\fPs
  78. design.
  79. .NH 1
  80. The \f(CWMkfile\fP
  81. .PP
  82. .CW Mk
  83. reads a file describing relationships among files
  84. and executes commands to bring the files up to date.
  85. The specification file, called a
  86. .CW mkfile ,
  87. contains three types of statements:
  88. assignments, includes, and rules.
  89. Assignment and include statements are similar
  90. to those in C.
  91. Rules specify dependencies between a
  92. .I target
  93. and its
  94. .I prerequisites .
  95. When the target and prerequisites are files, their
  96. modification times determine if they
  97. are out of date. Rules often contain a
  98. .I recipe ,
  99. an
  100. .I rc (1)
  101. script that produces the target from
  102. the prerequisites.
  103. .PP
  104. This simple
  105. .CW mkfile
  106. produces an executable
  107. from a C source file:
  108. .P1
  109. CC=pcc
  110. f1: f1.c
  111. $CC -o f1 f1.c
  112. .P2
  113. The first line assigns the name of the portable ANSI/POSIX compiler
  114. to the
  115. .CW mk
  116. variable
  117. .CW CC ;
  118. subsequent references of the form
  119. .CW $CC
  120. select this compiler.
  121. The only rule specifies a dependence between the target file
  122. .CW f1
  123. and the prerequisite file
  124. .CW f1.c .
  125. If the target does not exist or if the
  126. prerequisite has been modified more recently than
  127. the target,
  128. .CW mk
  129. passes the recipe to
  130. .CW rc
  131. for execution. Here,
  132. .CW f1.c
  133. is compiled and loaded to produce
  134. .CW f1 .
  135. .PP
  136. The native Plan 9 environment
  137. requires executables for
  138. all architectures, not only the current one.
  139. The Plan 9 version of the same
  140. .CW mkfile
  141. looks like:
  142. .P1
  143. </$objtype/mkfile
  144. CFLAGS=-w
  145. f1: f1.$O
  146. $LD $LDFLAGS -o f1 f1.$O
  147. f1.$O: f1.c
  148. $CC $CFLAGS f1.c
  149. .P2
  150. The first line is an include statement
  151. that replaces itself with the contents of the file
  152. .CW /$objtype/mkfile .
  153. The variable
  154. .CW $objtype
  155. is inherited from the environment and
  156. contains the name of the target architecture.
  157. The prototype
  158. .CW mkfile
  159. for that architecture defines architecture-specific variables:
  160. .CW CC
  161. and
  162. .CW LD
  163. are the names of the compiler and loader,
  164. .CW O
  165. is the code character of the architecture.
  166. The rules compile the source file into an object
  167. file and invoke the loader to produce
  168. .CW f1 .
  169. Invoking
  170. .CW mk
  171. from the command line as follows
  172. .P1
  173. % objtype=sparc mk
  174. kc -w f1.c
  175. kl $LDFLAGS -o f1 f1.k
  176. %
  177. .P2
  178. produces the
  179. .CW sparc
  180. executable of program
  181. .CW f1
  182. regardless of the current architecture type.
  183. .PP
  184. We can extend the
  185. .CW mkfile
  186. to build two programs:
  187. .P1
  188. </$objtype/mkfile
  189. CFLAGS=-w
  190. ALL=f1 f2
  191. all:V: $ALL
  192. f1: f1.$O
  193. $LD $LDFLAGS -o f1 f1.$O
  194. f1.$O: f1.c
  195. $CC $CFLAGS f1.c
  196. f2: f2.$O
  197. $LD $LDFLAGS -o f2 f2.$O
  198. f2.$O: f2.c
  199. $CC $CFLAGS f2.c
  200. .P2
  201. The target
  202. .CW all ,
  203. modified by the
  204. .I attribute
  205. .CW V ,
  206. builds both programs.
  207. The attribute identifies
  208. .CW all
  209. as a dummy target that is
  210. not related to a file of the same name;
  211. its precise effect is explained later.
  212. This example describes cascading dependencies:
  213. the first target depends on another which depends on a third and
  214. so on.
  215. Here, individual rules build each
  216. program; later we'll see how to do this with a
  217. general rule.
  218. .NH 1
  219. Variables and the environment
  220. .PP
  221. .CW Mk
  222. does not distinguish between its
  223. variables and
  224. .CW rc
  225. variables in the environment.
  226. When
  227. .CW mk
  228. starts, it imports each environment variable into a
  229. .CW mk
  230. variable of the same name. Before executing a recipe,
  231. .CW mk
  232. exports all variables, including those
  233. inherited from the environment,
  234. to the environment in which
  235. .CW rc
  236. executes the recipe.
  237. .PP
  238. There are several ways for a
  239. variable to take a value.
  240. It can be set with an assignment statement,
  241. inherited from the environment, or specified
  242. on the command line.
  243. .CW Mk
  244. also maintains several internal variables;
  245. these variables are described in
  246. .I mk (1).
  247. Assignments have the following decreasing order of precedence:
  248. .LP
  249. .in .7i
  250. 1) Command line assignment
  251. .br
  252. 2) Assignment statement
  253. .br
  254. 3) Imported from the environment
  255. .br
  256. 4) Implicitly set by \f(CWmk\fP
  257. .in 0
  258. .LP
  259. For example, a command line assignment overrides
  260. a value imported from the environment.
  261. .PP
  262. All variable values are strings. They can be
  263. used for pattern matching and
  264. comparison but not for arithmetic.
  265. A
  266. .I list
  267. is a string containing several values separated by
  268. white space. Each member is
  269. handled individually during pattern matching,
  270. target selection, and prerequisite evaluation.
  271. .PP
  272. A
  273. .I namelist
  274. is a list produced by
  275. transforming the members of an existing list.
  276. The transform applies a pattern to each member,
  277. replacing each matched string with a new string,
  278. much as in the substitute command in
  279. .I sam (1)
  280. or
  281. .I ed (1).
  282. The syntax is
  283. .P1
  284. ${\fIvar\fP:A%B=C%D}
  285. .P2
  286. where
  287. .I var
  288. is a variable.
  289. The pattern
  290. .CW A%B
  291. matches a member beginning with the string
  292. .I A
  293. and ending with the string
  294. .I B
  295. with any string in between;
  296. it behaves like the regular expression
  297. .CW A.*B .
  298. When a member of the
  299. .I var
  300. list
  301. matches this pattern,
  302. the string
  303. .I C
  304. replaces
  305. .I A ,
  306. .I D
  307. replaces
  308. .I B ,
  309. and the matched string replaces itself.
  310. Any of
  311. .I A ,
  312. .I B ,
  313. .I C ,
  314. or
  315. .I D
  316. may be the empty string. In effect, a namelist is
  317. generated by applying the
  318. .I ed (1)
  319. substitute command
  320. .P1
  321. s/\fIA\fP(.*)\fIB\fP/\fIC\fP\e1\fID\fP/
  322. .P2
  323. to each member of a variable.
  324. .PP
  325. Namelists are useful for generating
  326. a list based on a predictable transformation.
  327. For example,
  328. .P1
  329. SRC=a.c b.c c.c
  330. OBJ=${SRC:%.c=%.v}
  331. .P2
  332. assigns the list \f(CW(a.v b.v c.v)\fP to
  333. .CW OBJ .
  334. A namelist may be used anywhere a variable is allowed
  335. except in a recipe.
  336. .PP
  337. Command output is assigned to a variable
  338. using the normal
  339. .CW rc
  340. syntax:
  341. .P1
  342. var=`{rc command}
  343. .P2
  344. The command executes in an environment populated
  345. with previously assigned variables, including those
  346. inherited from
  347. .CW mk\fR'\fPs
  348. execution environment.
  349. The command may
  350. be arbitrarily complex; for example,
  351. .P1
  352. TARG=`{ls -d *.[cyl] | sed 's/..$//'}
  353. .P2
  354. assigns a list of the C, yacc, and Alef source files in the current
  355. directory, stripped of their suffix, to the variable
  356. .CW TARG .
  357. .NH 1
  358. The include statement
  359. .PP
  360. The include statement
  361. replaces itself with the contents of a file.
  362. It is functionally similar to the C
  363. .CW #include
  364. statement but uses a different syntax:
  365. .P1
  366. <\fIfilename\fP
  367. .P2
  368. The contents of the file are evaluated
  369. as they are read.
  370. An include statement may be used anywhere except
  371. in a recipe.
  372. .PP
  373. Unlike
  374. .CW make ,
  375. .CW mk
  376. has no built-in rules. Instead,
  377. the include statement allows generic rules
  378. to be imported from a prototype
  379. .CW mkfile ;
  380. most Plan 9
  381. .CW mkfiles
  382. use this approach [Flan95].
  383. .NH 1
  384. Rules
  385. .PP
  386. A rule has four elements: targets,
  387. prerequisites, attributes, and a recipe.
  388. It has the form:
  389. .P1
  390. \fItargets\fP:\fIattributes\fP:\fIprerequisites\fP
  391. \fIrecipe\fP
  392. .P2
  393. The first line, containing the
  394. targets, attributes, and prerequisites is
  395. the
  396. .I "rule header" ;
  397. it
  398. must begin at the left margin.
  399. The recipe contains zero or more lines,
  400. each of which begins with white space.
  401. One or more targets must be specified but the
  402. attributes, prerequisites, and recipe are optional.
  403. A rule specifies
  404. a dependency between the targets and the prerequisites;
  405. the recipe brings the targets
  406. up to date with the prerequisites.
  407. Attributes modify
  408. .CW mk\fR'\fPs
  409. evaluation of a rule.
  410. .PP
  411. Normally the target is a file that depends
  412. on one or more prerequisite files.
  413. .CW Mk
  414. compares the modification times of each target
  415. and each prerequisite; a target is considered out of date
  416. when it does not exist or when a prerequisite has been modified
  417. more recently.
  418. When a target is out of date,
  419. .CW mk
  420. executes the
  421. recipe to bring it up to date.
  422. When the recipe completes,
  423. the modification time of the target is checked and
  424. used in later dependency evaluations.
  425. If the recipe does not update the target,
  426. evaluation continues with the out of date target.
  427. .PP
  428. A prerequisite of one rule
  429. may be the target of another. When
  430. this happens, the rules cascade
  431. to define a multi-step procedure.
  432. For example,
  433. an executable target depends on prerequisite
  434. object files, each of which is a target
  435. in a rule with a C source file as the prerequisite.
  436. .CW Mk
  437. follows a chain of dependencies until it encounters
  438. a prerequisite that is not a target of another rule
  439. or it finds a target that
  440. is up to date. It then
  441. executes the recipes in reverse order to produce
  442. the desired target.
  443. .PP
  444. The rule header is evaluated when the rule is read.
  445. Variables are replaced by their values, namelists are
  446. generated, and
  447. commands are replaced by their
  448. output at this time.
  449. .PP
  450. Most attributes modify
  451. .CW mk\fR'\fPs
  452. evaluation of a rule.
  453. An attribute is usually a single letter but some
  454. are more complicated.
  455. This paper only discusses commonly used attributes;
  456. see
  457. .I mk (1)
  458. for a complete list.
  459. .PP
  460. The
  461. .CW V
  462. attribute identifies a
  463. .I virtual
  464. target;
  465. that is, a target that is not a file.
  466. For example,
  467. .P1
  468. clean:V:
  469. rm *.$O $O.out
  470. .P2
  471. removes executables and compiler intermediate files.
  472. The target is virtual because it does not refer to a file named
  473. .CW clean .
  474. Without the attribute, the recipe would not be
  475. executed if a file named
  476. .CW clean
  477. existed.
  478. The
  479. .CW Q
  480. silences the default printing of a recipe before
  481. it is executed.
  482. It is useful when the output of a recipe is
  483. similar to the recipe:
  484. .P1
  485. default:QV:
  486. echo 'No default target; use mk all or mk install'
  487. .P2
  488. .PP
  489. A recipe is an
  490. .CW rc
  491. script. The recipe is optional; when it is
  492. missing, the rule is handled specially, as described later.
  493. Unlike
  494. .CW make ,
  495. .CW mk
  496. executes recipes without interpretation.
  497. After
  498. stripping the first white space character from each line
  499. it passes the entire recipe to
  500. .CW rc
  501. on standard input.
  502. Since
  503. .CW mk
  504. does not interpret a recipe,
  505. escape conventions are exactly those of
  506. .CW rc .
  507. Scripts for
  508. .CW awk
  509. and
  510. .CW sed
  511. commands can be embedded just as they would
  512. be specified from the command line.
  513. .CW Mk
  514. invokes
  515. .CW rc
  516. with the
  517. .CW -e
  518. flag, which causes
  519. .CW rc
  520. to stop if any command
  521. in the recipe exits with a non-zero status; the
  522. .CW E
  523. attribute overrides this behavior and allows
  524. .CW rc
  525. to continue executing in the face of errors.
  526. Before a recipe is executed, variables are exported
  527. to the environment where
  528. .CW rc
  529. can see them.
  530. Recipe commands may not read from
  531. standard input because
  532. .CW mk
  533. uses it internally.
  534. .PP
  535. References to a variable can yield different
  536. values depending on the location of the
  537. reference in the
  538. .CW mkfile .
  539. .CW Mk
  540. resolves variable references
  541. in assignment statements and rule headers
  542. when the statement is read. Variable references
  543. in recipes are evaluated by
  544. .CW rc
  545. when the recipe is executed; this
  546. happens after the entire
  547. .CW mkfile
  548. has been read. The value of a variable in a recipe
  549. is the last value assigned in the file. For example,
  550. .P1
  551. STRING=all
  552. all:VQ:
  553. echo $STRING
  554. STRING=none
  555. .P2
  556. produces the message
  557. .CW none .
  558. A variable assignment in a recipe
  559. does not affect the value of the variable in the
  560. .CW mkfile
  561. for two reasons.
  562. First,
  563. .CW mk
  564. does not import values from
  565. the environment when a recipe completes;
  566. one recipe cannot pass a value through
  567. the environment to another recipe.
  568. Second, no recipe is executed until
  569. .CW mk
  570. has completed its evaluation, so even if a variable
  571. were changed,
  572. it would not affect the dependency evaluation.
  573. .NH 1
  574. Metarules
  575. .PP
  576. A
  577. .I metarule
  578. is a rule based on a pattern.
  579. The pattern selects a class of target and
  580. identifies related prerequisites.
  581. .CW Mk
  582. metarules may select targets and prerequisites
  583. based on any criterion that can be described by a pattern, not just
  584. the suffix transformations associated with program
  585. construction.
  586. .PP
  587. .CW Mk
  588. has two types of patterns:
  589. .I intrinsic
  590. patterns or regular expressions conforming to the
  591. syntax of
  592. .I regexp (6).
  593. The intrinsic patterns are shorthand
  594. for common regular expressions.
  595. The intrinsic pattern
  596. .CW %
  597. matches one or more of anything; it is equivalent to
  598. the regular expression
  599. .CW `.+' .
  600. The other intrinsic pattern,
  601. .CW & ,
  602. matches one or more of any characters except \f(CW`/'\fP
  603. and \f(CW`.'\fP.
  604. It matches a portion of a path and is
  605. equivalent to the regular expression
  606. .CW `[^./]+' .
  607. An intrinsic pattern in a prerequisite references
  608. the string matched by the same intrinsic pattern in the target.
  609. For example, the rule
  610. .P1
  611. %.v: %.c
  612. .P2
  613. says that a file ending in
  614. .CW .v
  615. depends on a file of the same name with a
  616. .CW .c
  617. suffix:
  618. .CW foo.v
  619. depends on
  620. .CW foo.c ,
  621. .CW bar.v
  622. depends on
  623. .CW bar.c ,
  624. and so on.
  625. The string matched by an intrinsic pattern in the target
  626. is supplied to the recipe in the variable
  627. .CW $stem .
  628. Thus the rule
  629. .P1
  630. %.$O: %.c
  631. $CC $CFLAGS $stem.c
  632. .P2
  633. creates an object file for the target architecture from
  634. a similarly named C source file. If several object
  635. files are out of date, the rule is applied repeatedly and
  636. .CW $stem
  637. refers to each file in turn.
  638. Since there is only one
  639. .CW stem
  640. variable, there can only be one
  641. .CW %
  642. or
  643. .CW &
  644. pattern in a target;
  645. the pattern
  646. .CW %-%.c
  647. is illegal.
  648. .PP
  649. Metarules simplify the
  650. .CW mkfile
  651. for building programs
  652. .CW f1
  653. and
  654. .CW f2 :
  655. .P1
  656. </$objtype/mkfile
  657. CFLAGS=-w
  658. ALL=f1 f2
  659. all:V: $ALL
  660. %: %.$O
  661. $LD -o $target $prereq
  662. %.$O: %.c
  663. $CC $CFLAGS $stem.c
  664. clean:V:
  665. rm -f $ALL *.[$OS]
  666. .P2
  667. (The variable
  668. .CW $OS
  669. is a list of code characters for all architectures.)
  670. Here, metarules specify
  671. compile and load steps for all files.
  672. The loader rule relies on two internal variables
  673. set by
  674. .CW mk
  675. during evaluation of the rule:
  676. .CW $target
  677. is the name of the target and
  678. .CW $prereq
  679. the name of all prerequisites.
  680. Metarules allow this
  681. .CW mkfile
  682. to be easily extended; a new program
  683. is supported by adding its name to the third line.
  684. .PP
  685. A regular expression metarule must have an
  686. .CW R
  687. attribute.
  688. Prerequisites may reference matching substrings in
  689. the target using the form
  690. .CW \e\fIn\fP
  691. where
  692. .I n
  693. is a digit from 1 to 9 specifying the
  694. .I n th
  695. parenthesized sub-expression. In a recipe,
  696. .CW $stem\fIn\fP
  697. is the equivalent reference.
  698. For example, a compile rule could be
  699. specified using regular expressions:
  700. .P1
  701. (.+)\e.$O:R: \e1.c
  702. $CC $CFLAGS $stem1.c
  703. .P2
  704. Here,
  705. .CW \e1
  706. and
  707. .CW $stem1
  708. refer to the name of the target object file without the
  709. suffix. The variable
  710. .CW $stem
  711. associated with an intrinsic pattern is undefined
  712. in a regular expression metarule.
  713. .NH 1
  714. Archives
  715. .PP
  716. .CW Mk
  717. provides a special mechanism for maintaining an archive.
  718. An archive member is referenced using the form
  719. .CW \fIlib\fP(\fIfile\fP)
  720. where
  721. .I lib
  722. is the name of the archive and
  723. .I file
  724. is the name of the member. Two rules define the
  725. dependency between an object file and its membership
  726. in an archive:
  727. .P1
  728. $LIB(foo.v):N: foo.v
  729. $LIB: $LIB(foo.v)
  730. ar rv $LIB foo.v
  731. .P2
  732. The first rule establishes a dependency between the
  733. archive member and the object file.
  734. Normally,
  735. .CW mk
  736. detects an error when a target does not exist and the rule
  737. contains no recipe; the
  738. .CW N
  739. attribute overrides this behavior because the subsequent rule
  740. updates the member.
  741. The second
  742. rule establishes the dependency between the member and
  743. the archive; its recipe inserts the member
  744. into the archive.
  745. This two-step specification allows the archive
  746. to represent the state of its members. Other rules
  747. can then specify the archive as a prerequisite instead of
  748. listing each member.
  749. .PP
  750. A metarule generalizes library maintenance:
  751. .P1
  752. LIB=lib.a
  753. OBJS=etoa.$O atoe.$O ebcdic.$O
  754. $LIB(%):N: %
  755. $LIB: ${OBJS:%=$LIB(%)}
  756. ar rv $LIB $OBJS
  757. .P2
  758. The namelist prerequisite of the
  759. .CW $LIB
  760. target generates archive member names for each object file name;
  761. for example,
  762. .CW etoa.$O
  763. becomes
  764. .CW lib.a(etoa.$O) .
  765. This formulation always updates all members.
  766. This is acceptable for a small archive, but may
  767. be slow for a big one.
  768. The rule
  769. .P1
  770. $LIB: ${OBJS:%=$LIB(%)}
  771. ar rv $LIB `{membername $newprereq}
  772. .P2
  773. only updates out of date object files.
  774. The internal variable
  775. .CW $newprereq
  776. contains the names of the out of
  777. date prerequisites. The
  778. .CW rc
  779. script
  780. .CW membername
  781. transforms an archive member specification into a file name:
  782. it translates
  783. .CW lib.a(etoa.$O)
  784. into
  785. .CW etoa.$O .
  786. .PP
  787. The
  788. .CW mkfile
  789. .P1
  790. </$objtype/mkfile
  791. LIB=lib.a
  792. OBJS=etoa.$O atoe.$O ebcdic.$O
  793. prog: main.$O $LIB
  794. $LD -o $target $prereq
  795. $LIB(%):N: %
  796. $LIB: ${OBJS:%=$LIB(%)}
  797. ar rv $LIB $OBJS
  798. .P2
  799. builds a program by loading it with a library.
  800. .NH 1
  801. Evaluation algorithm
  802. .PP
  803. For each target of interest,
  804. .CW mk
  805. uses the rules in a
  806. .CW mkfile
  807. to build a data
  808. structure called a dependency graph. The nodes of
  809. the graph represent targets and prerequisites;
  810. a directed arc
  811. from one node to another indicates that
  812. the file associated with the first node depends
  813. on the file associated with the second.
  814. When the
  815. .CW mkfile
  816. has been completely read, the graph is analyzed.
  817. In the first step, implied dependencies are resolved by
  818. computing the
  819. .I "transitive closure"
  820. of the graph.
  821. This calculation extends the graph to include all
  822. targets that are potentially
  823. derivable from the rules in the
  824. .CW mkfile .
  825. Next the graph is checked for cycles;
  826. .CW make
  827. accepts cyclic dependencies, but
  828. .CW mk
  829. does not allow them.
  830. Subsequent steps
  831. prune subgraphs that are irrelevant for producing the
  832. desired target and verify that there is only one way
  833. to build it.
  834. The recipes associated with the
  835. nodes on the longest path between the
  836. target and an out of date prerequisite
  837. are then executed in reverse order.
  838. .PP
  839. The transitive closure calculation is sensitive to
  840. metarules; the patterns often select many potential targets
  841. and cause the graph to grow rapidly.
  842. Fortunately,
  843. dependencies associated with the desired target
  844. usually form a small part of the graph, so, after
  845. pruning, analysis is tractable.
  846. For example, the rules
  847. .P1
  848. %: x.%
  849. recipe1
  850. x.%: %.k
  851. recipe2
  852. %.k: %.f
  853. recipe3
  854. .P2
  855. produce a graph with four nodes for each file in the
  856. current directory.
  857. If the desired target is
  858. .CW foo ,
  859. .CW mk
  860. detects the dependency between it
  861. and the original file
  862. .CW foo.f
  863. through intermediate dependencies on
  864. .CW foo.k
  865. and
  866. .CW x.foo .
  867. Nodes associated with other files are deleted during pruning because
  868. they are irrelevant to the production of
  869. .CW foo .
  870. .PP
  871. .CW Mk
  872. avoids infinite cycles by evaluating
  873. each metarule once.
  874. Thus, the rule
  875. .P1
  876. %: %.z
  877. cp $prereq $prereq.z
  878. .P2
  879. copies the prerequisite file once.
  880. .NH 1
  881. Conventions for evaluating rules
  882. .PP
  883. There must be only one
  884. way to build each target. However, during evaluation
  885. metarule patterns often select potential targets that
  886. conflict with the
  887. targets of other rules.
  888. .CW Mk
  889. uses several conventions to resolve ambiguities
  890. and to select the proper dependencies.
  891. .PP
  892. When a target selects more than one rule,
  893. .CW mk
  894. chooses a regular rule
  895. over a metarule.
  896. For example, the
  897. .CW mkfile
  898. .P1
  899. </$objtype/mkfile
  900. CFLAGS=-w
  901. FILES=f1.$O f2.$O f3.$O
  902. prog: $FILES
  903. $LD -o $target $prereq
  904. %.$O: %.c
  905. $CC $CFLAGS $stem.c
  906. f2.$O: f2.c
  907. $CC f2.c
  908. .P2
  909. contains two rules that could build
  910. .CW f2.$O .
  911. .CW Mk
  912. selects the last rule because its target,
  913. .CW f2.$O ,
  914. is explicitly specified, while the
  915. .CW %.$O
  916. rule is a metarule. In effect,
  917. the explicit rule for
  918. .CW f2.$O
  919. overrides the general rule for building object files from
  920. C source files.
  921. .PP
  922. When a rule has a target and prerequisites but no recipe,
  923. those prerequisites are added to all other rules with
  924. recipes that have the same target.
  925. All prerequisites, regardless of where they were specified, are
  926. available in the recipe in variable
  927. .CW $prereq .
  928. For example, in
  929. .P1
  930. </$objtype/mkfile
  931. CFLAGS=-w
  932. FILES=f1.$O f2.$O f3.$O
  933. prog: $FILES
  934. $LD -o $target $prereq
  935. %.$O: hdr.h
  936. %.$O: %.c
  937. $CC $CFLAGS $stem.c
  938. .P2
  939. the second rule adds
  940. .CW hdr.h
  941. as a prerequisite of the compile metarule;
  942. an object file produced from a C source file
  943. depends on
  944. .CW hdr.h
  945. as well as the source file. Notice that the recipe of
  946. the compile rule uses
  947. .CW $stem.c
  948. instead of
  949. .CW $prereq
  950. because the latter specification would attempt to compile
  951. .CW hdr.h .
  952. .PP
  953. When a target is virtual and there is no other rule with
  954. the same target,
  955. .CW mk
  956. evaluates each prerequisite.
  957. For example, adding the rule
  958. .P1
  959. all:V: prog
  960. .P2
  961. to the preceding example builds the executable
  962. when either
  963. .CW prog
  964. or
  965. .CW all
  966. is the specified target. In effect, the
  967. .CW all
  968. target is an alias for
  969. .CW prog .
  970. .PP
  971. When two rules have identical rule headers and both have
  972. recipes, the later rule replaces the former one.
  973. For example,
  974. if a file named
  975. .CW mkrules
  976. contains
  977. .P1
  978. $O.out: $OFILES
  979. $LD $LFLAGS $OFILES
  980. %.$O: %.c
  981. $CC $CFLAGS $stem.c
  982. .P2
  983. the
  984. .CW mkfile
  985. .P1
  986. OFILES=f1.$O f2.$O f3.$O
  987. <mkrules
  988. $O.out: $OFILES
  989. $LD $LFLAGS -l $OFILES -lbio -lc
  990. .P2
  991. overrides the general loader rule with a special
  992. rule using a non-standard library search sequence.
  993. A rule is neutralized by overriding it with a rule
  994. with a null recipe:
  995. .P1
  996. <mkrules
  997. $O.out:Q: $OFILES
  998. ;
  999. .P2
  1000. The
  1001. .CW Q
  1002. attribute suppresses the printing of the semicolon.
  1003. .PP
  1004. When a rule has no prerequisites, the recipe is executed
  1005. only when the target does not exist. For example,
  1006. .P1
  1007. marker:
  1008. touch $target
  1009. .P2
  1010. defines a rule to manage a marker file.
  1011. If the file exists, it is considered up to date
  1012. regardless of its modification time.
  1013. When a virtual target has no prerequisites the
  1014. recipe is always executed.
  1015. The
  1016. .CW clean
  1017. rule is of this type:
  1018. .P1
  1019. clean:V:
  1020. rm -f [$OS].out *.[$OS]
  1021. .P2
  1022. When a rule without prerequisites has multiple targets, the
  1023. extra targets are aliases for the rule.
  1024. For example, in
  1025. .P1
  1026. clean tidy nuke:V:
  1027. rm -f [$OS].out *.[$OS]
  1028. .P2
  1029. the
  1030. rule can be invoked by any of three names.
  1031. The first rule in a
  1032. .CW mkfile
  1033. is handled specially:
  1034. when
  1035. .CW mk
  1036. is invoked without a command line target
  1037. all targets of the first non-metarule are built.
  1038. When that rule has multiple targets, the recipe
  1039. is executed once for each target; normally, the recipe
  1040. of a rule with multiple targets is only executed once.
  1041. .PP
  1042. A rule applies to a target only when its prerequisites
  1043. exist or can be derived. More than one rule may have the
  1044. same target as long as only one rule with a recipe
  1045. remains applicable after the dependency evaluation completes.
  1046. For example, consider a program built from C
  1047. and assembler source files. Two rules produce
  1048. object files:
  1049. .P1
  1050. %.$O: %.c
  1051. $CC $CFLAGS $stem.c
  1052. %.$O: %.s
  1053. $AS $AFLAGS $stem.s
  1054. .P2
  1055. As long as there are not two source files with names like
  1056. .CW \fIfoo\fP.c
  1057. and
  1058. .CW \fIfoo\fP.s ,
  1059. .CW mk
  1060. can unambiguously select the proper rule.
  1061. If both files exist,
  1062. there are ambiguous rules to produce
  1063. .CW \fIfoo\fP.$O ,
  1064. and
  1065. .CW mk
  1066. exits with an error message.
  1067. .PP
  1068. In Plan 9, many programs consist of portable code stored
  1069. in one directory and architecture-specific source stored in
  1070. another.
  1071. For example, the
  1072. .CW mkfile
  1073. .P1
  1074. </$objtype/mkfile
  1075. CFLAGS=-w
  1076. FILES=f1.$O f2.$O f3.$O f3.$O
  1077. prog: $FILES
  1078. $LD -o $target $prereq
  1079. %.$O: %.$c
  1080. $CC $CFLAGS $stem.c
  1081. %.$O: ../port/%.c
  1082. $CC $CFLAGS ../port/$stem.c
  1083. .P2
  1084. builds the program named
  1085. .CW prog
  1086. using portable code in directory
  1087. .CW ../port
  1088. and architecture-specific code in the current directory.
  1089. As long as the
  1090. names of the C source files in
  1091. .CW ../port
  1092. do not conflict with the names of files in the current directory,
  1093. .CW mk
  1094. selects the appropriate rule.
  1095. If like-named files exist in both directories, the
  1096. specification is ambiguous and results in an error.
  1097. An explicit target resolves the ambiguity.
  1098. For example,
  1099. adding the rule
  1100. .P1
  1101. f2.$O: f2.c
  1102. $CC $CFLAGS $f2.c
  1103. .P2
  1104. to the previous
  1105. .CW mkfile
  1106. uses the architecture-specific version of
  1107. .CW f2.c
  1108. instead of the portable one.
  1109. Here, the explicit rule
  1110. documents which of the
  1111. like-named source files is used to build the program.
  1112. .PP
  1113. .CW Mk\fR'\fP s
  1114. heuristics can produce unintended results
  1115. when rules are not carefully specified.
  1116. For example, the rules that build
  1117. object files from C or assembler source files
  1118. .P1
  1119. %.$O: %.c
  1120. $CC $CFLAGS $stem.c
  1121. %.$O: %.s
  1122. $AS $AFLAGS $stem.s
  1123. .P2
  1124. illustrate a subtle pratfall.
  1125. Adding a header file dependency to the compile rule
  1126. .P1
  1127. %.$O: %.c hdr.h
  1128. $CC $CFLAGS $stem.c
  1129. .P2
  1130. produces the error message
  1131. .P1
  1132. .CW "don't know how to make '\fIfile\fP.c'"
  1133. .P2
  1134. when \fIfile\fP.s is an assembler
  1135. source file.
  1136. This occurs because
  1137. .CW \fIfile\fP.s
  1138. satisfies the assemble rule and
  1139. .CW hdr.h
  1140. satisfies the compile rule, so
  1141. either rule can potentially produce the target.
  1142. When a prerequisite exists or can be
  1143. derived,
  1144. all other prerequisites in that
  1145. rule header must exist or be derivable; here,
  1146. the existence of
  1147. .CW hdr.h
  1148. forces the evaluation of a C source file.
  1149. Specifying the dependencies in different
  1150. rules avoids this interpretation:
  1151. .P1
  1152. %.$O: hdr.h
  1153. %.$O: %.c
  1154. $CC $CFLAGS $stem.c
  1155. .P2
  1156. Although
  1157. .CW hdr.h
  1158. is an additional prerequisite of the compile rule,
  1159. the two rules are evaluated independently and
  1160. the existence of the C source file is not linked
  1161. to the existence of the header file.
  1162. However, this specification describes a different
  1163. dependency. Originally, only object
  1164. files derived from C files depended on
  1165. .CW hdr.h ;
  1166. now all object files, including those built
  1167. from assembler source, depend on the header file.
  1168. .PP
  1169. Metarule patterns should be as restrictive as possible to
  1170. prevent conflicts with other rules.
  1171. Consider the
  1172. .CW mkfile
  1173. .P1
  1174. </$objtype/mkfile
  1175. BIN=/$objtype/bin
  1176. PROG=foo
  1177. install:V: $BIN/$PROG
  1178. %: %.c
  1179. $CC $stem.c
  1180. $LD -o $target $stem.$O
  1181. $BIN/%: %
  1182. mv $stem $target
  1183. .P2
  1184. The first target builds an executable
  1185. in the local directory; the second
  1186. installs it in the directory
  1187. of executables for the architecture.
  1188. Invoking
  1189. .CW mk
  1190. with the
  1191. .CW install
  1192. target produces:
  1193. .P1 0
  1194. mk: ambiguous recipes for /mips/bin/foo:
  1195. /mips/bin/foo <-(mkfile:8)- /mips/bin/foo.c <-(mkfile:12)- foo.c
  1196. /mips/bin/foo <-(mkfile:12)- foo <-(mkfile:8)- foo.c
  1197. .P2
  1198. The prerequisite of the
  1199. .CW install
  1200. rule,
  1201. .CW $BIN/$PROG ,
  1202. matches both metarules because the
  1203. .CW %
  1204. pattern matches everything.
  1205. The
  1206. .CW &
  1207. pattern restricts the compile rule to files in the
  1208. current directory and avoids the conflict:
  1209. .P1
  1210. &: &.c
  1211. $CC $stem.c
  1212. $LD -o $target $stem.$O
  1213. .P2
  1214. .NH 1
  1215. Missing intermediates
  1216. .PP
  1217. .CW Mk
  1218. does not build a missing intermediate file if a target
  1219. is up to date with the prerequisites of the intermediate.
  1220. For example,
  1221. when an executable is up to date with its source file,
  1222. .CW mk
  1223. does not compile the source to create a missing object file.
  1224. The evaluation only applies
  1225. when a target is considered up to date by pretending that the
  1226. intermediate exists. Thus, it does not apply
  1227. when the intermediate is a command line target
  1228. or when it has no prerequisites.
  1229. .PP
  1230. This capability is useful for
  1231. maintaining archives. We can modify the archive
  1232. update recipe to remove object files after
  1233. they are archived:
  1234. .P1
  1235. $LIB(%):N: %
  1236. $LIB: ${OBJS:%=$LIB(%)}
  1237. names=`{membername $newprereq}
  1238. ar rv $LIB $names
  1239. rm -f $names
  1240. .P2
  1241. A subsequent
  1242. .CW mk
  1243. does not remake the object files as long as the members
  1244. of the archive remain up to date with the source files.
  1245. The
  1246. .CW -i
  1247. command line option overrides this behavior
  1248. and causes all intermediates to be built.
  1249. .NH 1
  1250. Alternative out-of-date determination
  1251. .PP
  1252. Sometimes the modification time is not useful
  1253. for deciding when a target and prerequisite are out of date.
  1254. The
  1255. .CW P
  1256. attribute replaces the default mechanism with the result of
  1257. a command. The command immediately follows the attribute
  1258. and is repeatedly executed with each
  1259. target and each prerequisite as its arguments;
  1260. if its exit status is non-zero, they are considered out of date
  1261. and the recipe is executed. Consider the
  1262. .CW mkfile
  1263. .P1
  1264. foo.ref:Pcmp -s: foo
  1265. cp $prereq $target
  1266. .P2
  1267. The command
  1268. .P1
  1269. cmp -s foo.ref foo
  1270. .P2
  1271. is executed and if
  1272. .CW foo.ref
  1273. differs from
  1274. .CW foo ,
  1275. the latter file is copied to the former.
  1276. .NH 1
  1277. Parallel processing
  1278. .PP
  1279. When possible,
  1280. .CW mk
  1281. executes recipes in parallel.
  1282. The variable
  1283. .CW $NPROC
  1284. specifies the maximum number of simultaneously executing
  1285. recipes.
  1286. Normally it is imported from the environment,
  1287. where the system has set it to the number of available processors.
  1288. It can be decreased by assigning a new
  1289. value and can be set to 1 to force single-threaded recipe execution.
  1290. This is necessary when several targets access
  1291. a common resource such as
  1292. a status file or data base.
  1293. When there is no dependency between targets,
  1294. .CW mk
  1295. assumes the
  1296. recipes can be
  1297. executed concurrently.
  1298. Normally, this allows
  1299. multiple prerequisites to be built simultaneously;
  1300. for example, the object file prerequisites of
  1301. a load rule can be produced by compiling the source files in parallel.
  1302. .CW Mk
  1303. does not define the order of execution of independent recipes.
  1304. When the prerequisites of a rule are not independent,
  1305. the dependencies between them should be specified in a rule or the
  1306. .CW mkfile
  1307. should be single-threaded.
  1308. For example, the archive update rules
  1309. .P1
  1310. $LIB(%):N: %
  1311. $LIB: ${OBJS:%=$LIB(%)}
  1312. ar rv $LIB `{membername $newprereq}
  1313. .P2
  1314. compile source files in parallel but update
  1315. all members of the archive at once.
  1316. It is a mistake to merge the two rules
  1317. .P1
  1318. $LIB(%): %
  1319. ar rv $LIB $stem
  1320. .P2
  1321. because an
  1322. .CW ar
  1323. command is executed for every
  1324. member of the library. Not only is this
  1325. inefficient, but the archive is updated
  1326. in parallel, making interference likely.
  1327. .PP
  1328. The
  1329. .CW $nproc
  1330. environment variable contains a number associated
  1331. with the processor executing a recipe.
  1332. It can be used to create unique
  1333. names when the
  1334. recipe may be executing simultaneously on several processors.
  1335. Other maintenance tools provide mechanisms to control recipe
  1336. scheduling explicitly [Cmel86], but
  1337. .CW mk\fR'\fPs
  1338. general rules are sufficient for all but the most unusual cases.
  1339. .NH 1
  1340. Deleting target files on errors
  1341. .PP
  1342. The
  1343. .CW D
  1344. attribute
  1345. causes
  1346. .CW mk
  1347. to remove the target file when a
  1348. recipe terminates prematurely.
  1349. The error message describing the
  1350. termination condition warns
  1351. of the deletion.
  1352. A partially built file is doubly dangerous:
  1353. it is not only wrong, but is also
  1354. considered to be up to date so
  1355. a subsequent
  1356. .CW mk
  1357. will not rebuild it. For example,
  1358. .P1
  1359. pic.out:D: mk.ms
  1360. pic $prereq | tbl | troff -ms > $target
  1361. .P2
  1362. produces the message
  1363. .P1
  1364. .CW "mk: pic mk.ms | ... : exit status=rc 685: deleting 'pic.out'"
  1365. .P2
  1366. if any program in the recipe exits with an error status.
  1367. .NH 1
  1368. Unspecified dependencies
  1369. .PP
  1370. The
  1371. .CW -w
  1372. command line flag forces the
  1373. files following the flag to be treated
  1374. as if they were just modified.
  1375. We can use this flag with a command that selects files
  1376. to force a build based on the selection criterion.
  1377. For example, if the declaration of
  1378. a global variable named
  1379. .I var
  1380. is changed in a header file,
  1381. all source files that reference
  1382. it can be rebuilt with the command
  1383. .P1
  1384. $ mk -w`{grep -l \fIvar\fP *.[cyl]}
  1385. .P2
  1386. .NH 1
  1387. Conclusion
  1388. .PP
  1389. There are many programs related to
  1390. .CW make ,
  1391. each choosing a different balance between
  1392. specialization and generality.
  1393. .CW Mk
  1394. emphasizes generality but allows
  1395. customization through its pattern specifications and
  1396. include facilities.
  1397. .PP
  1398. Plan 9 presents a difficult problem, particularly
  1399. because of its heterogeneous collection of
  1400. architectures and languages.
  1401. .CW Mk\fR'\fPs
  1402. flexible specification language and simple
  1403. interaction with
  1404. .CW rc
  1405. work well in this environment.
  1406. .PP
  1407. As a result,
  1408. Plan 9 relies on
  1409. .CW mk
  1410. to automate almost all maintenance.
  1411. Tasks as diverse as updating the
  1412. network data base, producing the manual,
  1413. or building a release are expressed as
  1414. .CW mk
  1415. procedures.
  1416. .NH 1
  1417. References
  1418. .LP
  1419. [Cmel86] R. F. Cmelik,
  1420. ``Concurrent Make: A Distributed Program in Concurrent C'',
  1421. AT&T Bell Laboratories Technical Report, 1986.
  1422. .LP
  1423. [Feld79] S. I. Feldman,
  1424. ``Make \(em a program for maintaining computer programs'',
  1425. .I
  1426. Software Practice & Experience ,
  1427. .R
  1428. 1979
  1429. Vol 9 #4,
  1430. pp. 255-266.
  1431. .LP
  1432. [Flan95] Bob Flandrena,
  1433. ``Plan 9 Mkfiles'',
  1434. this volume.
  1435. .LP
  1436. [Hume87] A. G. Hume,
  1437. ``Mk: A Successor to Make'',
  1438. .I
  1439. USENIX Summer Conf. Proc.,
  1440. .R
  1441. Phoenix, Az.
  1442. .NH 1
  1443. Appendix: Differences between
  1444. .CW make
  1445. and
  1446. .CW mk
  1447. .PP
  1448. The differences between
  1449. .CW mk
  1450. and
  1451. .CW make
  1452. are:
  1453. .IP \(bu 3n
  1454. .CW Make
  1455. builds targets when it needs them, allowing systematic use of side effects.
  1456. .CW Mk
  1457. constructs the entire dependency graph before building any target.
  1458. .IP \(bu
  1459. .CW Make
  1460. supports suffix rules and
  1461. .CW %
  1462. metarules.
  1463. .CW Mk
  1464. supports
  1465. .CW %
  1466. and regular expression metarules.
  1467. (Older versions of
  1468. .CW make
  1469. support only suffix rules.)
  1470. .IP \(bu
  1471. .CW Mk
  1472. performs transitive closure on metarules,
  1473. .CW make
  1474. does not.
  1475. .IP \(bu
  1476. .CW Make
  1477. supports cyclic dependencies,
  1478. .CW mk
  1479. does not.
  1480. .IP \(bu
  1481. .CW Make
  1482. evaluates recipes one line at a time, replacing variables by their values and
  1483. executing some commands internally.
  1484. .CW Mk
  1485. passes the entire recipe to the shell without
  1486. interpretation or internal execution.
  1487. .IP \(bu
  1488. .CW Make
  1489. supports parallel execution of single-line recipes when building
  1490. the prerequisites for specified targets.
  1491. .CW Mk
  1492. supports parallel execution of all recipes.
  1493. (Older versions of
  1494. .CW make
  1495. did not support parallel execution.)
  1496. .IP \(bu
  1497. .CW Make
  1498. uses special targets (beginning with a period)
  1499. to indicate special processing.
  1500. .CW Mk
  1501. uses attributes to modify rule evaluation.
  1502. .IP \(bu
  1503. .CW Mk
  1504. supports virtual
  1505. targets that are independent of the file system.
  1506. .IP \(bu
  1507. .CW Mk
  1508. allows non-standard out-of-date determination,
  1509. .CW make
  1510. does not.
  1511. .PP
  1512. It is usually easy to convert a
  1513. .CW makefile
  1514. to or from an equivalent
  1515. .CW mkfile .