source: trunk/kBuild/doc/QuickReference-kmk.html@ 2169

Last change on this file since 2169 was 2169, checked in by bird, 17 years ago

kmk-qr: started marking kmk specific features.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 58.3 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
7<title>kmk Quick Reference</title>
8<style type="text/css">
9
10/*
11:Author: David Goodger
12:Contact: goodger@users.sourceforge.net
13:Date: $Date: 2008-12-30 17:07:09 +0000 (Tue, 30 Dec 2008) $
14:Revision: $Revision: 2169 $
15:Copyright: This stylesheet has been placed in the public domain.
16
17Default cascading style sheet for the HTML output of Docutils.
18
19See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
20customize this style sheet.
21*/
22
23/* used to remove borders from tables and images */
24.borderless, table.borderless td, table.borderless th {
25 border: 0 }
26
27table.borderless td, table.borderless th {
28 /* Override padding for "table.docutils td" with "! important".
29 The right padding separates the table cells. */
30 padding: 0 0.5em 0 0 ! important }
31
32.first {
33 /* Override more specific margin styles with "! important". */
34 margin-top: 0 ! important }
35
36.last, .with-subtitle {
37 margin-bottom: 0 ! important }
38
39.hidden {
40 display: none }
41
42a.toc-backref {
43 text-decoration: none ;
44 color: black }
45
46blockquote.epigraph {
47 margin: 2em 5em ; }
48
49dl.docutils dd {
50 margin-bottom: 0.5em }
51
52/* Uncomment (and remove this text!) to get bold-faced definition list terms
53dl.docutils dt {
54 font-weight: bold }
55*/
56
57div.abstract {
58 margin: 2em 5em }
59
60div.abstract p.topic-title {
61 font-weight: bold ;
62 text-align: center }
63
64div.admonition, div.attention, div.caution, div.danger, div.error,
65div.hint, div.important, div.note, div.tip, div.warning {
66 margin: 2em ;
67 border: medium outset ;
68 padding: 1em }
69
70div.admonition p.admonition-title, div.hint p.admonition-title,
71div.important p.admonition-title, div.note p.admonition-title,
72div.tip p.admonition-title {
73 font-weight: bold ;
74 font-family: sans-serif }
75
76div.attention p.admonition-title, div.caution p.admonition-title,
77div.danger p.admonition-title, div.error p.admonition-title,
78div.warning p.admonition-title {
79 color: red ;
80 font-weight: bold ;
81 font-family: sans-serif }
82
83/* Uncomment (and remove this text!) to get reduced vertical space in
84 compound paragraphs.
85div.compound .compound-first, div.compound .compound-middle {
86 margin-bottom: 0.5em }
87
88div.compound .compound-last, div.compound .compound-middle {
89 margin-top: 0.5em }
90*/
91
92div.dedication {
93 margin: 2em 5em ;
94 text-align: center ;
95 font-style: italic }
96
97div.dedication p.topic-title {
98 font-weight: bold ;
99 font-style: normal }
100
101div.figure {
102 margin-left: 2em ;
103 margin-right: 2em }
104
105div.footer, div.header {
106 clear: both;
107 font-size: smaller }
108
109div.line-block {
110 display: block ;
111 margin-top: 1em ;
112 margin-bottom: 1em }
113
114div.line-block div.line-block {
115 margin-top: 0 ;
116 margin-bottom: 0 ;
117 margin-left: 1.5em }
118
119div.sidebar {
120 margin-left: 1em ;
121 border: medium outset ;
122 padding: 1em ;
123 background-color: #ffffee ;
124 width: 40% ;
125 float: right ;
126 clear: right }
127
128div.sidebar p.rubric {
129 font-family: sans-serif ;
130 font-size: medium }
131
132div.system-messages {
133 margin: 5em }
134
135div.system-messages h1 {
136 color: red }
137
138div.system-message {
139 border: medium outset ;
140 padding: 1em }
141
142div.system-message p.system-message-title {
143 color: red ;
144 font-weight: bold }
145
146div.topic {
147 margin: 2em }
148
149h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
150h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
151 margin-top: 0.4em }
152
153h1.title {
154 text-align: center }
155
156h2.subtitle {
157 text-align: center }
158
159hr.docutils {
160 width: 75% }
161
162img.align-left {
163 clear: left }
164
165img.align-right {
166 clear: right }
167
168ol.simple, ul.simple {
169 margin-bottom: 1em }
170
171ol.arabic {
172 list-style: decimal }
173
174ol.loweralpha {
175 list-style: lower-alpha }
176
177ol.upperalpha {
178 list-style: upper-alpha }
179
180ol.lowerroman {
181 list-style: lower-roman }
182
183ol.upperroman {
184 list-style: upper-roman }
185
186p.attribution {
187 text-align: right ;
188 margin-left: 50% }
189
190p.caption {
191 font-style: italic }
192
193p.credits {
194 font-style: italic ;
195 font-size: smaller }
196
197p.label {
198 white-space: nowrap }
199
200p.rubric {
201 font-weight: bold ;
202 font-size: larger ;
203 color: maroon ;
204 text-align: center }
205
206p.sidebar-title {
207 font-family: sans-serif ;
208 font-weight: bold ;
209 font-size: larger }
210
211p.sidebar-subtitle {
212 font-family: sans-serif ;
213 font-weight: bold }
214
215p.topic-title {
216 font-weight: bold }
217
218pre.address {
219 margin-bottom: 0 ;
220 margin-top: 0 ;
221 font-family: serif ;
222 font-size: 100% }
223
224pre.literal-block, pre.doctest-block {
225 margin-left: 2em ;
226 margin-right: 2em ;
227 background-color: #eeeeee }
228
229span.classifier {
230 font-family: sans-serif ;
231 font-style: oblique }
232
233span.classifier-delimiter {
234 font-family: sans-serif ;
235 font-weight: bold }
236
237span.interpreted {
238 font-family: sans-serif }
239
240span.option {
241 white-space: nowrap }
242
243span.pre {
244 white-space: pre }
245
246span.problematic {
247 color: red }
248
249span.section-subtitle {
250 /* font-size relative to parent (h1..h6 element) */
251 font-size: 80% }
252
253table.citation {
254 border-left: solid 1px gray;
255 margin-left: 1px }
256
257table.docinfo {
258 margin: 2em 4em }
259
260table.docutils {
261 margin-top: 0.5em ;
262 margin-bottom: 0.5em }
263
264table.footnote {
265 border-left: solid 1px black;
266 margin-left: 1px }
267
268table.docutils td, table.docutils th,
269table.docinfo td, table.docinfo th {
270 padding-left: 0.5em ;
271 padding-right: 0.5em ;
272 vertical-align: top }
273
274table.docutils th.field-name, table.docinfo th.docinfo-name {
275 font-weight: bold ;
276 text-align: left ;
277 white-space: nowrap ;
278 padding-left: 0 }
279
280h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
281h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
282 font-size: 100% }
283
284tt.docutils {
285 background-color: #eeeeee }
286
287ul.auto-toc {
288 list-style-type: none }
289
290</style>
291</head>
292<body>
293<div class="document" id="kmk-quick-reference">
294<h1 class="title">kmk Quick Reference</h1>
295<p>This is an attempt at summarizing all directives, functions, special variables,
296special targets, built-in commands, external commands, and <tt class="docutils literal"><span class="pre">kmk</span></tt>-expressions.
297Since <em>all</em> the features are included, the quickness of this reference can be
298disputed. ;-)</p>
299<p>Features that are</p>
300<div class="section">
301<h1><a id="directives" name="directives">Directives</a></h1>
302<p>Here is a summary of the directives <tt class="docutils literal"><span class="pre">kmk</span></tt> recognizes:</p>
303<blockquote>
304<p>Define a multi-line, recursively-expanded variable:</p>
305<pre class="literal-block">
306define variable
307endef
308</pre>
309<p>Conditionally evaluate part of the makefile:</p>
310<pre class="literal-block">
311ifdef variable
312ifndef variable
313ifeq (a,b)
314ifeq &quot;a&quot; &quot;b&quot;
315ifeq 'a' 'b'
316ifneq (a,b)
317ifneq &quot;a&quot; &quot;b&quot;
318ifneq 'a' 'b'
319if1of (set-a,set-b) [1]
320ifn1of (set-a,set-b) [1]
321if expression [1]
322else
323endif
324</pre>
325<p>Include another makefile:</p>
326<pre class="literal-block">
327include file
328-include file
329sinclude file
330</pre>
331<p>Include another dependency file <a class="footnote-reference" href="#id15" id="id1" name="id1">[1]</a>:</p>
332<pre class="literal-block">
333includedep file
334</pre>
335<p>Define a variable, overriding any previous definition, even one from the
336command line:</p>
337<pre class="literal-block">
338override variable = value
339override variable := value
340override variable += value
341override variable &lt;= value [1]
342override variable ?= value
343override define variable
344endef
345</pre>
346<p>Tell <tt class="docutils literal"><span class="pre">kmk</span></tt> to export all variables to child processes by default:</p>
347<pre class="literal-block">
348export
349</pre>
350<p>Tell <tt class="docutils literal"><span class="pre">kmk</span></tt> whether or not to export a particular variable to child
351processes:</p>
352<pre class="literal-block">
353export variable
354export variable = value
355export variable := value
356export variable += value
357export variable &lt;= value [1]
358export variable ?= value
359unexport variable
360</pre>
361<p>Define a variable in the local context instead of the global one <a class="footnote-reference" href="#id15" id="id2" name="id2">[1]</a>:</p>
362<pre class="literal-block">
363local variable = value
364local variable := value
365local variable += value
366local variable &lt;= value
367local variable ?= value
368local define variable
369endef
370</pre>
371<p>Specify a search path for files matching a <tt class="docutils literal"><span class="pre">%</span></tt> pattern:</p>
372<pre class="literal-block">
373vpath pattern path
374</pre>
375<p>Remove all search paths previously specified for pattern:</p>
376<pre class="literal-block">
377vpath pattern
378</pre>
379<p>Remove all search paths previously specified in any vpath directive:</p>
380<pre class="literal-block">
381vpath
382</pre>
383</blockquote>
384</div>
385<div class="section">
386<h1><a id="automatic-variables" name="automatic-variables">Automatic variables</a></h1>
387<p>Here is a summary of the automatic variables.</p>
388<table border="1" class="docutils">
389<colgroup>
390<col width="14%" />
391<col width="86%" />
392</colgroup>
393<thead valign="bottom">
394<tr><th class="head">Variable</th>
395<th class="head">Description</th>
396</tr>
397</thead>
398<tbody valign="top">
399<tr><td><tt class="docutils literal"><span class="pre">$&#64;</span></tt></td>
400<td>The file name of the target.</td>
401</tr>
402<tr><td><tt class="docutils literal"><span class="pre">$&lt;</span></tt></td>
403<td>The name of the first prerequisite.</td>
404</tr>
405<tr><td><tt class="docutils literal"><span class="pre">$?</span></tt></td>
406<td>The names of all the prerequisites that are newer than the
407target, with spaces between them.</td>
408</tr>
409<tr><td><tt class="docutils literal"><span class="pre">$^</span></tt></td>
410<td>The names of all the prerequisites, duplicates omitted.</td>
411</tr>
412<tr><td><tt class="docutils literal"><span class="pre">$+</span></tt></td>
413<td>The names of all the prerequisites, duplicates and order
414preserved</td>
415</tr>
416<tr><td><tt class="docutils literal"><span class="pre">$*</span></tt></td>
417<td>The stem with which an implicit rule matches.</td>
418</tr>
419<tr><td><tt class="docutils literal"><span class="pre">$|</span></tt></td>
420<td>The name of all the order only prerequisites.</td>
421</tr>
422<tr><td><tt class="docutils literal"><span class="pre">$(&#64;D)</span></tt></td>
423<td>The directory part of <tt class="docutils literal"><span class="pre">$&#64;</span></tt>.</td>
424</tr>
425<tr><td><tt class="docutils literal"><span class="pre">$(&lt;D)</span></tt></td>
426<td>The directory part of <tt class="docutils literal"><span class="pre">$&lt;</span></tt>.</td>
427</tr>
428<tr><td><tt class="docutils literal"><span class="pre">$(?D)</span></tt></td>
429<td>The directory part of <tt class="docutils literal"><span class="pre">$?</span></tt>.</td>
430</tr>
431<tr><td><tt class="docutils literal"><span class="pre">$(^D)</span></tt></td>
432<td>The directory part of <tt class="docutils literal"><span class="pre">%^</span></tt>.</td>
433</tr>
434<tr><td><tt class="docutils literal"><span class="pre">$(+D)</span></tt></td>
435<td>The directory part of <tt class="docutils literal"><span class="pre">$+</span></tt>.</td>
436</tr>
437<tr><td><tt class="docutils literal"><span class="pre">$(*D)</span></tt></td>
438<td>The directory part of <tt class="docutils literal"><span class="pre">$*</span></tt>.</td>
439</tr>
440<tr><td><tt class="docutils literal"><span class="pre">$(|D)</span></tt></td>
441<td>The directory part of <tt class="docutils literal"><span class="pre">$|</span></tt>.</td>
442</tr>
443<tr><td><tt class="docutils literal"><span class="pre">$(&#64;F)</span></tt></td>
444<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$&#64;</span></tt>.</td>
445</tr>
446<tr><td><tt class="docutils literal"><span class="pre">$(&lt;F)</span></tt></td>
447<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$&lt;</span></tt>.</td>
448</tr>
449<tr><td><tt class="docutils literal"><span class="pre">$(?F)</span></tt></td>
450<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$?</span></tt>.</td>
451</tr>
452<tr><td><tt class="docutils literal"><span class="pre">$(^F)</span></tt></td>
453<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$^</span></tt>.</td>
454</tr>
455<tr><td><tt class="docutils literal"><span class="pre">$(+F)</span></tt></td>
456<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$+</span></tt>.</td>
457</tr>
458<tr><td><tt class="docutils literal"><span class="pre">$(*F)</span></tt></td>
459<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$*</span></tt>.</td>
460</tr>
461<tr><td><tt class="docutils literal"><span class="pre">$(|F)</span></tt></td>
462<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$|</span></tt>.</td>
463</tr>
464</tbody>
465</table>
466</div>
467<div class="section">
468<h1><a id="special-variables" name="special-variables">Special variables</a></h1>
469<p>All variables starting with a <tt class="docutils literal"><span class="pre">.</span></tt> is reserved by <tt class="docutils literal"><span class="pre">kmk</span></tt>. The following
470variables are specially used or/and defined by <tt class="docutils literal"><span class="pre">kmk</span></tt>:</p>
471<table border="1" class="docutils">
472<colgroup>
473<col width="34%" />
474<col width="66%" />
475</colgroup>
476<thead valign="bottom">
477<tr><th class="head">Variable</th>
478<th class="head">Description</th>
479</tr>
480</thead>
481<tbody valign="top">
482<tr><td><tt class="docutils literal"><span class="pre">.DEFAULT_GOAL</span></tt></td>
483<td>The makefile default goal. You can set this in
484the makefile, if you don't it will default to
485the first target that is encountered.</td>
486</tr>
487<tr><td><tt class="docutils literal"><span class="pre">.FEATURES</span></tt></td>
488<td>List of GNU <tt class="docutils literal"><span class="pre">make</span></tt> features. Do not set this.</td>
489</tr>
490<tr><td><tt class="docutils literal"><span class="pre">.INCLUDE_DIRS</span></tt></td>
491<td>List of include directories, <tt class="docutils literal"><span class="pre">-I</span></tt> arguments
492and defaults. Do not set this.</td>
493</tr>
494<tr><td><tt class="docutils literal"><span class="pre">.RECIPEPREFIX</span></tt></td>
495<td>Recipe prefix, defaults to tab.</td>
496</tr>
497<tr><td><tt class="docutils literal"><span class="pre">.VARIABLES</span></tt></td>
498<td>Special variable which exands to the list of
499variable. Do not set this.</td>
500</tr>
501<tr><td><tt class="docutils literal"><span class="pre">CURDIR</span></tt></td>
502<td>Set to the pathname of the current working
503directory (after all <tt class="docutils literal"><span class="pre">-C</span></tt> options are
504processed, if any). Do not set this.</td>
505</tr>
506<tr><td><tt class="docutils literal"><span class="pre">KBUILD_VERSION</span></tt>,
507<tt class="docutils literal"><span class="pre">KBUILD_VERSION_MAJOR</span></tt>,
508<tt class="docutils literal"><span class="pre">KBUILD_VERSION_MINOR</span></tt>,
509<tt class="docutils literal"><span class="pre">KBUILD_VERSION_PATCH</span></tt>,
510<tt class="docutils literal"><span class="pre">KBUILD_KMK_REVISION</span></tt></td>
511<td>The kBuild version string and the break down
512into individual components. <a class="footnote-reference" href="#id15" id="id3" name="id3">[1]</a></td>
513</tr>
514<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST</span></tt> <a class="footnote-reference" href="#id15" id="id4" name="id4">[1]</a></td>
515<td>The host operating system.</td>
516</tr>
517<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_ARCH</span></tt> <a class="footnote-reference" href="#id15" id="id5" name="id5">[1]</a></td>
518<td>The host architecture.</td>
519</tr>
520<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_CPU</span></tt> <a class="footnote-reference" href="#id15" id="id6" name="id6">[1]</a></td>
521<td>The host CPU <tt class="docutils literal"><span class="pre">kmk</span></tt> is built for, set to
522<tt class="docutils literal"><span class="pre">blend</span></tt> if not any particular CPU.</td>
523</tr>
524<tr><td><tt class="docutils literal"><span class="pre">KBUILD_PATH</span></tt> <a class="footnote-reference" href="#id15" id="id7" name="id7">[1]</a></td>
525<td>Where the kBuild scripts are.</td>
526</tr>
527<tr><td><tt class="docutils literal"><span class="pre">KBUILD_BIN_PATH</span></tt> <a class="footnote-reference" href="#id15" id="id8" name="id8">[1]</a></td>
528<td>Where the host specific kBuild binaries are.</td>
529</tr>
530<tr><td><tt class="docutils literal"><span class="pre">KMK</span></tt> <a class="footnote-reference" href="#id15" id="id9" name="id9">[1]</a>,
531<tt class="docutils literal"><span class="pre">MAKE</span></tt></td>
532<td>The name with which <tt class="docutils literal"><span class="pre">kmk</span></tt> was invoked. Using
533this variable in recipes has special meaning.</td>
534</tr>
535<tr><td><tt class="docutils literal"><span class="pre">KMK_BUILTIN</span></tt> <a class="footnote-reference" href="#id15" id="id10" name="id10">[1]</a></td>
536<td>List of built-in commands.</td>
537</tr>
538<tr><td><tt class="docutils literal"><span class="pre">KMK_FEATURES</span></tt> <a class="footnote-reference" href="#id15" id="id11" name="id11">[1]</a></td>
539<td>List of <tt class="docutils literal"><span class="pre">kmk</span></tt> specific features.</td>
540</tr>
541<tr><td><tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt> <a class="footnote-reference" href="#id15" id="id12" name="id12">[1]</a></td>
542<td><p class="first">The flags given to <tt class="docutils literal"><span class="pre">kmk</span></tt>. You can set this in
543the environment or a makefile to set flags.</p>
544<p class="last">It is never appropriate to use <tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt>
545directly in a recipe line: its contents may not
546be quoted correctly for use in the shell. Always
547allow recursive <tt class="docutils literal"><span class="pre">kmk</span></tt>'s to obtain these values
548through the environment from its parent.</p>
549</td>
550</tr>
551<tr><td><tt class="docutils literal"><span class="pre">KMK_LEVEL</span></tt> <a class="footnote-reference" href="#id15" id="id13" name="id13">[1]</a></td>
552<td>The number of levels of recursion (sub-makes).</td>
553</tr>
554<tr><td><tt class="docutils literal"><span class="pre">KMK_VERSION</span></tt> <a class="footnote-reference" href="#id15" id="id14" name="id14">[1]</a></td>
555<td>The GNU <tt class="docutils literal"><span class="pre">make</span></tt> version number.</td>
556</tr>
557<tr><td><tt class="docutils literal"><span class="pre">MAKECMDGOALS</span></tt></td>
558<td>The targets given to <tt class="docutils literal"><span class="pre">kmk</span></tt> on the command line.
559Do not set this.</td>
560</tr>
561<tr><td><tt class="docutils literal"><span class="pre">MAKEFILES</span></tt></td>
562<td>Makefiles to be read on every invocation of
563<tt class="docutils literal"><span class="pre">kmk</span></tt>.</td>
564</tr>
565<tr><td><tt class="docutils literal"><span class="pre">MAKEFILE_LIST</span></tt></td>
566<td>List of the makefiles that <tt class="docutils literal"><span class="pre">kmk</span></tt> has opened.</td>
567</tr>
568<tr><td><tt class="docutils literal"><span class="pre">MAKESHELL</span></tt></td>
569<td>OS/2 and MS-DOS only, the name of the command
570interpreter that is to be used by <tt class="docutils literal"><span class="pre">kmk</span></tt>. This
571value takes precedence over the value of SHELL.</td>
572</tr>
573<tr><td><tt class="docutils literal"><span class="pre">SHELL</span></tt></td>
574<td>The name of the default command interpreter,
575kmk_ash. You can set SHELL in the makefile to
576change the shell used to run recipes. The SHELL
577variable is handled specially when importing
578from and exporting to the environment.</td>
579</tr>
580<tr><td><tt class="docutils literal"><span class="pre">SUFFIXES</span></tt></td>
581<td>The default list of suffixes before <tt class="docutils literal"><span class="pre">kmk</span></tt>
582reads any makefiles (always empty).</td>
583</tr>
584<tr><td><tt class="docutils literal"><span class="pre">VPATH</span></tt></td>
585<td>Directory search path for files not found in the
586current directory.</td>
587</tr>
588</tbody>
589</table>
590<p>The following variables reflects <tt class="docutils literal"><span class="pre">kmk</span></tt> options. Do not set these.</p>
591<table border="1" class="docutils">
592<colgroup>
593<col width="49%" />
594<col width="51%" />
595</colgroup>
596<thead valign="bottom">
597<tr><th class="head">Variable</th>
598<th class="head">Description</th>
599</tr>
600</thead>
601<tbody valign="top">
602<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_JOBS</span></tt></td>
603<td>-j slots, <tt class="docutils literal"><span class="pre">0</span></tt> if not given.</td>
604</tr>
605<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_KEEP_GOING</span></tt></td>
606<td>-k indictor (<tt class="docutils literal"><span class="pre">0</span></tt>/<tt class="docutils literal"><span class="pre">1</span></tt>).</td>
607</tr>
608<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_JUST_PRINT</span></tt></td>
609<td>-n indicator (<tt class="docutils literal"><span class="pre">0</span></tt>/<tt class="docutils literal"><span class="pre">1</span></tt>).</td>
610</tr>
611<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_PRORITY</span></tt></td>
612<td>--priority level, <tt class="docutils literal"><span class="pre">0</span></tt> if not given.</td>
613</tr>
614<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_AFFINITY</span></tt></td>
615<td>--affinity mask, <tt class="docutils literal"><span class="pre">0</span></tt> if not given.</td>
616</tr>
617<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_STATISTICS</span></tt></td>
618<td>--statistics indicator (<tt class="docutils literal"><span class="pre">0</span></tt>/<tt class="docutils literal"><span class="pre">1</span></tt>).</td>
619</tr>
620<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_PRINT_TIME</span></tt></td>
621<td>The --print-time value.</td>
622</tr>
623<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_PRETTY_COMMAND_PRINTING</span></tt></td>
624<td>--pretty-command-printing indicator.</td>
625</tr>
626</tbody>
627</table>
628</div>
629<div class="section">
630<h1><a id="special-targets" name="special-targets">Special Targets</a></h1>
631<p>todo</p>
632</div>
633<div class="section">
634<h1><a id="commands" name="commands">Commands</a></h1>
635<p>Builtin commands all start with <tt class="docutils literal"><span class="pre">kmk_builtin_</span></tt>, so in order to save space
636this prefix has been omitted in the table below. All commands comes in an
637external edition that can be used by/in the shell, these are prefixed <tt class="docutils literal"><span class="pre">kmk_</span></tt>.</p>
638<table border="1" class="docutils">
639<colgroup>
640<col width="20%" />
641<col width="80%" />
642</colgroup>
643<thead valign="bottom">
644<tr><th class="head">Command</th>
645<th class="head">Description</th>
646</tr>
647</thead>
648<tbody valign="top">
649<tr><td><tt class="docutils literal"><span class="pre">append</span></tt></td>
650<td>Append text to a file. The builtin version can output the
651value of a variable or the commands of a target.</td>
652</tr>
653<tr><td><tt class="docutils literal"><span class="pre">cat</span></tt></td>
654<td>The BSD <tt class="docutils literal"><span class="pre">cat</span></tt> command.</td>
655</tr>
656<tr><td><tt class="docutils literal"><span class="pre">chmod</span></tt></td>
657<td>The BSD <tt class="docutils literal"><span class="pre">chmod</span></tt> command.</td>
658</tr>
659<tr><td><tt class="docutils literal"><span class="pre">cmp</span></tt></td>
660<td>The BSD <tt class="docutils literal"><span class="pre">cmp</span></tt> command.</td>
661</tr>
662<tr><td><tt class="docutils literal"><span class="pre">cp</span></tt></td>
663<td>The BSD <tt class="docutils literal"><span class="pre">cp</span></tt> command with some twaking.</td>
664</tr>
665<tr><td><tt class="docutils literal"><span class="pre">echo</span></tt></td>
666<td>The BSD <tt class="docutils literal"><span class="pre">echo</span></tt> command.</td>
667</tr>
668<tr><td><tt class="docutils literal"><span class="pre">expr</span></tt></td>
669<td>The BSD <tt class="docutils literal"><span class="pre">expr</span></tt> command.</td>
670</tr>
671<tr><td><tt class="docutils literal"><span class="pre">install</span></tt></td>
672<td>The BSD <tt class="docutils literal"><span class="pre">install</span></tt> command with some tweaking.</td>
673</tr>
674<tr><td><tt class="docutils literal"><span class="pre">kDepIDB</span></tt></td>
675<td>Extract dependencies from a Visual C++ .IDB file.</td>
676</tr>
677<tr><td><tt class="docutils literal"><span class="pre">ln</span></tt></td>
678<td>The BSD <tt class="docutils literal"><span class="pre">ln</span></tt> command.</td>
679</tr>
680<tr><td><tt class="docutils literal"><span class="pre">md5sum</span></tt></td>
681<td>Typical MD5 sum program, custom kBuild version.</td>
682</tr>
683<tr><td><tt class="docutils literal"><span class="pre">mkdir</span></tt></td>
684<td>The BSD <tt class="docutils literal"><span class="pre">mkdir</span></tt> command.</td>
685</tr>
686<tr><td><tt class="docutils literal"><span class="pre">mv</span></tt></td>
687<td>The BSD <tt class="docutils literal"><span class="pre">mv</span></tt> command with some tweaking.</td>
688</tr>
689<tr><td><tt class="docutils literal"><span class="pre">printf</span></tt></td>
690<td>The BSD <tt class="docutils literal"><span class="pre">printf</span></tt> command.</td>
691</tr>
692<tr><td><tt class="docutils literal"><span class="pre">rm</span></tt></td>
693<td>The BSD <tt class="docutils literal"><span class="pre">rm</span></tt> command with some tweaking.</td>
694</tr>
695<tr><td><tt class="docutils literal"><span class="pre">rmdir</span></tt></td>
696<td>The BSD <tt class="docutils literal"><span class="pre">rmdir</span></tt> command with some tweaking.</td>
697</tr>
698<tr><td><tt class="docutils literal"><span class="pre">sleep</span></tt></td>
699<td>Typical <tt class="docutils literal"><span class="pre">sleep</span></tt> program, custom kBuild version.</td>
700</tr>
701<tr><td><tt class="docutils literal"><span class="pre">test</span></tt></td>
702<td>The BSD <tt class="docutils literal"><span class="pre">test</span></tt> program with some tweaking.</td>
703</tr>
704</tbody>
705</table>
706<p>Some additional external commands are available in the <tt class="docutils literal"><span class="pre">kmk</span></tt> / <tt class="docutils literal"><span class="pre">kBuild</span></tt>
707environment (<tt class="docutils literal"><span class="pre">kSomething</span></tt> command are not prefixed with <tt class="docutils literal"><span class="pre">kmk_</span></tt>):</p>
708<table border="1" class="docutils">
709<colgroup>
710<col width="20%" />
711<col width="80%" />
712</colgroup>
713<thead valign="bottom">
714<tr><th class="head">Command</th>
715<th class="head">Description</th>
716</tr>
717</thead>
718<tbody valign="top">
719<tr><td><tt class="docutils literal"><span class="pre">kDepPre</span></tt></td>
720<td>Extract dependencies from the C/C++ preprocessor output.</td>
721</tr>
722<tr><td><tt class="docutils literal"><span class="pre">kObjCache</span></tt></td>
723<td>Simple object file cache program.</td>
724</tr>
725<tr><td><tt class="docutils literal"><span class="pre">ash</span></tt></td>
726<td>Almquist's shell (NetBSD variant).</td>
727</tr>
728<tr><td><tt class="docutils literal"><span class="pre">gmake</span></tt></td>
729<td>Vanilla GNU <tt class="docutils literal"><span class="pre">make</span></tt> from same sources as <tt class="docutils literal"><span class="pre">kmk</span></tt>.</td>
730</tr>
731<tr><td><tt class="docutils literal"><span class="pre">redirect</span></tt></td>
732<td>Shell avoidance tool. Sets up file descriptors, environment
733variables and current directory before kicking of program.</td>
734</tr>
735<tr><td><tt class="docutils literal"><span class="pre">sed</span></tt></td>
736<td>GNU <tt class="docutils literal"><span class="pre">sed</span></tt> with some tweaks to avoid involving the shell.</td>
737</tr>
738<tr><td><tt class="docutils literal"><span class="pre">time</span></tt></td>
739<td>Stopwatch utility for measuring program execution time(s).</td>
740</tr>
741</tbody>
742</table>
743</div>
744<div class="section">
745<h1><a id="kmk-expression" name="kmk-expression">kmk-expression</a></h1>
746<p><tt class="docutils literal"><span class="pre">kmk</span></tt>-expressions are related to the C/C++ preprocessor in some ways as well
747as <tt class="docutils literal"><span class="pre">nmake</span></tt> and BSD <tt class="docutils literal"><span class="pre">make</span></tt>. There are however some peculiarities because of
748the way GNU <tt class="docutils literal"><span class="pre">make</span></tt> choose to represent booleans in its function library, so,
749strings can be turned into boolean by taking any non-empty string as true.</p>
750<p>Quoting using single quotes results in hard strings, while double quotes and
751unquoted string results in soft strings that can be converted to number or
752boolean to fit the situation.</p>
753<p>Here's the operator table in decending precedence order:</p>
754<table border="1" class="docutils">
755<colgroup>
756<col width="20%" />
757<col width="11%" />
758<col width="70%" />
759</colgroup>
760<thead valign="bottom">
761<tr><th class="head">Operator</th>
762<th class="head">Type</th>
763<th class="head">Description</th>
764</tr>
765</thead>
766<tbody valign="top">
767<tr><td><tt class="docutils literal"><span class="pre">defined</span></tt></td>
768<td rowspan="6">Unary</td>
769<td>Checks if the following variable exists.</td>
770</tr>
771<tr><td><tt class="docutils literal"><span class="pre">exists</span></tt></td>
772<td>Checks if the following file exists.</td>
773</tr>
774<tr><td><tt class="docutils literal"><span class="pre">target</span></tt></td>
775<td>Checks if the following target exists.</td>
776</tr>
777<tr><td><tt class="docutils literal"><span class="pre">bool</span></tt></td>
778<td>Casts the following value to boolean.</td>
779</tr>
780<tr><td><tt class="docutils literal"><span class="pre">num</span></tt></td>
781<td>Casts the following value to a number.</td>
782</tr>
783<tr><td><tt class="docutils literal"><span class="pre">str</span></tt></td>
784<td>Casts the following value to a string.</td>
785</tr>
786<tr><td><tt class="docutils literal"><span class="pre">!</span></tt></td>
787<td rowspan="4">Unary</td>
788<td>Logical NOT.</td>
789</tr>
790<tr><td><tt class="docutils literal"><span class="pre">+</span></tt></td>
791<td>Pluss prefix.</td>
792</tr>
793<tr><td><tt class="docutils literal"><span class="pre">-</span></tt></td>
794<td>Minus prefix.</td>
795</tr>
796<tr><td><tt class="docutils literal"><span class="pre">~</span></tt></td>
797<td>Bitwise one's complement.</td>
798</tr>
799<tr><td><tt class="docutils literal"><span class="pre">*</span></tt></td>
800<td rowspan="3">Binary</td>
801<td>Multiplication (product).</td>
802</tr>
803<tr><td><tt class="docutils literal"><span class="pre">/</span></tt></td>
804<td>Division (quotient).</td>
805</tr>
806<tr><td><tt class="docutils literal"><span class="pre">%</span></tt></td>
807<td>Modulus (remainder).</td>
808</tr>
809<tr><td><tt class="docutils literal"><span class="pre">+</span></tt></td>
810<td rowspan="2">Binary</td>
811<td>Addition (sum).</td>
812</tr>
813<tr><td><tt class="docutils literal"><span class="pre">-</span></tt></td>
814<td>Subtraction (difference).</td>
815</tr>
816<tr><td><tt class="docutils literal"><span class="pre">&lt;&lt;</span></tt></td>
817<td rowspan="2">Binary</td>
818<td>Bitwise left shift.</td>
819</tr>
820<tr><td><tt class="docutils literal"><span class="pre">&gt;&gt;</span></tt></td>
821<td>Bitwise right shift.</td>
822</tr>
823<tr><td><tt class="docutils literal"><span class="pre">&lt;=</span></tt></td>
824<td rowspan="4">Binary</td>
825<td>Less or equal than.</td>
826</tr>
827<tr><td><tt class="docutils literal"><span class="pre">&lt;</span></tt></td>
828<td>Less than.</td>
829</tr>
830<tr><td><tt class="docutils literal"><span class="pre">&gt;=</span></tt></td>
831<td>Greater or equal than.</td>
832</tr>
833<tr><td><tt class="docutils literal"><span class="pre">&gt;</span></tt></td>
834<td>Greater than.</td>
835</tr>
836<tr><td><tt class="docutils literal"><span class="pre">==</span></tt></td>
837<td rowspan="2">Binary</td>
838<td>Equal to.</td>
839</tr>
840<tr><td><tt class="docutils literal"><span class="pre">!=</span></tt></td>
841<td>Not equal to.</td>
842</tr>
843<tr><td><tt class="docutils literal"><span class="pre">&amp;</span></tt></td>
844<td>Binary</td>
845<td>Bitwise AND.</td>
846</tr>
847<tr><td><tt class="docutils literal"><span class="pre">^</span></tt></td>
848<td>Binary</td>
849<td>Bitwise XOR.</td>
850</tr>
851<tr><td><tt class="docutils literal"><span class="pre">|</span></tt></td>
852<td>Binary</td>
853<td>Bitwise OR.</td>
854</tr>
855<tr><td><tt class="docutils literal"><span class="pre">&amp;&amp;</span></tt></td>
856<td>Binary</td>
857<td>Logical AND.</td>
858</tr>
859<tr><td><tt class="docutils literal"><span class="pre">||</span></tt></td>
860<td>Binary</td>
861<td>Logical OR.</td>
862</tr>
863</tbody>
864</table>
865</div>
866<div class="section">
867<h1><a id="built-in-functions" name="built-in-functions">Built-in functions</a></h1>
868<p>String Manipulation Functions:</p>
869<blockquote>
870<p>Replace <tt class="docutils literal"><span class="pre">from</span></tt> with <tt class="docutils literal"><span class="pre">to</span></tt> in <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
871<pre class="literal-block">
872$(subst from,to,text)
873</pre>
874<p>Replace words matching <tt class="docutils literal"><span class="pre">pattern</span></tt> with <tt class="docutils literal"><span class="pre">replacement</span></tt> in <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
875<pre class="literal-block">
876$(patsubst pattern,replacement,text)
877</pre>
878<p>Remove excess whitespace characters from <tt class="docutils literal"><span class="pre">string</span></tt>:</p>
879<pre class="literal-block">
880$(strip string)
881</pre>
882<p>Locate <tt class="docutils literal"><span class="pre">find</span></tt> in <tt class="docutils literal"><span class="pre">text</span></tt>, returning <tt class="docutils literal"><span class="pre">find</span></tt> if found:</p>
883<pre class="literal-block">
884$(findstring find,text)
885</pre>
886<p>Select words in <tt class="docutils literal"><span class="pre">text</span></tt> that match one of the <tt class="docutils literal"><span class="pre">pattern</span></tt> words:</p>
887<pre class="literal-block">
888$(filter pattern...,text)
889</pre>
890<p>Select words in <tt class="docutils literal"><span class="pre">text</span></tt> that do not match any of the <tt class="docutils literal"><span class="pre">pattern</span></tt> words:</p>
891<pre class="literal-block">
892$(filter-out pattern...,text)
893</pre>
894<p>Sort the words in <tt class="docutils literal"><span class="pre">list</span></tt> lexicographically, removing duplicates:</p>
895<pre class="literal-block">
896$(sort list)
897</pre>
898<p>Sort the words in <tt class="docutils literal"><span class="pre">list</span></tt> lexicographically in reserve order, removing
899duplicates:</p>
900<pre class="literal-block">
901$(rsort list)
902</pre>
903<p>Count the number of words in <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
904<pre class="literal-block">
905$(words text)
906</pre>
907<p>Extract the <tt class="docutils literal"><span class="pre">n</span></tt>th word (one-origin) of <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
908<pre class="literal-block">
909$(word n,text)
910</pre>
911<p>Returns the list of words in <tt class="docutils literal"><span class="pre">text</span></tt> from <tt class="docutils literal"><span class="pre">s</span></tt> to <tt class="docutils literal"><span class="pre">e</span></tt> (one-origin):</p>
912<pre class="literal-block">
913$(wordlist s,e,text)
914</pre>
915<p>Extract the first word of <tt class="docutils literal"><span class="pre">names</span></tt>:</p>
916<pre class="literal-block">
917$(firstword names...)
918</pre>
919<p>Extract the last word of <tt class="docutils literal"><span class="pre">names</span></tt>:</p>
920<pre class="literal-block">
921$(lastword names...)
922</pre>
923<p>Join two parallel lists of words:</p>
924<pre class="literal-block">
925$(join list1,list2)
926</pre>
927<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to upper case:</p>
928<pre class="literal-block">
929$(toupper text)
930</pre>
931<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to lower case:</p>
932<pre class="literal-block">
933$(tolower text)
934</pre>
935<p>String formatting a la the unix <tt class="docutils literal"><span class="pre">printf</span></tt> command:</p>
936<pre class="literal-block">
937$(printf fmt, arg...)
938</pre>
939<p>Return the length of a string or a (unexpanded) variable:</p>
940<pre class="literal-block">
941$(length string)
942$(length-var var)
943</pre>
944<p>Find the position of <tt class="docutils literal"><span class="pre">needle</span></tt> in <tt class="docutils literal"><span class="pre">haystack</span></tt>, returns 0 if not found.
945Negative <tt class="docutils literal"><span class="pre">start</span></tt> indices are relative to the end of <tt class="docutils literal"><span class="pre">haystack</span></tt>, while
946positive ones are one based:</p>
947<pre class="literal-block">
948$(pos needle, haystack[, start])
949$(lastpos needle, haystack[, start])
950</pre>
951<p>Returns the specified substring. The <tt class="docutils literal"><span class="pre">start</span></tt> works like with <tt class="docutils literal"><span class="pre">$(pos</span> <span class="pre">)</span></tt>.
952If the substring is partially outside the <tt class="docutils literal"><span class="pre">string</span></tt> the result will be
953padded with <tt class="docutils literal"><span class="pre">pad</span></tt> if present:</p>
954<pre class="literal-block">
955$(substr string, start[, length[, pad]])
956</pre>
957<p>Insert <tt class="docutils literal"><span class="pre">in</span></tt> into <tt class="docutils literal"><span class="pre">str</span></tt> at the specified position. <tt class="docutils literal"><span class="pre">n</span></tt> works like with
958<tt class="docutils literal"><span class="pre">$(pos</span> <span class="pre">)</span></tt>, except that <tt class="docutils literal"><span class="pre">0</span></tt> is the end of the string:</p>
959<pre class="literal-block">
960$(insert in, str[, n[, length[, pad]]])
961</pre>
962<p>Translate <tt class="docutils literal"><span class="pre">string</span></tt> exchanging characters in <tt class="docutils literal"><span class="pre">from-set</span></tt> with <tt class="docutils literal"><span class="pre">to-set</span></tt>,
963optionally completing <tt class="docutils literal"><span class="pre">to-set</span></tt> with <tt class="docutils literal"><span class="pre">pad-char</span></tt> if specified. If no
964<tt class="docutils literal"><span class="pre">pad-char</span></tt> characters absent in <tt class="docutils literal"><span class="pre">to-set</span></tt> will be deleted:</p>
965<pre class="literal-block">
966$(translate string, from-set[, to-set[, pad-char]])
967</pre>
968</blockquote>
969<p>Functions for file names:</p>
970<blockquote>
971<p>Extract the directory part of each file <tt class="docutils literal"><span class="pre">name</span></tt>:</p>
972<pre class="literal-block">
973$(dir names...)
974</pre>
975<p>Extract the non-directory part of each file <tt class="docutils literal"><span class="pre">name</span></tt>:</p>
976<pre class="literal-block">
977$(notdir names...)
978</pre>
979<p>Extract the suffix (the last <tt class="docutils literal"><span class="pre">.</span></tt> and following characters) of each file
980<tt class="docutils literal"><span class="pre">name</span></tt>:</p>
981<pre class="literal-block">
982$(suffix names...)
983</pre>
984<p>Extract the base name (name without suffix) of each file name:</p>
985<pre class="literal-block">
986$(basename names...)
987</pre>
988<p>Append <tt class="docutils literal"><span class="pre">suffix</span></tt> to each word in <tt class="docutils literal"><span class="pre">names</span></tt>:</p>
989<pre class="literal-block">
990$(addsuffix suffix,names...)
991</pre>
992<p>Prepend <tt class="docutils literal"><span class="pre">prefix</span></tt> to each word in <tt class="docutils literal"><span class="pre">names</span></tt>:</p>
993<pre class="literal-block">
994$(addprefix prefix,names...)
995</pre>
996<p>Find file names matching a shell file name <tt class="docutils literal"><span class="pre">pattern</span></tt> (not a <tt class="docutils literal"><span class="pre">%</span></tt>
997pattern):</p>
998<pre class="literal-block">
999$(wildcard pattern...)
1000</pre>
1001<p>For each file name in <tt class="docutils literal"><span class="pre">names</span></tt>, expand to an absolute name that does not
1002contain any <tt class="docutils literal"><span class="pre">.</span></tt>, <tt class="docutils literal"><span class="pre">..</span></tt>, nor symlinks:</p>
1003<pre class="literal-block">
1004$(realpath names...)
1005</pre>
1006<p>For each file name in <tt class="docutils literal"><span class="pre">names</span></tt>, expand to an absolute name that does not
1007contain any <tt class="docutils literal"><span class="pre">.</span></tt> or <tt class="docutils literal"><span class="pre">..</span></tt> components, but preserves symlinks:</p>
1008<pre class="literal-block">
1009$(abspath names...)
1010</pre>
1011<p>Same as <tt class="docutils literal"><span class="pre">$(abspath</span> <span class="pre">)</span></tt> except that the current directory can be
1012specified as <tt class="docutils literal"><span class="pre">curdir</span></tt>:</p>
1013<pre class="literal-block">
1014$(abspathex names...[, curdir])
1015</pre>
1016</blockquote>
1017<p>Arithmetic Functions:</p>
1018<blockquote>
1019<p>Returns the sum of the arguments:</p>
1020<pre class="literal-block">
1021$(int-add addend1, addend2[, addendN])
1022</pre>
1023<p>Returns the difference between the first argument and the sum of the rest:</p>
1024<pre class="literal-block">
1025$(int-sub minuend, subtrahend[, subtrahendN])
1026</pre>
1027<p>Returns the product of the arguments:</p>
1028<pre class="literal-block">
1029$(int-mul factor1, factor2[, factorN])
1030</pre>
1031<p>Returns the quotient of first argument and the rest:</p>
1032<pre class="literal-block">
1033$(int-div dividend, divisor[, divisorN])
1034</pre>
1035<p>Returns the modulus of the two arguments:</p>
1036<pre class="literal-block">
1037$(int-mod dividend, divisor)
1038</pre>
1039<p>Returns the bitwise two-complement of argument:</p>
1040<pre class="literal-block">
1041$(int-not val)
1042</pre>
1043<p>Returns the result of a bitwise AND of the arguments:</p>
1044<pre class="literal-block">
1045$(int-and val1, val2[, valN])
1046</pre>
1047<p>Returns the result of a bitwise OR of the arguments:</p>
1048<pre class="literal-block">
1049$(int-or val1, val2[, valN])
1050</pre>
1051<p>Returns the result of a bitwise XOR of the arguments:</p>
1052<pre class="literal-block">
1053$(int-xor val1, val2[, valN])
1054</pre>
1055<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean (true = non-empty, false = empty) result
1056of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">==</span> <span class="pre">val2</span></tt>:</p>
1057<pre class="literal-block">
1058$(int-eq val1, val2)
1059</pre>
1060<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">!=</span> <span class="pre">val2</span></tt>:</p>
1061<pre class="literal-block">
1062$(int-ne val1, val2)
1063</pre>
1064<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">&gt;</span> <span class="pre">val2</span></tt>:</p>
1065<pre class="literal-block">
1066$(int-gt val1, val2)
1067</pre>
1068<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">&gt;=</span> <span class="pre">val2</span></tt>:</p>
1069<pre class="literal-block">
1070$(int-ge val1, val2)
1071</pre>
1072<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">&lt;</span> <span class="pre">val2</span></tt>:</p>
1073<pre class="literal-block">
1074$(int-lt val1, val2)
1075</pre>
1076<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean result of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">&lt;=</span> <span class="pre">val2</span></tt>:</p>
1077<pre class="literal-block">
1078$(int-le val1, val2)
1079</pre>
1080</blockquote>
1081<p>Boolean and Conditional Functions:</p>
1082<blockquote>
1083<p>Condition is false if the <tt class="docutils literal"><span class="pre">condition</span></tt> evaluates to an empty string
1084(stripped). Evaluate the <tt class="docutils literal"><span class="pre">true-part</span></tt> if the condition is true, otherwise
1085the <tt class="docutils literal"><span class="pre">false-part</span></tt>:</p>
1086<pre class="literal-block">
1087$(if condition,true-part[,false-part])
1088</pre>
1089<p>Test if any of the conditions evalues to non-empty string, returning the
1090first one:</p>
1091<pre class="literal-block">
1092$(or condition1[,condition2[,condition3[...]]])
1093</pre>
1094<p>Test if all of the conditions evaluates to non-empty strings, returning the
1095last one:</p>
1096<pre class="literal-block">
1097$(and condition1[,condition2[,condition3[...]]])
1098</pre>
1099<p>Test if the two strings are identical, returning <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean (true =
1100non-empty, false = empty):</p>
1101<pre class="literal-block">
1102$(eq str1, str2)
1103</pre>
1104<p>Invert a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value:</p>
1105<pre class="literal-block">
1106$(not val)
1107</pre>
1108<p>Test if <tt class="docutils literal"><span class="pre">variable</span></tt> is defined, returning a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value:</p>
1109<pre class="literal-block">
1110$(defined variable)
1111</pre>
1112<p>Test if <tt class="docutils literal"><span class="pre">set-a</span></tt> and <tt class="docutils literal"><span class="pre">set-b</span></tt> intersects, returning a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean
1113value:</p>
1114<pre class="literal-block">
1115$(intersects set-a, set-b)
1116</pre>
1117<p>Same as <tt class="docutils literal"><span class="pre">$(if</span> <span class="pre">)</span></tt> execpt that the condition is a <tt class="docutils literal"><span class="pre">kmk</span></tt>-expression:</p>
1118<pre class="literal-block">
1119$(if-expr kmk-expression,true-part[,false-part])
1120</pre>
1121<p>Select the first true condition (<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) and expand the
1122following body. Special condition strings <tt class="docutils literal"><span class="pre">default</span></tt> and <tt class="docutils literal"><span class="pre">otherwise</span></tt>:</p>
1123<pre class="literal-block">
1124$(select when1-cond, when1-body[, whenN-cond, whenN-body])
1125</pre>
1126<p>Evalutate the <tt class="docutils literal"><span class="pre">kmk-expression</span></tt> returning what it evalues as. This is
1127the preferred way of doing arithmentic now:</p>
1128<pre class="literal-block">
1129$(expr kmk-expression)
1130</pre>
1131</blockquote>
1132<p>Stack Fuctions:</p>
1133<blockquote>
1134<p>Push <tt class="docutils literal"><span class="pre">item</span></tt> onto the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string:</p>
1135<pre class="literal-block">
1136$(stack-push stack-var, item)
1137</pre>
1138<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt>:</p>
1139<pre class="literal-block">
1140$(stack-pop stack-var)
1141</pre>
1142<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string:</p>
1143<pre class="literal-block">
1144$(stack-popv stack-var)
1145</pre>
1146<p>Get the top item of the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string:</p>
1147<pre class="literal-block">
1148$(stack-top stack-var)
1149</pre>
1150</blockquote>
1151<p>Advanced Functions:</p>
1152<blockquote>
1153<p>Evaluates to the contents of the variable <tt class="docutils literal"><span class="pre">var</span></tt>, with no expansion
1154performed on it:</p>
1155<pre class="literal-block">
1156$(value var)
1157</pre>
1158<p>Evaluate <tt class="docutils literal"><span class="pre">body</span></tt> with <tt class="docutils literal"><span class="pre">var</span></tt> bound to each word in <tt class="docutils literal"><span class="pre">words</span></tt>, and
1159concatenate the results (spaced):</p>
1160<pre class="literal-block">
1161$(foreach var,words,body)
1162</pre>
1163<p>C-style for-loop. Start by evaluating <tt class="docutils literal"><span class="pre">init</span></tt>. Each iteration will
1164first check whether the <tt class="docutils literal"><span class="pre">condition</span></tt> (<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) is true,
1165then expand <tt class="docutils literal"><span class="pre">body</span></tt> concatenating the result to the previous iterations
1166(spaced), and finally evaluate <tt class="docutils literal"><span class="pre">next</span></tt>:</p>
1167<pre class="literal-block">
1168$(for init,conditions,next,body)
1169</pre>
1170<p>C-style while-loop. Each iteration will check whether the <tt class="docutils literal"><span class="pre">condition</span></tt>
1171(<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) is true, then expand <tt class="docutils literal"><span class="pre">body</span></tt> concatenating the
1172result to the previous iterations:</p>
1173<pre class="literal-block">
1174$(while conditions,body)
1175</pre>
1176<p>Evaluate the variable <tt class="docutils literal"><span class="pre">var</span></tt> replacing any references to <tt class="docutils literal"><span class="pre">$(1)</span></tt>,
1177<tt class="docutils literal"><span class="pre">$(2)</span></tt> with the first, second, etc. <tt class="docutils literal"><span class="pre">param</span></tt> values:</p>
1178<pre class="literal-block">
1179$(call var,param,...)
1180</pre>
1181<p>Evaluate <tt class="docutils literal"><span class="pre">text</span></tt> then read the results as makefile commands. Expands
1182to the empty string:</p>
1183<pre class="literal-block">
1184$(eval text)
1185</pre>
1186<p>Same as <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">text)</span></tt> except that the <tt class="docutils literal"><span class="pre">text</span></tt> is expanded in its
1187own variable context:</p>
1188<pre class="literal-block">
1189$(evalctx text)
1190</pre>
1191<p>Same as <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt>:</p>
1192<pre class="literal-block">
1193$(evalval var)
1194</pre>
1195<p>Same as <tt class="docutils literal"><span class="pre">$(evalctx</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt>:</p>
1196<pre class="literal-block">
1197$(evalvalctx var)
1198</pre>
1199<p>A combination of <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">)</span></tt>, <tt class="docutils literal"><span class="pre">$(call</span> <span class="pre">)</span></tt> and <tt class="docutils literal"><span class="pre">$(value</span> <span class="pre">)</span></tt>:</p>
1200<pre class="literal-block">
1201$(evalcall var)
1202</pre>
1203<p>A combination of <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">)</span></tt> and <tt class="docutils literal"><span class="pre">$(call</span> <span class="pre">)</span></tt>:</p>
1204<pre class="literal-block">
1205$(evalcall var)
1206</pre>
1207<p>Remove comments and blank lines from the variable <tt class="docutils literal"><span class="pre">var</span></tt>. Expands to
1208the empty string:</p>
1209<pre class="literal-block">
1210$(eval-opt-var var)
1211</pre>
1212<p>Returns accessing <tt class="docutils literal"><span class="pre">$&lt;</span></tt> of <tt class="docutils literal"><span class="pre">target</span></tt>, either retriving the whole thing
1213or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1214<pre class="literal-block">
1215$(deps target[, pos])
1216</pre>
1217<p>Returns accessing <tt class="docutils literal"><span class="pre">$+</span></tt> (order + duplicates) of <tt class="docutils literal"><span class="pre">target</span></tt>, either
1218retriving the whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1219<pre class="literal-block">
1220$(deps-all target[, pos])
1221</pre>
1222<p>Returns accessing <tt class="docutils literal"><span class="pre">$?</span></tt> of <tt class="docutils literal"><span class="pre">target</span></tt>, either retriving the whole
1223thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1224<pre class="literal-block">
1225$(deps-newer target[, pos])
1226</pre>
1227<p>Returns accessing <tt class="docutils literal"><span class="pre">$|</span></tt> (order only) of <tt class="docutils literal"><span class="pre">target</span></tt>, either retriving the
1228whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1229<pre class="literal-block">
1230$(deps-oo target[, pos])
1231</pre>
1232</blockquote>
1233<p>Command Functions:</p>
1234<blockquote>
1235<p>Create one or more command lines avoiding the max argument
1236length restriction of the host OS:</p>
1237<pre class="literal-block">
1238$(xargs ar cas mylib.a,$(objects))
1239$(xargs ar cas mylib.a,ar as mylib.a,$(objects))
1240</pre>
1241<p>Returns the commands for the specified target separated by new-line, space,
1242or a user defined string. Note that this might not produce the 100% correct
1243result if any of the prerequisite automatic variables are used:</p>
1244<pre class="literal-block">
1245$(commands target)
1246$(commands-sc target)
1247$(commands-usr target,sep)
1248</pre>
1249<p>Compares two commands returning the empty string if equal and the 3rd
1250argument if not. This differs from <tt class="docutils literal"><span class="pre">$(comp-vars</span> <span class="pre">v1,v2,ne)</span></tt> in that
1251line by line is stripped of leading spaces, command prefixes and
1252trailing spaces before comparing:</p>
1253<pre class="literal-block">
1254$(comp-cmds cmds-var1, cmds-var2, ne)
1255$(comp-cmds-ex cmds1, cmd2, ne)
1256</pre>
1257<p>Compares the values of the two variables returning the empty string if
1258equal and the 3rd argument if not. Leading and trailing spaces is ignored:</p>
1259<pre class="literal-block">
1260$(comp-var var1, var2, ne)
1261</pre>
1262</blockquote>
1263<p>Utility functions:</p>
1264<blockquote>
1265<p>When this function is evaluated, <tt class="docutils literal"><span class="pre">kmk</span></tt> generates a fatal error with the
1266message <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
1267<pre class="literal-block">
1268$(error text...)
1269</pre>
1270<p>When this function is evaluated, <tt class="docutils literal"><span class="pre">kmk</span></tt> generates a warning with the
1271message <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
1272<pre class="literal-block">
1273$(warning text...)
1274</pre>
1275<p>When this function is evaluated, <tt class="docutils literal"><span class="pre">kmk</span></tt> generates a info with the
1276message <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
1277<pre class="literal-block">
1278$(info text...)
1279</pre>
1280<p>Execute a shell <tt class="docutils literal"><span class="pre">command</span></tt> and return its output:</p>
1281<pre class="literal-block">
1282$(shell command)
1283</pre>
1284<p>Return a string describing how the <tt class="docutils literal"><span class="pre">kmk</span></tt> variable <tt class="docutils literal"><span class="pre">variable</span></tt> was defined:</p>
1285<pre class="literal-block">
1286$(origin variable)
1287</pre>
1288<p>Return a string describing the flavor of the <tt class="docutils literal"><span class="pre">kmk</span></tt> variable <tt class="docutils literal"><span class="pre">variable</span></tt>:</p>
1289<pre class="literal-block">
1290$(flavor variable)
1291</pre>
1292<p>Returns the current local time and date formatted in the <tt class="docutils literal"><span class="pre">strftime</span></tt>
1293style specifier <tt class="docutils literal"><span class="pre">fmt</span></tt>. <tt class="docutils literal"><span class="pre">fmt</span></tt> defaults to <tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%S</span></tt> when
1294not specified:</p>
1295<pre class="literal-block">
1296$(date fmt)
1297</pre>
1298<p>Returns the current UTC time and date formatted in the <tt class="docutils literal"><span class="pre">strftime</span></tt>
1299style specifier <tt class="docutils literal"><span class="pre">fmt</span></tt>. <tt class="docutils literal"><span class="pre">fmt</span></tt> defaults to <tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%SZ</span></tt> when
1300not specified:</p>
1301<pre class="literal-block">
1302$(date-utc fmt)
1303</pre>
1304<p>Reformats the <tt class="docutils literal"><span class="pre">in</span></tt> time and date using <tt class="docutils literal"><span class="pre">fmt</span></tt>. The <tt class="docutils literal"><span class="pre">in-fmt</span></tt> defaults
1305to <tt class="docutils literal"><span class="pre">fmt</span></tt> if not specified. While <tt class="docutils literal"><span class="pre">fmt</span></tt> defaults to
1306<tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%SZ</span></tt> if not specified:</p>
1307<pre class="literal-block">
1308$(date-utc fmt,time,in-fmt)
1309</pre>
1310<p>Returns the current nanosecond timestamp (monotonic when possible):</p>
1311<pre class="literal-block">
1312$(nanots )
1313</pre>
1314<p>Returns the size of the specified file, or -1 if the size could not
1315be obtained. This can be used to check if a file exist or not:</p>
1316<pre class="literal-block">
1317$(file-size file)
1318</pre>
1319<p>Searches the <tt class="docutils literal"><span class="pre">PATH</span></tt> <tt class="docutils literal"><span class="pre">kmk</span></tt> variable for the specified <tt class="docutils literal"><span class="pre">files</span></tt>:</p>
1320<pre class="literal-block">
1321$(which files...)
1322</pre>
1323<p>OS/2: Returns the specified LIBPATH variable value:</p>
1324<pre class="literal-block">
1325$(libpath var)
1326</pre>
1327<p>OS/2: Sets the specified LIBPATH variable value, returning the empty string:</p>
1328<pre class="literal-block">
1329$(libpath var,value)
1330</pre>
1331</blockquote>
1332<p>Debugging Functions:</p>
1333<blockquote>
1334<p>Returns various make statistics, if no item is specified a default
1335selection is returned:</p>
1336<pre class="literal-block">
1337$(make-stats item[,itemN])
1338</pre>
1339<p>Raise a debug breakpoint. Used for debugging <tt class="docutils literal"><span class="pre">kmk</span></tt> makefile parsing:</p>
1340<pre class="literal-block">
1341$(breakpoint )
1342</pre>
1343</blockquote>
1344<hr class="docutils" />
1345<table class="docutils footnote" frame="void" id="id15" rules="none">
1346<colgroup><col class="label" /><col /></colgroup>
1347<tbody valign="top">
1348<tr><td class="label"><a name="id15">[1]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>, <a class="fn-backref" href="#id3">3</a>, <a class="fn-backref" href="#id4">4</a>, <a class="fn-backref" href="#id5">5</a>, <a class="fn-backref" href="#id6">6</a>, <a class="fn-backref" href="#id7">7</a>, <a class="fn-backref" href="#id8">8</a>, <a class="fn-backref" href="#id9">9</a>, <a class="fn-backref" href="#id10">10</a>, <a class="fn-backref" href="#id11">11</a>, <a class="fn-backref" href="#id12">12</a>, <a class="fn-backref" href="#id13">13</a>, <a class="fn-backref" href="#id14">14</a>)</em> <tt class="docutils literal"><span class="pre">kmk</span></tt> only feature.</td></tr>
1349</tbody>
1350</table>
1351<hr class="docutils" />
1352<table class="docutils field-list" frame="void" rules="none">
1353<col class="field-name" />
1354<col class="field-body" />
1355<tbody valign="top">
1356<tr class="field"><th class="field-name">Status:</th><td class="field-body"><p class="first">$Id: QuickReference-kmk.html 2169 2008-12-30 17:07:09Z bird $</p>
1357</td>
1358</tr>
1359<tr class="field"><th class="field-name">Copyright:</th><td class="field-body"><p class="first">Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
13601996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
13612007 Free Software Foundation, Inc.</p>
1362<p class="last">Copyright (C) 2008 Knut St. Osmundsen</p>
1363</td>
1364</tr>
1365</tbody>
1366</table>
1367</div>
1368</div>
1369</body>
1370</html>
Note: See TracBrowser for help on using the repository browser.