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

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

kmk-qr: reorg

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 56.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 16:52:13 +0000 (Tue, 30 Dec 2008) $
14:Revision: $Revision: 2168 $
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<div class="section">
300<h1><a id="directives" name="directives">Directives</a></h1>
301<p>Here is a summary of the directives <tt class="docutils literal"><span class="pre">kmk</span></tt> recognizes:</p>
302<blockquote>
303<p>Define a multi-line, recursively-expanded variable:</p>
304<pre class="literal-block">
305define variable
306endef
307</pre>
308<p>Conditionally evaluate part of the makefile:</p>
309<pre class="literal-block">
310ifdef variable
311ifndef variable
312ifeq (a,b)
313ifeq &quot;a&quot; &quot;b&quot;
314ifeq 'a' 'b'
315ifneq (a,b)
316ifneq &quot;a&quot; &quot;b&quot;
317ifneq 'a' 'b'
318if1of (set-a,set-b)
319ifn1of (set-a,set-b)
320if expression
321else
322endif
323</pre>
324<p>Include another makefile:</p>
325<pre class="literal-block">
326include file
327-include file
328sinclude file
329</pre>
330<p>Include another dependency file:</p>
331<pre class="literal-block">
332includedep file
333</pre>
334<p>Define a variable, overriding any previous definition, even one from the
335command line:</p>
336<pre class="literal-block">
337override variable = value
338override variable := value
339override variable += value
340override variable &lt;= value
341override variable ?= value
342override define variable
343endef
344</pre>
345<p>Tell <tt class="docutils literal"><span class="pre">kmk</span></tt> to export all variables to child processes by default:</p>
346<pre class="literal-block">
347export
348</pre>
349<p>Tell <tt class="docutils literal"><span class="pre">kmk</span></tt> whether or not to export a particular variable to child
350processes:</p>
351<pre class="literal-block">
352export variable
353export variable = value
354export variable := value
355export variable += value
356export variable &lt;= value
357export variable ?= value
358unexport variable
359</pre>
360<p>Define a variable in the local context instead of the global one:</p>
361<pre class="literal-block">
362local variable = value
363local variable := value
364local variable += value
365local variable &lt;= value
366local variable ?= value
367local define variable
368endef
369</pre>
370<p>Specify a search path for files matching a <tt class="docutils literal"><span class="pre">%</span></tt> pattern:</p>
371<pre class="literal-block">
372vpath pattern path
373</pre>
374<p>Remove all search paths previously specified for pattern:</p>
375<pre class="literal-block">
376vpath pattern
377</pre>
378<p>Remove all search paths previously specified in any vpath directive:</p>
379<pre class="literal-block">
380vpath
381</pre>
382</blockquote>
383</div>
384<div class="section">
385<h1><a id="automatic-variables" name="automatic-variables">Automatic variables</a></h1>
386<p>Here is a summary of the automatic variables.</p>
387<table border="1" class="docutils">
388<colgroup>
389<col width="14%" />
390<col width="86%" />
391</colgroup>
392<thead valign="bottom">
393<tr><th class="head">Variable</th>
394<th class="head">Description</th>
395</tr>
396</thead>
397<tbody valign="top">
398<tr><td><tt class="docutils literal"><span class="pre">$&#64;</span></tt></td>
399<td>The file name of the target.</td>
400</tr>
401<tr><td><tt class="docutils literal"><span class="pre">$&lt;</span></tt></td>
402<td>The name of the first prerequisite.</td>
403</tr>
404<tr><td><tt class="docutils literal"><span class="pre">$?</span></tt></td>
405<td>The names of all the prerequisites that are newer than the
406target, with spaces between them.</td>
407</tr>
408<tr><td><tt class="docutils literal"><span class="pre">$^</span></tt></td>
409<td>The names of all the prerequisites, duplicates omitted.</td>
410</tr>
411<tr><td><tt class="docutils literal"><span class="pre">$+</span></tt></td>
412<td>The names of all the prerequisites, duplicates and order
413preserved</td>
414</tr>
415<tr><td><tt class="docutils literal"><span class="pre">$*</span></tt></td>
416<td>The stem with which an implicit rule matches.</td>
417</tr>
418<tr><td><tt class="docutils literal"><span class="pre">$|</span></tt></td>
419<td>The name of all the order only prerequisites.</td>
420</tr>
421<tr><td><tt class="docutils literal"><span class="pre">$(&#64;D)</span></tt></td>
422<td>The directory part of <tt class="docutils literal"><span class="pre">$&#64;</span></tt>.</td>
423</tr>
424<tr><td><tt class="docutils literal"><span class="pre">$(&lt;D)</span></tt></td>
425<td>The directory part of <tt class="docutils literal"><span class="pre">$&lt;</span></tt>.</td>
426</tr>
427<tr><td><tt class="docutils literal"><span class="pre">$(?D)</span></tt></td>
428<td>The directory part of <tt class="docutils literal"><span class="pre">$?</span></tt>.</td>
429</tr>
430<tr><td><tt class="docutils literal"><span class="pre">$(^D)</span></tt></td>
431<td>The directory part of <tt class="docutils literal"><span class="pre">%^</span></tt>.</td>
432</tr>
433<tr><td><tt class="docutils literal"><span class="pre">$(+D)</span></tt></td>
434<td>The directory part of <tt class="docutils literal"><span class="pre">$+</span></tt>.</td>
435</tr>
436<tr><td><tt class="docutils literal"><span class="pre">$(*D)</span></tt></td>
437<td>The directory part of <tt class="docutils literal"><span class="pre">$*</span></tt>.</td>
438</tr>
439<tr><td><tt class="docutils literal"><span class="pre">$(|D)</span></tt></td>
440<td>The directory part of <tt class="docutils literal"><span class="pre">$|</span></tt>.</td>
441</tr>
442<tr><td><tt class="docutils literal"><span class="pre">$(&#64;F)</span></tt></td>
443<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$&#64;</span></tt>.</td>
444</tr>
445<tr><td><tt class="docutils literal"><span class="pre">$(&lt;F)</span></tt></td>
446<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$&lt;</span></tt>.</td>
447</tr>
448<tr><td><tt class="docutils literal"><span class="pre">$(?F)</span></tt></td>
449<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$?</span></tt>.</td>
450</tr>
451<tr><td><tt class="docutils literal"><span class="pre">$(^F)</span></tt></td>
452<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$^</span></tt>.</td>
453</tr>
454<tr><td><tt class="docutils literal"><span class="pre">$(+F)</span></tt></td>
455<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$+</span></tt>.</td>
456</tr>
457<tr><td><tt class="docutils literal"><span class="pre">$(*F)</span></tt></td>
458<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$*</span></tt>.</td>
459</tr>
460<tr><td><tt class="docutils literal"><span class="pre">$(|F)</span></tt></td>
461<td>The file-within-directory part of <tt class="docutils literal"><span class="pre">$|</span></tt>.</td>
462</tr>
463</tbody>
464</table>
465</div>
466<div class="section">
467<h1><a id="special-variables" name="special-variables">Special variables</a></h1>
468<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
469variables are specially used or/and defined by <tt class="docutils literal"><span class="pre">kmk</span></tt>:</p>
470<table border="1" class="docutils">
471<colgroup>
472<col width="34%" />
473<col width="66%" />
474</colgroup>
475<thead valign="bottom">
476<tr><th class="head">Variable</th>
477<th class="head">Description</th>
478</tr>
479</thead>
480<tbody valign="top">
481<tr><td><tt class="docutils literal"><span class="pre">.DEFAULT_GOAL</span></tt></td>
482<td>The makefile default goal. You can set this in
483the makefile, if you don't it will default to
484the first target that is encountered.</td>
485</tr>
486<tr><td><tt class="docutils literal"><span class="pre">.FEATURES</span></tt></td>
487<td>List of GNU <tt class="docutils literal"><span class="pre">make</span></tt> features. Do not set this.</td>
488</tr>
489<tr><td><tt class="docutils literal"><span class="pre">.INCLUDE_DIRS</span></tt></td>
490<td>List of include directories, <tt class="docutils literal"><span class="pre">-I</span></tt> arguments
491and defaults. Do not set this.</td>
492</tr>
493<tr><td><tt class="docutils literal"><span class="pre">.RECIPEPREFIX</span></tt></td>
494<td>Recipe prefix, defaults to tab.</td>
495</tr>
496<tr><td><tt class="docutils literal"><span class="pre">.VARIABLES</span></tt></td>
497<td>Special variable which exands to the list of
498variable. Do not set this.</td>
499</tr>
500<tr><td><tt class="docutils literal"><span class="pre">CURDIR</span></tt></td>
501<td>Set to the pathname of the current working
502directory (after all <tt class="docutils literal"><span class="pre">-C</span></tt> options are
503processed, if any). Do not set this.</td>
504</tr>
505<tr><td><tt class="docutils literal"><span class="pre">KBUILD_VERSION</span></tt>,
506<tt class="docutils literal"><span class="pre">KBUILD_VERSION_MAJOR</span></tt>,
507<tt class="docutils literal"><span class="pre">KBUILD_VERSION_MINOR</span></tt>,
508<tt class="docutils literal"><span class="pre">KBUILD_VERSION_PATCH</span></tt>,
509<tt class="docutils literal"><span class="pre">KBUILD_KMK_REVISION</span></tt></td>
510<td>The kBuild version string and the break down
511into individual components.</td>
512</tr>
513<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST</span></tt></td>
514<td>The host operating system.</td>
515</tr>
516<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_ARCH</span></tt></td>
517<td>The host architecture.</td>
518</tr>
519<tr><td><tt class="docutils literal"><span class="pre">KBUILD_HOST_CPU</span></tt></td>
520<td>The host CPU <tt class="docutils literal"><span class="pre">kmk</span></tt> is built for, set to
521<tt class="docutils literal"><span class="pre">blend</span></tt> if not any particular CPU.</td>
522</tr>
523<tr><td><tt class="docutils literal"><span class="pre">KBUILD_PATH</span></tt></td>
524<td>Where the kBuild scripts are.</td>
525</tr>
526<tr><td><tt class="docutils literal"><span class="pre">KBUILD_BIN_PATH</span></tt></td>
527<td>Where the host specific kBuild binaries are.</td>
528</tr>
529<tr><td><tt class="docutils literal"><span class="pre">KMK</span></tt>,
530<tt class="docutils literal"><span class="pre">MAKE</span></tt></td>
531<td>The name with which <tt class="docutils literal"><span class="pre">kmk</span></tt> was invoked. Using
532this variable in recipes has special meaning.</td>
533</tr>
534<tr><td><tt class="docutils literal"><span class="pre">KMK_BUILTIN</span></tt></td>
535<td>List of built-in commands.</td>
536</tr>
537<tr><td><tt class="docutils literal"><span class="pre">KMK_FEATURES</span></tt></td>
538<td>List of <tt class="docutils literal"><span class="pre">kmk</span></tt> specific features.</td>
539</tr>
540<tr><td><tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt></td>
541<td><p class="first">The flags given to <tt class="docutils literal"><span class="pre">kmk</span></tt>. You can set this in
542the environment or a makefile to set flags.</p>
543<p class="last">It is never appropriate to use <tt class="docutils literal"><span class="pre">KMK_FLAGS</span></tt>
544directly in a recipe line: its contents may not
545be quoted correctly for use in the shell. Always
546allow recursive <tt class="docutils literal"><span class="pre">kmk</span></tt>'s to obtain these values
547through the environment from its parent.</p>
548</td>
549</tr>
550<tr><td><tt class="docutils literal"><span class="pre">KMK_LEVEL</span></tt></td>
551<td>The number of levels of recursion (sub-makes).</td>
552</tr>
553<tr><td><tt class="docutils literal"><span class="pre">KMK_VERSION</span></tt></td>
554<td>The GNU <tt class="docutils literal"><span class="pre">make</span></tt> version number.</td>
555</tr>
556<tr><td><tt class="docutils literal"><span class="pre">MAKECMDGOALS</span></tt></td>
557<td>The targets given to <tt class="docutils literal"><span class="pre">kmk</span></tt> on the command line.
558Do not set this.</td>
559</tr>
560<tr><td><tt class="docutils literal"><span class="pre">MAKEFILES</span></tt></td>
561<td>Makefiles to be read on every invocation of
562<tt class="docutils literal"><span class="pre">kmk</span></tt>.</td>
563</tr>
564<tr><td><tt class="docutils literal"><span class="pre">MAKEFILE_LIST</span></tt></td>
565<td>List of the makefiles that <tt class="docutils literal"><span class="pre">kmk</span></tt> has opened.</td>
566</tr>
567<tr><td><tt class="docutils literal"><span class="pre">MAKESHELL</span></tt></td>
568<td>OS/2 and MS-DOS only, the name of the command
569interpreter that is to be used by <tt class="docutils literal"><span class="pre">kmk</span></tt>. This
570value takes precedence over the value of SHELL.</td>
571</tr>
572<tr><td><tt class="docutils literal"><span class="pre">SHELL</span></tt></td>
573<td>The name of the default command interpreter,
574kmk_ash. You can set SHELL in the makefile to
575change the shell used to run recipes. The SHELL
576variable is handled specially when importing
577from and exporting to the environment.</td>
578</tr>
579<tr><td><tt class="docutils literal"><span class="pre">SUFFIXES</span></tt></td>
580<td>The default list of suffixes before <tt class="docutils literal"><span class="pre">kmk</span></tt>
581reads any makefiles (always empty).</td>
582</tr>
583<tr><td><tt class="docutils literal"><span class="pre">VPATH</span></tt></td>
584<td>Directory search path for files not found in the
585current directory.</td>
586</tr>
587</tbody>
588</table>
589<p>The following variables reflects <tt class="docutils literal"><span class="pre">kmk</span></tt> options. Do not set these.</p>
590<table border="1" class="docutils">
591<colgroup>
592<col width="49%" />
593<col width="51%" />
594</colgroup>
595<thead valign="bottom">
596<tr><th class="head">Variable</th>
597<th class="head">Description</th>
598</tr>
599</thead>
600<tbody valign="top">
601<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_JOBS</span></tt></td>
602<td>-j slots, <tt class="docutils literal"><span class="pre">0</span></tt> if not given.</td>
603</tr>
604<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_KEEP_GOING</span></tt></td>
605<td>-k indictor (<tt class="docutils literal"><span class="pre">0</span></tt>/<tt class="docutils literal"><span class="pre">1</span></tt>).</td>
606</tr>
607<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_JUST_PRINT</span></tt></td>
608<td>-n indicator (<tt class="docutils literal"><span class="pre">0</span></tt>/<tt class="docutils literal"><span class="pre">1</span></tt>).</td>
609</tr>
610<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_PRORITY</span></tt></td>
611<td>--priority level, <tt class="docutils literal"><span class="pre">0</span></tt> if not given.</td>
612</tr>
613<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_AFFINITY</span></tt></td>
614<td>--affinity mask, <tt class="docutils literal"><span class="pre">0</span></tt> if not given.</td>
615</tr>
616<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_STATISTICS</span></tt></td>
617<td>--statistics indicator (<tt class="docutils literal"><span class="pre">0</span></tt>/<tt class="docutils literal"><span class="pre">1</span></tt>).</td>
618</tr>
619<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_PRINT_TIME</span></tt></td>
620<td>The --print-time value.</td>
621</tr>
622<tr><td><tt class="docutils literal"><span class="pre">KMK_OPTS_PRETTY_COMMAND_PRINTING</span></tt></td>
623<td>--pretty-command-printing indicator.</td>
624</tr>
625</tbody>
626</table>
627</div>
628<div class="section">
629<h1><a id="special-targets" name="special-targets">Special Targets</a></h1>
630<p>todo</p>
631</div>
632<div class="section">
633<h1><a id="commands" name="commands">Commands</a></h1>
634<p>Builtin commands all start with <tt class="docutils literal"><span class="pre">kmk_builtin_</span></tt>, so in order to save space
635this prefix has been omitted in the table below. All commands comes in an
636external edition that can be used by/in the shell, these are prefixed <tt class="docutils literal"><span class="pre">kmk_</span></tt>.</p>
637<table border="1" class="docutils">
638<colgroup>
639<col width="20%" />
640<col width="80%" />
641</colgroup>
642<thead valign="bottom">
643<tr><th class="head">Command</th>
644<th class="head">Description</th>
645</tr>
646</thead>
647<tbody valign="top">
648<tr><td><tt class="docutils literal"><span class="pre">append</span></tt></td>
649<td>Append text to a file. The builtin version can output the
650value of a variable or the commands of a target.</td>
651</tr>
652<tr><td><tt class="docutils literal"><span class="pre">cat</span></tt></td>
653<td>The BSD <tt class="docutils literal"><span class="pre">cat</span></tt> command.</td>
654</tr>
655<tr><td><tt class="docutils literal"><span class="pre">chmod</span></tt></td>
656<td>The BSD <tt class="docutils literal"><span class="pre">chmod</span></tt> command.</td>
657</tr>
658<tr><td><tt class="docutils literal"><span class="pre">cmp</span></tt></td>
659<td>The BSD <tt class="docutils literal"><span class="pre">cmp</span></tt> command.</td>
660</tr>
661<tr><td><tt class="docutils literal"><span class="pre">cp</span></tt></td>
662<td>The BSD <tt class="docutils literal"><span class="pre">cp</span></tt> command with some twaking.</td>
663</tr>
664<tr><td><tt class="docutils literal"><span class="pre">echo</span></tt></td>
665<td>The BSD <tt class="docutils literal"><span class="pre">echo</span></tt> command.</td>
666</tr>
667<tr><td><tt class="docutils literal"><span class="pre">expr</span></tt></td>
668<td>The BSD <tt class="docutils literal"><span class="pre">expr</span></tt> command.</td>
669</tr>
670<tr><td><tt class="docutils literal"><span class="pre">install</span></tt></td>
671<td>The BSD <tt class="docutils literal"><span class="pre">install</span></tt> command with some tweaking.</td>
672</tr>
673<tr><td><tt class="docutils literal"><span class="pre">kDepIDB</span></tt></td>
674<td>Extract dependencies from a Visual C++ .IDB file.</td>
675</tr>
676<tr><td><tt class="docutils literal"><span class="pre">ln</span></tt></td>
677<td>The BSD <tt class="docutils literal"><span class="pre">ln</span></tt> command.</td>
678</tr>
679<tr><td><tt class="docutils literal"><span class="pre">md5sum</span></tt></td>
680<td>Typical MD5 sum program, custom kBuild version.</td>
681</tr>
682<tr><td><tt class="docutils literal"><span class="pre">mkdir</span></tt></td>
683<td>The BSD <tt class="docutils literal"><span class="pre">mkdir</span></tt> command.</td>
684</tr>
685<tr><td><tt class="docutils literal"><span class="pre">mv</span></tt></td>
686<td>The BSD <tt class="docutils literal"><span class="pre">mv</span></tt> command with some tweaking.</td>
687</tr>
688<tr><td><tt class="docutils literal"><span class="pre">printf</span></tt></td>
689<td>The BSD <tt class="docutils literal"><span class="pre">printf</span></tt> command.</td>
690</tr>
691<tr><td><tt class="docutils literal"><span class="pre">rm</span></tt></td>
692<td>The BSD <tt class="docutils literal"><span class="pre">rm</span></tt> command with some tweaking.</td>
693</tr>
694<tr><td><tt class="docutils literal"><span class="pre">rmdir</span></tt></td>
695<td>The BSD <tt class="docutils literal"><span class="pre">rmdir</span></tt> command with some tweaking.</td>
696</tr>
697<tr><td><tt class="docutils literal"><span class="pre">sleep</span></tt></td>
698<td>Typical <tt class="docutils literal"><span class="pre">sleep</span></tt> program, custom kBuild version.</td>
699</tr>
700<tr><td><tt class="docutils literal"><span class="pre">test</span></tt></td>
701<td>The BSD <tt class="docutils literal"><span class="pre">test</span></tt> program with some tweaking.</td>
702</tr>
703</tbody>
704</table>
705<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>
706environment (<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>
707<table border="1" class="docutils">
708<colgroup>
709<col width="20%" />
710<col width="80%" />
711</colgroup>
712<thead valign="bottom">
713<tr><th class="head">Command</th>
714<th class="head">Description</th>
715</tr>
716</thead>
717<tbody valign="top">
718<tr><td><tt class="docutils literal"><span class="pre">kDepPre</span></tt></td>
719<td>Extract dependencies from the C/C++ preprocessor output.</td>
720</tr>
721<tr><td><tt class="docutils literal"><span class="pre">kObjCache</span></tt></td>
722<td>Simple object file cache program.</td>
723</tr>
724<tr><td><tt class="docutils literal"><span class="pre">ash</span></tt></td>
725<td>Almquist's shell (NetBSD variant).</td>
726</tr>
727<tr><td><tt class="docutils literal"><span class="pre">gmake</span></tt></td>
728<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>
729</tr>
730<tr><td><tt class="docutils literal"><span class="pre">redirect</span></tt></td>
731<td>Shell avoidance tool. Sets up file descriptors, environment
732variables and current directory before kicking of program.</td>
733</tr>
734<tr><td><tt class="docutils literal"><span class="pre">sed</span></tt></td>
735<td>GNU <tt class="docutils literal"><span class="pre">sed</span></tt> with some tweaks to avoid involving the shell.</td>
736</tr>
737<tr><td><tt class="docutils literal"><span class="pre">time</span></tt></td>
738<td>Stopwatch utility for measuring program execution time(s).</td>
739</tr>
740</tbody>
741</table>
742</div>
743<div class="section">
744<h1><a id="kmk-expression" name="kmk-expression">kmk-expression</a></h1>
745<p><tt class="docutils literal"><span class="pre">kmk</span></tt>-expressions are related to the C/C++ preprocessor in some ways as well
746as <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
747the way GNU <tt class="docutils literal"><span class="pre">make</span></tt> choose to represent booleans in its function library, so,
748strings can be turned into boolean by taking any non-empty string as true.</p>
749<p>Quoting using single quotes results in hard strings, while double quotes and
750unquoted string results in soft strings that can be converted to number or
751boolean to fit the situation.</p>
752<p>Here's the operator table in decending precedence order:</p>
753<table border="1" class="docutils">
754<colgroup>
755<col width="20%" />
756<col width="11%" />
757<col width="70%" />
758</colgroup>
759<thead valign="bottom">
760<tr><th class="head">Operator</th>
761<th class="head">Type</th>
762<th class="head">Description</th>
763</tr>
764</thead>
765<tbody valign="top">
766<tr><td><tt class="docutils literal"><span class="pre">defined</span></tt></td>
767<td rowspan="6">Unary</td>
768<td>Checks if the following variable exists.</td>
769</tr>
770<tr><td><tt class="docutils literal"><span class="pre">exists</span></tt></td>
771<td>Checks if the following file exists.</td>
772</tr>
773<tr><td><tt class="docutils literal"><span class="pre">target</span></tt></td>
774<td>Checks if the following target exists.</td>
775</tr>
776<tr><td><tt class="docutils literal"><span class="pre">bool</span></tt></td>
777<td>Casts the following value to boolean.</td>
778</tr>
779<tr><td><tt class="docutils literal"><span class="pre">num</span></tt></td>
780<td>Casts the following value to a number.</td>
781</tr>
782<tr><td><tt class="docutils literal"><span class="pre">str</span></tt></td>
783<td>Casts the following value to a string.</td>
784</tr>
785<tr><td><tt class="docutils literal"><span class="pre">!</span></tt></td>
786<td rowspan="4">Unary</td>
787<td>Logical NOT.</td>
788</tr>
789<tr><td><tt class="docutils literal"><span class="pre">+</span></tt></td>
790<td>Pluss prefix.</td>
791</tr>
792<tr><td><tt class="docutils literal"><span class="pre">-</span></tt></td>
793<td>Minus prefix.</td>
794</tr>
795<tr><td><tt class="docutils literal"><span class="pre">~</span></tt></td>
796<td>Bitwise one's complement.</td>
797</tr>
798<tr><td><tt class="docutils literal"><span class="pre">*</span></tt></td>
799<td rowspan="3">Binary</td>
800<td>Multiplication (product).</td>
801</tr>
802<tr><td><tt class="docutils literal"><span class="pre">/</span></tt></td>
803<td>Division (quotient).</td>
804</tr>
805<tr><td><tt class="docutils literal"><span class="pre">%</span></tt></td>
806<td>Modulus (remainder).</td>
807</tr>
808<tr><td><tt class="docutils literal"><span class="pre">+</span></tt></td>
809<td rowspan="2">Binary</td>
810<td>Addition (sum).</td>
811</tr>
812<tr><td><tt class="docutils literal"><span class="pre">-</span></tt></td>
813<td>Subtraction (difference).</td>
814</tr>
815<tr><td><tt class="docutils literal"><span class="pre">&lt;&lt;</span></tt></td>
816<td rowspan="2">Binary</td>
817<td>Bitwise left shift.</td>
818</tr>
819<tr><td><tt class="docutils literal"><span class="pre">&gt;&gt;</span></tt></td>
820<td>Bitwise right shift.</td>
821</tr>
822<tr><td><tt class="docutils literal"><span class="pre">&lt;=</span></tt></td>
823<td rowspan="4">Binary</td>
824<td>Less or equal than.</td>
825</tr>
826<tr><td><tt class="docutils literal"><span class="pre">&lt;</span></tt></td>
827<td>Less than.</td>
828</tr>
829<tr><td><tt class="docutils literal"><span class="pre">&gt;=</span></tt></td>
830<td>Greater or equal than.</td>
831</tr>
832<tr><td><tt class="docutils literal"><span class="pre">&gt;</span></tt></td>
833<td>Greater than.</td>
834</tr>
835<tr><td><tt class="docutils literal"><span class="pre">==</span></tt></td>
836<td rowspan="2">Binary</td>
837<td>Equal to.</td>
838</tr>
839<tr><td><tt class="docutils literal"><span class="pre">!=</span></tt></td>
840<td>Not equal to.</td>
841</tr>
842<tr><td><tt class="docutils literal"><span class="pre">&amp;</span></tt></td>
843<td>Binary</td>
844<td>Bitwise AND.</td>
845</tr>
846<tr><td><tt class="docutils literal"><span class="pre">^</span></tt></td>
847<td>Binary</td>
848<td>Bitwise XOR.</td>
849</tr>
850<tr><td><tt class="docutils literal"><span class="pre">|</span></tt></td>
851<td>Binary</td>
852<td>Bitwise OR.</td>
853</tr>
854<tr><td><tt class="docutils literal"><span class="pre">&amp;&amp;</span></tt></td>
855<td>Binary</td>
856<td>Logical AND.</td>
857</tr>
858<tr><td><tt class="docutils literal"><span class="pre">||</span></tt></td>
859<td>Binary</td>
860<td>Logical OR.</td>
861</tr>
862</tbody>
863</table>
864</div>
865<div class="section">
866<h1><a id="built-in-functions" name="built-in-functions">Built-in functions</a></h1>
867<p>String Manipulation Functions:</p>
868<blockquote>
869<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>
870<pre class="literal-block">
871$(subst from,to,text)
872</pre>
873<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>
874<pre class="literal-block">
875$(patsubst pattern,replacement,text)
876</pre>
877<p>Remove excess whitespace characters from <tt class="docutils literal"><span class="pre">string</span></tt>:</p>
878<pre class="literal-block">
879$(strip string)
880</pre>
881<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>
882<pre class="literal-block">
883$(findstring find,text)
884</pre>
885<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>
886<pre class="literal-block">
887$(filter pattern...,text)
888</pre>
889<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>
890<pre class="literal-block">
891$(filter-out pattern...,text)
892</pre>
893<p>Sort the words in <tt class="docutils literal"><span class="pre">list</span></tt> lexicographically, removing duplicates:</p>
894<pre class="literal-block">
895$(sort list)
896</pre>
897<p>Sort the words in <tt class="docutils literal"><span class="pre">list</span></tt> lexicographically in reserve order, removing
898duplicates:</p>
899<pre class="literal-block">
900$(rsort list)
901</pre>
902<p>Count the number of words in <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
903<pre class="literal-block">
904$(words text)
905</pre>
906<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>
907<pre class="literal-block">
908$(word n,text)
909</pre>
910<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>
911<pre class="literal-block">
912$(wordlist s,e,text)
913</pre>
914<p>Extract the first word of <tt class="docutils literal"><span class="pre">names</span></tt>:</p>
915<pre class="literal-block">
916$(firstword names...)
917</pre>
918<p>Extract the last word of <tt class="docutils literal"><span class="pre">names</span></tt>:</p>
919<pre class="literal-block">
920$(lastword names...)
921</pre>
922<p>Join two parallel lists of words:</p>
923<pre class="literal-block">
924$(join list1,list2)
925</pre>
926<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to upper case:</p>
927<pre class="literal-block">
928$(toupper text)
929</pre>
930<p>Fold <tt class="docutils literal"><span class="pre">text</span></tt> to lower case:</p>
931<pre class="literal-block">
932$(tolower text)
933</pre>
934<p>String formatting a la the unix <tt class="docutils literal"><span class="pre">printf</span></tt> command:</p>
935<pre class="literal-block">
936$(printf fmt, arg...)
937</pre>
938<p>Return the length of a string or a (unexpanded) variable:</p>
939<pre class="literal-block">
940$(length string)
941$(length-var var)
942</pre>
943<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.
944Negative <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
945positive ones are one based:</p>
946<pre class="literal-block">
947$(pos needle, haystack[, start])
948$(lastpos needle, haystack[, start])
949</pre>
950<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>.
951If the substring is partially outside the <tt class="docutils literal"><span class="pre">string</span></tt> the result will be
952padded with <tt class="docutils literal"><span class="pre">pad</span></tt> if present:</p>
953<pre class="literal-block">
954$(substr string, start[, length[, pad]])
955</pre>
956<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
957<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>
958<pre class="literal-block">
959$(insert in, str[, n[, length[, pad]]])
960</pre>
961<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>,
962optionally 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
963<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>
964<pre class="literal-block">
965$(translate string, from-set[, to-set[, pad-char]])
966</pre>
967</blockquote>
968<p>Functions for file names:</p>
969<blockquote>
970<p>Extract the directory part of each file <tt class="docutils literal"><span class="pre">name</span></tt>:</p>
971<pre class="literal-block">
972$(dir names...)
973</pre>
974<p>Extract the non-directory part of each file <tt class="docutils literal"><span class="pre">name</span></tt>:</p>
975<pre class="literal-block">
976$(notdir names...)
977</pre>
978<p>Extract the suffix (the last <tt class="docutils literal"><span class="pre">.</span></tt> and following characters) of each file
979<tt class="docutils literal"><span class="pre">name</span></tt>:</p>
980<pre class="literal-block">
981$(suffix names...)
982</pre>
983<p>Extract the base name (name without suffix) of each file name:</p>
984<pre class="literal-block">
985$(basename names...)
986</pre>
987<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>
988<pre class="literal-block">
989$(addsuffix suffix,names...)
990</pre>
991<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>
992<pre class="literal-block">
993$(addprefix prefix,names...)
994</pre>
995<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>
996pattern):</p>
997<pre class="literal-block">
998$(wildcard pattern...)
999</pre>
1000<p>For each file name in <tt class="docutils literal"><span class="pre">names</span></tt>, expand to an absolute name that does not
1001contain any <tt class="docutils literal"><span class="pre">.</span></tt>, <tt class="docutils literal"><span class="pre">..</span></tt>, nor symlinks:</p>
1002<pre class="literal-block">
1003$(realpath names...)
1004</pre>
1005<p>For each file name in <tt class="docutils literal"><span class="pre">names</span></tt>, expand to an absolute name that does not
1006contain 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>
1007<pre class="literal-block">
1008$(abspath names...)
1009</pre>
1010<p>Same as <tt class="docutils literal"><span class="pre">$(abspath</span> <span class="pre">)</span></tt> except that the current directory can be
1011specified as <tt class="docutils literal"><span class="pre">curdir</span></tt>:</p>
1012<pre class="literal-block">
1013$(abspathex names...[, curdir])
1014</pre>
1015</blockquote>
1016<p>Arithmetic Functions:</p>
1017<blockquote>
1018<p>Returns the sum of the arguments:</p>
1019<pre class="literal-block">
1020$(int-add addend1, addend2[, addendN])
1021</pre>
1022<p>Returns the difference between the first argument and the sum of the rest:</p>
1023<pre class="literal-block">
1024$(int-sub minuend, subtrahend[, subtrahendN])
1025</pre>
1026<p>Returns the product of the arguments:</p>
1027<pre class="literal-block">
1028$(int-mul factor1, factor2[, factorN])
1029</pre>
1030<p>Returns the quotient of first argument and the rest:</p>
1031<pre class="literal-block">
1032$(int-div dividend, divisor[, divisorN])
1033</pre>
1034<p>Returns the modulus of the two arguments:</p>
1035<pre class="literal-block">
1036$(int-mod dividend, divisor)
1037</pre>
1038<p>Returns the bitwise two-complement of argument:</p>
1039<pre class="literal-block">
1040$(int-not val)
1041</pre>
1042<p>Returns the result of a bitwise AND of the arguments:</p>
1043<pre class="literal-block">
1044$(int-and val1, val2[, valN])
1045</pre>
1046<p>Returns the result of a bitwise OR of the arguments:</p>
1047<pre class="literal-block">
1048$(int-or val1, val2[, valN])
1049</pre>
1050<p>Returns the result of a bitwise XOR of the arguments:</p>
1051<pre class="literal-block">
1052$(int-xor val1, val2[, valN])
1053</pre>
1054<p>Returns the <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean (true = non-empty, false = empty) result
1055of <tt class="docutils literal"><span class="pre">val1</span> <span class="pre">==</span> <span class="pre">val2</span></tt>:</p>
1056<pre class="literal-block">
1057$(int-eq val1, val2)
1058</pre>
1059<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>
1060<pre class="literal-block">
1061$(int-ne val1, val2)
1062</pre>
1063<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>
1064<pre class="literal-block">
1065$(int-gt val1, val2)
1066</pre>
1067<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>
1068<pre class="literal-block">
1069$(int-ge val1, val2)
1070</pre>
1071<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>
1072<pre class="literal-block">
1073$(int-lt val1, val2)
1074</pre>
1075<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>
1076<pre class="literal-block">
1077$(int-le val1, val2)
1078</pre>
1079</blockquote>
1080<p>Boolean and Conditional Functions:</p>
1081<blockquote>
1082<p>Condition is false if the <tt class="docutils literal"><span class="pre">condition</span></tt> evaluates to an empty string
1083(stripped). Evaluate the <tt class="docutils literal"><span class="pre">true-part</span></tt> if the condition is true, otherwise
1084the <tt class="docutils literal"><span class="pre">false-part</span></tt>:</p>
1085<pre class="literal-block">
1086$(if condition,true-part[,false-part])
1087</pre>
1088<p>Test if any of the conditions evalues to non-empty string, returning the
1089first one:</p>
1090<pre class="literal-block">
1091$(or condition1[,condition2[,condition3[...]]])
1092</pre>
1093<p>Test if all of the conditions evaluates to non-empty strings, returning the
1094last one:</p>
1095<pre class="literal-block">
1096$(and condition1[,condition2[,condition3[...]]])
1097</pre>
1098<p>Test if the two strings are identical, returning <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean (true =
1099non-empty, false = empty):</p>
1100<pre class="literal-block">
1101$(eq str1, str2)
1102</pre>
1103<p>Invert a <tt class="docutils literal"><span class="pre">kmk</span></tt> boolean value:</p>
1104<pre class="literal-block">
1105$(not val)
1106</pre>
1107<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>
1108<pre class="literal-block">
1109$(defined variable)
1110</pre>
1111<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
1112value:</p>
1113<pre class="literal-block">
1114$(intersects set-a, set-b)
1115</pre>
1116<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>
1117<pre class="literal-block">
1118$(if-expr kmk-expression,true-part[,false-part])
1119</pre>
1120<p>Select the first true condition (<tt class="docutils literal"><span class="pre">kmk</span></tt>-expression) and expand the
1121following 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>
1122<pre class="literal-block">
1123$(select when1-cond, when1-body[, whenN-cond, whenN-body])
1124</pre>
1125<p>Evalutate the <tt class="docutils literal"><span class="pre">kmk-expression</span></tt> returning what it evalues as. This is
1126the preferred way of doing arithmentic now:</p>
1127<pre class="literal-block">
1128$(expr kmk-expression)
1129</pre>
1130</blockquote>
1131<p>Stack Fuctions:</p>
1132<blockquote>
1133<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>
1134<pre class="literal-block">
1135$(stack-push stack-var, item)
1136</pre>
1137<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt>:</p>
1138<pre class="literal-block">
1139$(stack-pop stack-var)
1140</pre>
1141<p>Pop the top item off the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string:</p>
1142<pre class="literal-block">
1143$(stack-popv stack-var)
1144</pre>
1145<p>Get the top item of the <tt class="docutils literal"><span class="pre">stack-var</span></tt>, returning the empty string:</p>
1146<pre class="literal-block">
1147$(stack-top stack-var)
1148</pre>
1149</blockquote>
1150<p>Advanced Functions:</p>
1151<blockquote>
1152<p>Evaluates to the contents of the variable <tt class="docutils literal"><span class="pre">var</span></tt>, with no expansion
1153performed on it:</p>
1154<pre class="literal-block">
1155$(value var)
1156</pre>
1157<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
1158concatenate the results (spaced):</p>
1159<pre class="literal-block">
1160$(foreach var,words,body)
1161</pre>
1162<p>C-style for-loop. Start by evaluating <tt class="docutils literal"><span class="pre">init</span></tt>. Each iteration will
1163first 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,
1164then expand <tt class="docutils literal"><span class="pre">body</span></tt> concatenating the result to the previous iterations
1165(spaced), and finally evaluate <tt class="docutils literal"><span class="pre">next</span></tt>:</p>
1166<pre class="literal-block">
1167$(for init,conditions,next,body)
1168</pre>
1169<p>C-style while-loop. Each iteration will check whether the <tt class="docutils literal"><span class="pre">condition</span></tt>
1170(<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
1171result to the previous iterations:</p>
1172<pre class="literal-block">
1173$(while conditions,body)
1174</pre>
1175<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>,
1176<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>
1177<pre class="literal-block">
1178$(call var,param,...)
1179</pre>
1180<p>Evaluate <tt class="docutils literal"><span class="pre">text</span></tt> then read the results as makefile commands. Expands
1181to the empty string:</p>
1182<pre class="literal-block">
1183$(eval text)
1184</pre>
1185<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
1186own variable context:</p>
1187<pre class="literal-block">
1188$(evalctx text)
1189</pre>
1190<p>Same as <tt class="docutils literal"><span class="pre">$(eval</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt>:</p>
1191<pre class="literal-block">
1192$(evalval var)
1193</pre>
1194<p>Same as <tt class="docutils literal"><span class="pre">$(evalctx</span> <span class="pre">$(value</span> <span class="pre">var))</span></tt>:</p>
1195<pre class="literal-block">
1196$(evalvalctx var)
1197</pre>
1198<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>
1199<pre class="literal-block">
1200$(evalcall var)
1201</pre>
1202<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>
1203<pre class="literal-block">
1204$(evalcall var)
1205</pre>
1206<p>Remove comments and blank lines from the variable <tt class="docutils literal"><span class="pre">var</span></tt>. Expands to
1207the empty string:</p>
1208<pre class="literal-block">
1209$(eval-opt-var var)
1210</pre>
1211<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
1212or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1213<pre class="literal-block">
1214$(deps target[, pos])
1215</pre>
1216<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
1217retriving the whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1218<pre class="literal-block">
1219$(deps-all target[, pos])
1220</pre>
1221<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
1222thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1223<pre class="literal-block">
1224$(deps-newer target[, pos])
1225</pre>
1226<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
1227whole thing or the file at <tt class="docutils literal"><span class="pre">pos</span></tt> (one-origin):</p>
1228<pre class="literal-block">
1229$(deps-oo target[, pos])
1230</pre>
1231</blockquote>
1232<p>Command Functions:</p>
1233<blockquote>
1234<p>Create one or more command lines avoiding the max argument
1235length restriction of the host OS:</p>
1236<pre class="literal-block">
1237$(xargs ar cas mylib.a,$(objects))
1238$(xargs ar cas mylib.a,ar as mylib.a,$(objects))
1239</pre>
1240<p>Returns the commands for the specified target separated by new-line, space,
1241or a user defined string. Note that this might not produce the 100% correct
1242result if any of the prerequisite automatic variables are used:</p>
1243<pre class="literal-block">
1244$(commands target)
1245$(commands-sc target)
1246$(commands-usr target,sep)
1247</pre>
1248<p>Compares two commands returning the empty string if equal and the 3rd
1249argument 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
1250line by line is stripped of leading spaces, command prefixes and
1251trailing spaces before comparing:</p>
1252<pre class="literal-block">
1253$(comp-cmds cmds-var1, cmds-var2, ne)
1254$(comp-cmds-ex cmds1, cmd2, ne)
1255</pre>
1256<p>Compares the values of the two variables returning the empty string if
1257equal and the 3rd argument if not. Leading and trailing spaces is ignored:</p>
1258<pre class="literal-block">
1259$(comp-var var1, var2, ne)
1260</pre>
1261</blockquote>
1262<p>Utility functions:</p>
1263<blockquote>
1264<p>When this function is evaluated, <tt class="docutils literal"><span class="pre">kmk</span></tt> generates a fatal error with the
1265message <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
1266<pre class="literal-block">
1267$(error text...)
1268</pre>
1269<p>When this function is evaluated, <tt class="docutils literal"><span class="pre">kmk</span></tt> generates a warning with the
1270message <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
1271<pre class="literal-block">
1272$(warning text...)
1273</pre>
1274<p>When this function is evaluated, <tt class="docutils literal"><span class="pre">kmk</span></tt> generates a info with the
1275message <tt class="docutils literal"><span class="pre">text</span></tt>:</p>
1276<pre class="literal-block">
1277$(info text...)
1278</pre>
1279<p>Execute a shell <tt class="docutils literal"><span class="pre">command</span></tt> and return its output:</p>
1280<pre class="literal-block">
1281$(shell command)
1282</pre>
1283<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>
1284<pre class="literal-block">
1285$(origin variable)
1286</pre>
1287<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>
1288<pre class="literal-block">
1289$(flavor variable)
1290</pre>
1291<p>Returns the current local time and date formatted in the <tt class="docutils literal"><span class="pre">strftime</span></tt>
1292style 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
1293not specified:</p>
1294<pre class="literal-block">
1295$(date fmt)
1296</pre>
1297<p>Returns the current UTC time and date formatted in the <tt class="docutils literal"><span class="pre">strftime</span></tt>
1298style 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
1299not specified:</p>
1300<pre class="literal-block">
1301$(date-utc fmt)
1302</pre>
1303<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
1304to <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
1305<tt class="docutils literal"><span class="pre">%Y-%m-%dT%H:%M:%SZ</span></tt> if not specified:</p>
1306<pre class="literal-block">
1307$(date-utc fmt,time,in-fmt)
1308</pre>
1309<p>Returns the current nanosecond timestamp (monotonic when possible):</p>
1310<pre class="literal-block">
1311$(nanots )
1312</pre>
1313<p>Returns the size of the specified file, or -1 if the size could not
1314be obtained. This can be used to check if a file exist or not:</p>
1315<pre class="literal-block">
1316$(file-size file)
1317</pre>
1318<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>
1319<pre class="literal-block">
1320$(which files...)
1321</pre>
1322<p>OS/2: Returns the specified LIBPATH variable value:</p>
1323<pre class="literal-block">
1324$(libpath var)
1325</pre>
1326<p>OS/2: Sets the specified LIBPATH variable value, returning the empty string:</p>
1327<pre class="literal-block">
1328$(libpath var,value)
1329</pre>
1330</blockquote>
1331<p>Debugging Functions:</p>
1332<blockquote>
1333<p>Returns various make statistics, if no item is specified a default
1334selection is returned:</p>
1335<pre class="literal-block">
1336$(make-stats item[,itemN])
1337</pre>
1338<p>Raise a debug breakpoint. Used for debugging <tt class="docutils literal"><span class="pre">kmk</span></tt> makefile parsing:</p>
1339<pre class="literal-block">
1340$(breakpoint )
1341</pre>
1342</blockquote>
1343<hr class="docutils" />
1344<table class="docutils field-list" frame="void" rules="none">
1345<col class="field-name" />
1346<col class="field-body" />
1347<tbody valign="top">
1348<tr class="field"><th class="field-name">Status:</th><td class="field-body"><p class="first">$Id: QuickReference-kmk.html 2168 2008-12-30 16:52:13Z bird $</p>
1349</td>
1350</tr>
1351<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,
13521996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
13532007 Free Software Foundation, Inc.</p>
1354<p class="last">Copyright (C) 2008 Knut St. Osmundsen</p>
1355</td>
1356</tr>
1357</tbody>
1358</table>
1359</div>
1360</div>
1361</body>
1362</html>
Note: See TracBrowser for help on using the repository browser.