1
0

mk.ms 34 KB

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