mk.ms 34 KB

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