1 |
|
---|
2 | kmk Quick Reference
|
---|
3 | ===================
|
---|
4 |
|
---|
5 | This is an attempt at summarizing all directives, functions, special variables,
|
---|
6 | special targets, built-in commands, external commands, and ``kmk``-expressions.
|
---|
7 | Since *all* the features are included, the quickness of this reference can be
|
---|
8 | disputed. ;-)
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 | Directives
|
---|
13 | ----------
|
---|
14 |
|
---|
15 | Here is a summary of the directives ``kmk`` recognizes:
|
---|
16 |
|
---|
17 | Define a multi-line, recursively-expanded variable::
|
---|
18 |
|
---|
19 | define variable
|
---|
20 | endef
|
---|
21 |
|
---|
22 | Conditionally evaluate part of the makefile::
|
---|
23 |
|
---|
24 | ifdef variable
|
---|
25 | ifndef variable
|
---|
26 | ifeq (a,b)
|
---|
27 | ifeq "a" "b"
|
---|
28 | ifeq 'a' 'b'
|
---|
29 | ifneq (a,b)
|
---|
30 | ifneq "a" "b"
|
---|
31 | ifneq 'a' 'b'
|
---|
32 | if1of (set-a,set-b) [1]
|
---|
33 | ifn1of (set-a,set-b) [1]
|
---|
34 | if expression [1]
|
---|
35 | else
|
---|
36 | endif
|
---|
37 |
|
---|
38 | Include another makefile::
|
---|
39 |
|
---|
40 | include file
|
---|
41 | -include file
|
---|
42 | sinclude file
|
---|
43 |
|
---|
44 | Include another dependency file [1]_::
|
---|
45 |
|
---|
46 | includedep file
|
---|
47 |
|
---|
48 | Define a variable, overriding any previous definition, even one from the
|
---|
49 | command line::
|
---|
50 |
|
---|
51 | override variable = value
|
---|
52 | override variable := value
|
---|
53 | override variable += value
|
---|
54 | override variable <= value [1]
|
---|
55 | override variable ?= value
|
---|
56 | override define variable
|
---|
57 | endef
|
---|
58 |
|
---|
59 | Tell ``kmk`` to export all variables to child processes by default::
|
---|
60 |
|
---|
61 | export
|
---|
62 |
|
---|
63 | Tell ``kmk`` whether or not to export a particular variable to child
|
---|
64 | processes::
|
---|
65 |
|
---|
66 | export variable
|
---|
67 | export variable = value
|
---|
68 | export variable := value
|
---|
69 | export variable += value
|
---|
70 | export variable <= value [1]
|
---|
71 | export variable ?= value
|
---|
72 | unexport variable
|
---|
73 |
|
---|
74 | Define a variable in the local context instead of the global one [1]_::
|
---|
75 |
|
---|
76 | local variable = value
|
---|
77 | local variable := value
|
---|
78 | local variable += value
|
---|
79 | local variable <= value
|
---|
80 | local variable ?= value
|
---|
81 | local define variable
|
---|
82 | endef
|
---|
83 |
|
---|
84 | Specify a search path for files matching a ``%`` pattern::
|
---|
85 |
|
---|
86 | vpath pattern path
|
---|
87 |
|
---|
88 | Remove all search paths previously specified for pattern::
|
---|
89 |
|
---|
90 | vpath pattern
|
---|
91 |
|
---|
92 | Remove all search paths previously specified in any vpath directive::
|
---|
93 |
|
---|
94 | vpath
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 | Automatic variables
|
---|
99 | -------------------
|
---|
100 |
|
---|
101 | Here is a summary of the automatic variables.
|
---|
102 |
|
---|
103 | +-----------+-----------------------------------------------------------------+
|
---|
104 | | Variable | Description |
|
---|
105 | +===========+=================================================================+
|
---|
106 | | ``$@`` | The file name of the target. |
|
---|
107 | +-----------+-----------------------------------------------------------------+
|
---|
108 | | ``$<`` | The name of the first prerequisite. |
|
---|
109 | +-----------+-----------------------------------------------------------------+
|
---|
110 | | ``$?`` | The names of all the prerequisites that are newer than the |
|
---|
111 | | | target, with spaces between them. |
|
---|
112 | +-----------+-----------------------------------------------------------------+
|
---|
113 | | ``$^`` | The names of all the prerequisites, duplicates omitted. |
|
---|
114 | +-----------+-----------------------------------------------------------------+
|
---|
115 | | ``$+`` | The names of all the prerequisites, duplicates and order |
|
---|
116 | | | preserved |
|
---|
117 | +-----------+-----------------------------------------------------------------+
|
---|
118 | | ``$*`` | The stem with which an implicit rule matches. |
|
---|
119 | +-----------+-----------------------------------------------------------------+
|
---|
120 | | ``$|`` | The name of all the order only prerequisites. |
|
---|
121 | +-----------+-----------------------------------------------------------------+
|
---|
122 | | ``$(@D)`` | The directory part of ``$@``. |
|
---|
123 | +-----------+-----------------------------------------------------------------+
|
---|
124 | | ``$(<D)`` | The directory part of ``$<``. |
|
---|
125 | +-----------+-----------------------------------------------------------------+
|
---|
126 | | ``$(?D)`` | The directory part of ``$?``. |
|
---|
127 | +-----------+-----------------------------------------------------------------+
|
---|
128 | | ``$(^D)`` | The directory part of ``%^``. |
|
---|
129 | +-----------+-----------------------------------------------------------------+
|
---|
130 | | ``$(+D)`` | The directory part of ``$+``. |
|
---|
131 | +-----------+-----------------------------------------------------------------+
|
---|
132 | | ``$(*D)`` | The directory part of ``$*``. |
|
---|
133 | +-----------+-----------------------------------------------------------------+
|
---|
134 | | ``$(|D)`` | The directory part of ``$|``. |
|
---|
135 | +-----------+-----------------------------------------------------------------+
|
---|
136 | | ``$(@F)`` | The file-within-directory part of ``$@``. |
|
---|
137 | +-----------+-----------------------------------------------------------------+
|
---|
138 | | ``$(<F)`` | The file-within-directory part of ``$<``. |
|
---|
139 | +-----------+-----------------------------------------------------------------+
|
---|
140 | | ``$(?F)`` | The file-within-directory part of ``$?``. |
|
---|
141 | +-----------+-----------------------------------------------------------------+
|
---|
142 | | ``$(^F)`` | The file-within-directory part of ``$^``. |
|
---|
143 | +-----------+-----------------------------------------------------------------+
|
---|
144 | | ``$(+F)`` | The file-within-directory part of ``$+``. |
|
---|
145 | +-----------+-----------------------------------------------------------------+
|
---|
146 | | ``$(*F)`` | The file-within-directory part of ``$*``. |
|
---|
147 | +-----------+-----------------------------------------------------------------+
|
---|
148 | | ``$(|F)`` | The file-within-directory part of ``$|``. |
|
---|
149 | +-----------+-----------------------------------------------------------------+
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 | Special variables
|
---|
154 | -----------------
|
---|
155 |
|
---|
156 | All variables starting with a ``.`` is reserved by ``kmk``. The following
|
---|
157 | variables are specially used or/and defined by ``kmk``:
|
---|
158 |
|
---|
159 | +--------------------------+--------------------------------------------------+
|
---|
160 | | Variable | Description |
|
---|
161 | +==========================+==================================================+
|
---|
162 | | ``.DEFAULT_GOAL`` | The makefile default goal. You can set this in |
|
---|
163 | | | the makefile, if you don't it will default to |
|
---|
164 | | | the first target that is encountered. |
|
---|
165 | +--------------------------+--------------------------------------------------+
|
---|
166 | | ``.FEATURES`` | List of GNU ``make`` features. Do not set this. |
|
---|
167 | +--------------------------+--------------------------------------------------+
|
---|
168 | | ``.INCLUDE_DIRS`` | List of include directories, ``-I`` arguments |
|
---|
169 | | | and defaults. Do not set this. |
|
---|
170 | +--------------------------+--------------------------------------------------+
|
---|
171 | | ``.RECIPEPREFIX`` | Recipe prefix, defaults to tab. |
|
---|
172 | +--------------------------+--------------------------------------------------+
|
---|
173 | | ``.VARIABLES`` | Special variable which exands to the list of |
|
---|
174 | | | variable. Do not set this. |
|
---|
175 | +--------------------------+--------------------------------------------------+
|
---|
176 | | ``CURDIR`` | Set to the pathname of the current working |
|
---|
177 | | | directory (after all ``-C`` options are |
|
---|
178 | | | processed, if any). Do not set this. |
|
---|
179 | +--------------------------+--------------------------------------------------+
|
---|
180 | | ``KBUILD_VERSION``, | The kBuild version string and the break down |
|
---|
181 | | ``KBUILD_VERSION_MAJOR``,| into individual components. [1]_ |
|
---|
182 | | ``KBUILD_VERSION_MINOR``,| |
|
---|
183 | | ``KBUILD_VERSION_PATCH``,| |
|
---|
184 | | ``KBUILD_KMK_REVISION`` | |
|
---|
185 | +--------------------------+--------------------------------------------------+
|
---|
186 | | ``KBUILD_HOST`` [1]_ | The host operating system. |
|
---|
187 | +--------------------------+--------------------------------------------------+
|
---|
188 | | ``KBUILD_HOST_ARCH`` [1]_| The host architecture. |
|
---|
189 | +--------------------------+--------------------------------------------------+
|
---|
190 | | ``KBUILD_HOST_CPU`` [1]_ | The host CPU ``kmk`` is built for, set to |
|
---|
191 | | | ``blend`` if not any particular CPU. |
|
---|
192 | +--------------------------+--------------------------------------------------+
|
---|
193 | | ``KBUILD_PATH`` [1]_ | Where the kBuild scripts are. |
|
---|
194 | +--------------------------+--------------------------------------------------+
|
---|
195 | | ``KBUILD_BIN_PATH`` [1]_ | Where the host specific kBuild binaries are. |
|
---|
196 | +--------------------------+--------------------------------------------------+
|
---|
197 | | ``KMK`` [1]_, | The name with which ``kmk`` was invoked. Using |
|
---|
198 | | ``MAKE`` | this variable in recipes has special meaning. |
|
---|
199 | +--------------------------+--------------------------------------------------+
|
---|
200 | | ``KMK_BUILTIN`` [1]_ | List of built-in commands. |
|
---|
201 | +--------------------------+--------------------------------------------------+
|
---|
202 | | ``KMK_FEATURES`` [1]_ | List of ``kmk`` specific features. |
|
---|
203 | +--------------------------+--------------------------------------------------+
|
---|
204 | | ``KMK_FLAGS`` [1]_ | The flags given to ``kmk``. You can set this in |
|
---|
205 | | | the environment or a makefile to set flags. |
|
---|
206 | | | |
|
---|
207 | | | It is never appropriate to use ``KMK_FLAGS`` |
|
---|
208 | | | directly in a recipe line: its contents may not |
|
---|
209 | | | be quoted correctly for use in the shell. Always |
|
---|
210 | | | allow recursive ``kmk``'s to obtain these values |
|
---|
211 | | | through the environment from its parent. |
|
---|
212 | +--------------------------+--------------------------------------------------+
|
---|
213 | | ``KMK_LEVEL`` [1]_ | The number of levels of recursion (sub-makes). |
|
---|
214 | +--------------------------+--------------------------------------------------+
|
---|
215 | | ``KMK_VERSION`` [1]_ | The GNU ``make`` version number. |
|
---|
216 | +--------------------------+--------------------------------------------------+
|
---|
217 | | ``MAKECMDGOALS`` | The targets given to ``kmk`` on the command line.|
|
---|
218 | | | Do not set this. |
|
---|
219 | +--------------------------+--------------------------------------------------+
|
---|
220 | | ``MAKEFILES`` | Makefiles to be read on every invocation of |
|
---|
221 | | | ``kmk``. |
|
---|
222 | +--------------------------+--------------------------------------------------+
|
---|
223 | | ``MAKEFILE_LIST`` | List of the makefiles that ``kmk`` has opened. |
|
---|
224 | +--------------------------+--------------------------------------------------+
|
---|
225 | | ``MAKESHELL`` | OS/2 and MS-DOS only, the name of the command |
|
---|
226 | | | interpreter that is to be used by ``kmk``. This |
|
---|
227 | | | value takes precedence over the value of SHELL. |
|
---|
228 | +--------------------------+--------------------------------------------------+
|
---|
229 | | ``SHELL`` | The name of the default command interpreter, |
|
---|
230 | | | kmk_ash. You can set SHELL in the makefile to |
|
---|
231 | | | change the shell used to run recipes. The SHELL |
|
---|
232 | | | variable is handled specially when importing |
|
---|
233 | | | from and exporting to the environment. |
|
---|
234 | +--------------------------+--------------------------------------------------+
|
---|
235 | | ``SUFFIXES`` | The default list of suffixes before ``kmk`` |
|
---|
236 | | | reads any makefiles (always empty). |
|
---|
237 | +--------------------------+--------------------------------------------------+
|
---|
238 | | ``VPATH`` | Directory search path for files not found in the |
|
---|
239 | | | current directory. |
|
---|
240 | +--------------------------+--------------------------------------------------+
|
---|
241 |
|
---|
242 |
|
---|
243 | The following variables reflects ``kmk`` options. Do not set these. [1]_
|
---|
244 |
|
---|
245 | +-------------------------------------+---------------------------------------+
|
---|
246 | | Variable | Description |
|
---|
247 | +=====================================+=======================================+
|
---|
248 | | ``KMK_OPTS_JOBS`` | -j slots, ``0`` if not given. |
|
---|
249 | +-------------------------------------+---------------------------------------+
|
---|
250 | | ``KMK_OPTS_KEEP_GOING`` | -k indictor (``0``/``1``). |
|
---|
251 | +-------------------------------------+---------------------------------------+
|
---|
252 | | ``KMK_OPTS_JUST_PRINT`` | -n indicator (``0``/``1``). |
|
---|
253 | +-------------------------------------+---------------------------------------+
|
---|
254 | | ``KMK_OPTS_PRORITY`` | --priority level, ``0`` if not given. |
|
---|
255 | +-------------------------------------+---------------------------------------+
|
---|
256 | | ``KMK_OPTS_AFFINITY`` | --affinity mask, ``0`` if not given. |
|
---|
257 | +-------------------------------------+---------------------------------------+
|
---|
258 | | ``KMK_OPTS_STATISTICS`` | --statistics indicator (``0``/``1``). |
|
---|
259 | +-------------------------------------+---------------------------------------+
|
---|
260 | | ``KMK_OPTS_PRINT_TIME`` | The --print-time value. |
|
---|
261 | +-------------------------------------+---------------------------------------+
|
---|
262 | | ``KMK_OPTS_PRETTY_COMMAND_PRINTING``| --pretty-command-printing indicator. |
|
---|
263 | +-------------------------------------+---------------------------------------+
|
---|
264 |
|
---|
265 |
|
---|
266 |
|
---|
267 | Special Targets
|
---|
268 | ---------------
|
---|
269 |
|
---|
270 | todo
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|
274 | Commands
|
---|
275 | --------
|
---|
276 |
|
---|
277 | Builtin commands [1]_ all start with ``kmk_builtin_``, so in order to save
|
---|
278 | space this prefix has been omitted in the table below. All commands comes in an
|
---|
279 | external edition that can be used by/in the shell, these are prefixed ``kmk_``.
|
---|
280 |
|
---|
281 | +---------------+-------------------------------------------------------------+
|
---|
282 | | Command | Description |
|
---|
283 | +===============+=============================================================+
|
---|
284 | | ``append`` | Append text to a file. The builtin version can output the |
|
---|
285 | | | value of a variable or the commands of a target. |
|
---|
286 | +---------------+-------------------------------------------------------------+
|
---|
287 | | ``cat`` | The BSD ``cat`` command. |
|
---|
288 | +---------------+-------------------------------------------------------------+
|
---|
289 | | ``chmod`` | The BSD ``chmod`` command. |
|
---|
290 | +---------------+-------------------------------------------------------------+
|
---|
291 | | ``cmp`` | The BSD ``cmp`` command. |
|
---|
292 | +---------------+-------------------------------------------------------------+
|
---|
293 | | ``cp`` | The BSD ``cp`` command with some twaking. |
|
---|
294 | +---------------+-------------------------------------------------------------+
|
---|
295 | | ``echo`` | The BSD ``echo`` command. |
|
---|
296 | +---------------+-------------------------------------------------------------+
|
---|
297 | | ``expr`` | The BSD ``expr`` command. |
|
---|
298 | +---------------+-------------------------------------------------------------+
|
---|
299 | | ``install`` | The BSD ``install`` command with some tweaking. |
|
---|
300 | +---------------+-------------------------------------------------------------+
|
---|
301 | | ``kDepIDB`` | Extract dependencies from a Visual C++ .IDB file. |
|
---|
302 | +---------------+-------------------------------------------------------------+
|
---|
303 | | ``ln`` | The BSD ``ln`` command. |
|
---|
304 | +---------------+-------------------------------------------------------------+
|
---|
305 | | ``md5sum`` | Typical MD5 sum program, custom kBuild version. |
|
---|
306 | +---------------+-------------------------------------------------------------+
|
---|
307 | | ``mkdir`` | The BSD ``mkdir`` command. |
|
---|
308 | +---------------+-------------------------------------------------------------+
|
---|
309 | | ``mv`` | The BSD ``mv`` command with some tweaking. |
|
---|
310 | +---------------+-------------------------------------------------------------+
|
---|
311 | | ``printf`` | The BSD ``printf`` command. |
|
---|
312 | +---------------+-------------------------------------------------------------+
|
---|
313 | | ``rm`` | The BSD ``rm`` command with some tweaking. |
|
---|
314 | +---------------+-------------------------------------------------------------+
|
---|
315 | | ``rmdir`` | The BSD ``rmdir`` command with some tweaking. |
|
---|
316 | +---------------+-------------------------------------------------------------+
|
---|
317 | | ``sleep`` | Typical ``sleep`` program, custom kBuild version. |
|
---|
318 | +---------------+-------------------------------------------------------------+
|
---|
319 | | ``test`` | The BSD ``test`` program with some tweaking. |
|
---|
320 | +---------------+-------------------------------------------------------------+
|
---|
321 |
|
---|
322 | Some additional external commands are available in the ``kmk`` / ``kBuild``
|
---|
323 | environment (``kSomething`` command are not prefixed with ``kmk_``):
|
---|
324 |
|
---|
325 | +---------------+-------------------------------------------------------------+
|
---|
326 | | Command | Description |
|
---|
327 | +===============+=============================================================+
|
---|
328 | | ``kDepPre`` | Extract dependencies from the C/C++ preprocessor output. |
|
---|
329 | +---------------+-------------------------------------------------------------+
|
---|
330 | | ``kObjCache`` | Simple object file cache program. |
|
---|
331 | +---------------+-------------------------------------------------------------+
|
---|
332 | | ``ash`` | Almquist's shell (NetBSD variant). |
|
---|
333 | +---------------+-------------------------------------------------------------+
|
---|
334 | | ``gmake`` | Vanilla GNU ``make`` from same sources as ``kmk``. |
|
---|
335 | +---------------+-------------------------------------------------------------+
|
---|
336 | | ``redirect`` | Shell avoidance tool. Sets up file descriptors, environment |
|
---|
337 | | | variables and current directory before kicking of program. |
|
---|
338 | +---------------+-------------------------------------------------------------+
|
---|
339 | | ``sed`` | GNU ``sed`` with some tweaks to avoid involving the shell. |
|
---|
340 | +---------------+-------------------------------------------------------------+
|
---|
341 | | ``time`` | Stopwatch utility for measuring program execution time(s). |
|
---|
342 | +---------------+-------------------------------------------------------------+
|
---|
343 |
|
---|
344 |
|
---|
345 |
|
---|
346 | kmk-expression
|
---|
347 | --------------
|
---|
348 |
|
---|
349 | ``kmk``-expressions [1]_ are related to the C/C++ preprocessor in some ways as
|
---|
350 | well as ``nmake`` and BSD ``make``. There are however some peculiarities
|
---|
351 | because of the way GNU ``make`` choose to represent booleans in its function
|
---|
352 | library, so, strings can be turned into boolean by taking any non-empty string
|
---|
353 | as true.
|
---|
354 |
|
---|
355 | Quoting using single quotes results in hard strings, while double quotes and
|
---|
356 | unquoted string results in soft strings that can be converted to number or
|
---|
357 | boolean to fit the situation.
|
---|
358 |
|
---|
359 | Here's the operator table in decending precedence order:
|
---|
360 |
|
---|
361 | +---------------+--------+-----------------------------------------------------+
|
---|
362 | | Operator | Type | Description |
|
---|
363 | +===============+========+=====================================================+
|
---|
364 | | ``defined`` | Unary | Checks if the following variable exists. |
|
---|
365 | +---------------+ +-----------------------------------------------------+
|
---|
366 | | ``exists`` | | Checks if the following file exists. |
|
---|
367 | +---------------+ +-----------------------------------------------------+
|
---|
368 | | ``target`` | | Checks if the following target exists. |
|
---|
369 | +---------------+ +-----------------------------------------------------+
|
---|
370 | | ``bool`` | | Casts the following value to boolean. |
|
---|
371 | +---------------+ +-----------------------------------------------------+
|
---|
372 | | ``num`` | | Casts the following value to a number. |
|
---|
373 | +---------------+ +-----------------------------------------------------+
|
---|
374 | | ``str`` | | Casts the following value to a string. |
|
---|
375 | +---------------+--------+-----------------------------------------------------+
|
---|
376 | | ``!`` | Unary | Logical NOT. |
|
---|
377 | +---------------+ +-----------------------------------------------------+
|
---|
378 | | ``+`` | | Pluss prefix. |
|
---|
379 | +---------------+ +-----------------------------------------------------+
|
---|
380 | | ``-`` | | Minus prefix. |
|
---|
381 | +---------------+ +-----------------------------------------------------+
|
---|
382 | | ``~`` | | Bitwise one's complement. |
|
---|
383 | +---------------+--------+-----------------------------------------------------+
|
---|
384 | | ``*`` | Binary | Multiplication (product). |
|
---|
385 | +---------------+ +-----------------------------------------------------+
|
---|
386 | | ``/`` | | Division (quotient). |
|
---|
387 | +---------------+ +-----------------------------------------------------+
|
---|
388 | | ``%`` | | Modulus (remainder). |
|
---|
389 | +---------------+--------+-----------------------------------------------------+
|
---|
390 | | ``+`` | Binary | Addition (sum). |
|
---|
391 | +---------------+ +-----------------------------------------------------+
|
---|
392 | | ``-`` | | Subtraction (difference). |
|
---|
393 | +---------------+--------+-----------------------------------------------------+
|
---|
394 | | ``<<`` | Binary | Bitwise left shift. |
|
---|
395 | +---------------+ +-----------------------------------------------------+
|
---|
396 | | ``>>`` | | Bitwise right shift. |
|
---|
397 | +---------------+--------+-----------------------------------------------------+
|
---|
398 | | ``<=`` | Binary | Less or equal than. |
|
---|
399 | +---------------+ +-----------------------------------------------------+
|
---|
400 | | ``<`` | | Less than. |
|
---|
401 | +---------------+ +-----------------------------------------------------+
|
---|
402 | | ``>=`` | | Greater or equal than. |
|
---|
403 | +---------------+ +-----------------------------------------------------+
|
---|
404 | | ``>`` | | Greater than. |
|
---|
405 | +---------------+--------+-----------------------------------------------------+
|
---|
406 | | ``==`` | Binary | Equal to. |
|
---|
407 | +---------------+ +-----------------------------------------------------+
|
---|
408 | | ``!=`` | | Not equal to. |
|
---|
409 | +---------------+--------+-----------------------------------------------------+
|
---|
410 | | ``&`` | Binary | Bitwise AND. |
|
---|
411 | +---------------+--------+-----------------------------------------------------+
|
---|
412 | | ``^`` | Binary | Bitwise XOR. |
|
---|
413 | +---------------+--------+-----------------------------------------------------+
|
---|
414 | | ``|`` | Binary | Bitwise OR. |
|
---|
415 | +---------------+--------+-----------------------------------------------------+
|
---|
416 | | ``&&`` | Binary | Logical AND. |
|
---|
417 | +---------------+--------+-----------------------------------------------------+
|
---|
418 | | ``||`` | Binary | Logical OR. |
|
---|
419 | +---------------+--------+-----------------------------------------------------+
|
---|
420 |
|
---|
421 |
|
---|
422 |
|
---|
423 | Built-in functions
|
---|
424 | ------------------
|
---|
425 |
|
---|
426 |
|
---|
427 | String Manipulation Functions:
|
---|
428 |
|
---|
429 | Replace ``from`` with ``to`` in ``text``::
|
---|
430 |
|
---|
431 | $(subst from,to,text)
|
---|
432 |
|
---|
433 | Replace words matching ``pattern`` with ``replacement`` in ``text``::
|
---|
434 |
|
---|
435 | $(patsubst pattern,replacement,text)
|
---|
436 |
|
---|
437 | Remove excess whitespace characters from ``string``::
|
---|
438 |
|
---|
439 | $(strip string)
|
---|
440 |
|
---|
441 | Locate ``find`` in ``text``, returning ``find`` if found::
|
---|
442 |
|
---|
443 | $(findstring find,text)
|
---|
444 |
|
---|
445 | Select words in ``text`` that match one of the ``pattern`` words::
|
---|
446 |
|
---|
447 | $(filter pattern...,text)
|
---|
448 |
|
---|
449 | Select words in ``text`` that do not match any of the ``pattern`` words::
|
---|
450 |
|
---|
451 | $(filter-out pattern...,text)
|
---|
452 |
|
---|
453 | Sort the words in ``list`` lexicographically, removing duplicates::
|
---|
454 |
|
---|
455 | $(sort list)
|
---|
456 |
|
---|
457 | Sort the words in ``list`` lexicographically in reserve order, removing
|
---|
458 | duplicates [1]_::
|
---|
459 |
|
---|
460 | $(rsort list)
|
---|
461 |
|
---|
462 | Count the number of words in ``text``::
|
---|
463 |
|
---|
464 | $(words text)
|
---|
465 |
|
---|
466 | Extract the ``n``\th word (one-origin) of ``text``::
|
---|
467 |
|
---|
468 | $(word n,text)
|
---|
469 |
|
---|
470 | Returns the list of words in ``text`` from ``s`` to ``e`` (one-origin)::
|
---|
471 |
|
---|
472 | $(wordlist s,e,text)
|
---|
473 |
|
---|
474 | Extract the first word of ``names``::
|
---|
475 |
|
---|
476 | $(firstword names...)
|
---|
477 |
|
---|
478 | Extract the last word of ``names``::
|
---|
479 |
|
---|
480 | $(lastword names...)
|
---|
481 |
|
---|
482 | Join two parallel lists of words::
|
---|
483 |
|
---|
484 | $(join list1,list2)
|
---|
485 |
|
---|
486 | Fold ``text`` to upper case [1]_::
|
---|
487 |
|
---|
488 | $(toupper text)
|
---|
489 |
|
---|
490 | Fold ``text`` to lower case [1]_::
|
---|
491 |
|
---|
492 | $(tolower text)
|
---|
493 |
|
---|
494 | String formatting a la the unix ``printf`` command [1]_::
|
---|
495 |
|
---|
496 | $(printf fmt, arg...)
|
---|
497 |
|
---|
498 | Return the length of a string or a (unexpanded) variable [1]_::
|
---|
499 |
|
---|
500 | $(length string)
|
---|
501 | $(length-var var)
|
---|
502 |
|
---|
503 | Find the position of ``needle`` in ``haystack``, returns 0 if not found.
|
---|
504 | Negative ``start`` indices are relative to the end of ``haystack``, while
|
---|
505 | positive ones are one based [1]_::
|
---|
506 |
|
---|
507 | $(pos needle, haystack[, start])
|
---|
508 | $(lastpos needle, haystack[, start])
|
---|
509 |
|
---|
510 | Returns the specified substring. The ``start`` works like with ``$(pos )``.
|
---|
511 | If the substring is partially outside the ``string`` the result will be
|
---|
512 | padded with ``pad`` if present [1]_::
|
---|
513 |
|
---|
514 | $(substr string, start[, length[, pad]])
|
---|
515 |
|
---|
516 | Insert ``in`` into ``str`` at the specified position. ``n`` works like with
|
---|
517 | ``$(pos )``, except that ``0`` is the end of the string [1]_::
|
---|
518 |
|
---|
519 | $(insert in, str[, n[, length[, pad]]])
|
---|
520 |
|
---|
521 | Translate ``string`` exchanging characters in ``from-set`` with ``to-set``,
|
---|
522 | optionally completing ``to-set`` with ``pad-char`` if specified. If no
|
---|
523 | ``pad-char`` characters absent in ``to-set`` will be deleted [1]_::
|
---|
524 |
|
---|
525 | $(translate string, from-set[, to-set[, pad-char]])
|
---|
526 |
|
---|
527 |
|
---|
528 | Functions for file names:
|
---|
529 |
|
---|
530 | Extract the directory part of each file ``name``::
|
---|
531 |
|
---|
532 | $(dir names...)
|
---|
533 |
|
---|
534 | Extract the non-directory part of each file ``name``::
|
---|
535 |
|
---|
536 | $(notdir names...)
|
---|
537 |
|
---|
538 | Extract the suffix (the last ``.`` and following characters) of each file
|
---|
539 | ``name``::
|
---|
540 |
|
---|
541 | $(suffix names...)
|
---|
542 |
|
---|
543 | Extract the base name (name without suffix) of each file name::
|
---|
544 |
|
---|
545 | $(basename names...)
|
---|
546 |
|
---|
547 | Append ``suffix`` to each word in ``names``::
|
---|
548 |
|
---|
549 | $(addsuffix suffix,names...)
|
---|
550 |
|
---|
551 | Prepend ``prefix`` to each word in ``names``::
|
---|
552 |
|
---|
553 | $(addprefix prefix,names...)
|
---|
554 |
|
---|
555 | Find file names matching a shell file name ``pattern`` (not a ``%``
|
---|
556 | pattern)::
|
---|
557 |
|
---|
558 | $(wildcard pattern...)
|
---|
559 |
|
---|
560 | For each file name in ``names``, expand to an absolute name that does not
|
---|
561 | contain any ``.``, ``..``, nor symlinks::
|
---|
562 |
|
---|
563 | $(realpath names...)
|
---|
564 |
|
---|
565 | For each file name in ``names``, expand to an absolute name that does not
|
---|
566 | contain any ``.`` or ``..`` components, but preserves symlinks::
|
---|
567 |
|
---|
568 | $(abspath names...)
|
---|
569 |
|
---|
570 | Same as ``$(abspath )`` except that the current directory can be
|
---|
571 | specified as ``curdir`` [1]_::
|
---|
572 |
|
---|
573 | $(abspathex names...[, curdir])
|
---|
574 |
|
---|
575 |
|
---|
576 | Arithmetic Functions:
|
---|
577 |
|
---|
578 | Returns the sum of the arguments [1]_::
|
---|
579 |
|
---|
580 | $(int-add addend1, addend2[, addendN])
|
---|
581 |
|
---|
582 | Returns the difference between the first argument and the sum of the
|
---|
583 | rest [1]_::
|
---|
584 |
|
---|
585 | $(int-sub minuend, subtrahend[, subtrahendN])
|
---|
586 |
|
---|
587 | Returns the product of the arguments [1]_::
|
---|
588 |
|
---|
589 | $(int-mul factor1, factor2[, factorN])
|
---|
590 |
|
---|
591 | Returns the quotient of first argument and the rest [1]_::
|
---|
592 |
|
---|
593 | $(int-div dividend, divisor[, divisorN])
|
---|
594 |
|
---|
595 | Returns the modulus of the two arguments [1]_::
|
---|
596 |
|
---|
597 | $(int-mod dividend, divisor)
|
---|
598 |
|
---|
599 | Returns the bitwise two-complement of argument [1]_::
|
---|
600 |
|
---|
601 | $(int-not val)
|
---|
602 |
|
---|
603 | Returns the result of a bitwise AND of the arguments [1]_::
|
---|
604 |
|
---|
605 | $(int-and val1, val2[, valN])
|
---|
606 |
|
---|
607 | Returns the result of a bitwise OR of the arguments [1]_::
|
---|
608 |
|
---|
609 | $(int-or val1, val2[, valN])
|
---|
610 |
|
---|
611 | Returns the result of a bitwise XOR of the arguments [1]_::
|
---|
612 |
|
---|
613 | $(int-xor val1, val2[, valN])
|
---|
614 |
|
---|
615 | Returns the ``kmk`` boolean (true = non-empty, false = empty) result
|
---|
616 | of ``val1 == val2`` [1]_::
|
---|
617 |
|
---|
618 | $(int-eq val1, val2)
|
---|
619 |
|
---|
620 | Returns the ``kmk`` boolean result of ``val1 != val2`` [1]_::
|
---|
621 |
|
---|
622 | $(int-ne val1, val2)
|
---|
623 |
|
---|
624 | Returns the ``kmk`` boolean result of ``val1 > val2`` [1]_::
|
---|
625 |
|
---|
626 | $(int-gt val1, val2)
|
---|
627 |
|
---|
628 | Returns the ``kmk`` boolean result of ``val1 >= val2`` [1]_::
|
---|
629 |
|
---|
630 | $(int-ge val1, val2)
|
---|
631 |
|
---|
632 | Returns the ``kmk`` boolean result of ``val1 < val2`` [1]_::
|
---|
633 |
|
---|
634 | $(int-lt val1, val2)
|
---|
635 |
|
---|
636 | Returns the ``kmk`` boolean result of ``val1 <= val2`` [1]_::
|
---|
637 |
|
---|
638 | $(int-le val1, val2)
|
---|
639 |
|
---|
640 |
|
---|
641 | Boolean and Conditional Functions:
|
---|
642 |
|
---|
643 | Condition is false if the ``condition`` evaluates to an empty string
|
---|
644 | (stripped). Evaluate the ``true-part`` if the condition is true, otherwise
|
---|
645 | the ``false-part``::
|
---|
646 |
|
---|
647 | $(if condition,true-part[,false-part])
|
---|
648 |
|
---|
649 | Test if any of the conditions evalues to non-empty string, returning the
|
---|
650 | first one::
|
---|
651 |
|
---|
652 | $(or condition1[,condition2[,condition3[...]]])
|
---|
653 |
|
---|
654 | Test if all of the conditions evaluates to non-empty strings, returning the
|
---|
655 | last one::
|
---|
656 |
|
---|
657 | $(and condition1[,condition2[,condition3[...]]])
|
---|
658 |
|
---|
659 |
|
---|
660 | Test if the two strings are identical, returning ``kmk`` boolean (true =
|
---|
661 | non-empty, false = empty) [2]_::
|
---|
662 |
|
---|
663 | $(eq str1, str2)
|
---|
664 |
|
---|
665 | Invert a ``kmk`` boolean value [2]_::
|
---|
666 |
|
---|
667 | $(not val)
|
---|
668 |
|
---|
669 | Test if ``variable`` is defined, returning a ``kmk`` boolean value [1]_::
|
---|
670 |
|
---|
671 | $(defined variable)
|
---|
672 |
|
---|
673 | Test if ``set-a`` and ``set-b`` intersects, returning a ``kmk`` boolean
|
---|
674 | value [1]_::
|
---|
675 |
|
---|
676 | $(intersects set-a, set-b)
|
---|
677 |
|
---|
678 | Same as ``$(if )`` execpt that the condition is a ``kmk``-expression [1]_::
|
---|
679 |
|
---|
680 | $(if-expr kmk-expression,true-part[,false-part])
|
---|
681 |
|
---|
682 | Select the first true condition (``kmk``-expression) and expand the
|
---|
683 | following body. Special condition strings ``default`` and
|
---|
684 | ``otherwise`` [1]_::
|
---|
685 |
|
---|
686 | $(select when1-cond, when1-body[, whenN-cond, whenN-body])
|
---|
687 |
|
---|
688 | Evalutate the ``kmk-expression`` returning what it evalues as. This is
|
---|
689 | the preferred way of doing arithmentic now [1]_::
|
---|
690 |
|
---|
691 | $(expr kmk-expression)
|
---|
692 |
|
---|
693 |
|
---|
694 | Stack Fuctions:
|
---|
695 |
|
---|
696 | Push ``item`` onto the ``stack-var``, returning the empty string [1]_::
|
---|
697 |
|
---|
698 | $(stack-push stack-var, item)
|
---|
699 |
|
---|
700 | Pop the top item off the ``stack-var`` [1]_::
|
---|
701 |
|
---|
702 | $(stack-pop stack-var)
|
---|
703 |
|
---|
704 | Pop the top item off the ``stack-var``, returning the empty string [1]_::
|
---|
705 |
|
---|
706 | $(stack-popv stack-var)
|
---|
707 |
|
---|
708 | Get the top item of the ``stack-var``, returning the empty string [1]_::
|
---|
709 |
|
---|
710 | $(stack-top stack-var)
|
---|
711 |
|
---|
712 |
|
---|
713 | Advanced Functions:
|
---|
714 |
|
---|
715 | Evaluates to the contents of the variable ``var``, with no expansion
|
---|
716 | performed on it::
|
---|
717 |
|
---|
718 | $(value var)
|
---|
719 |
|
---|
720 | Evaluate ``body`` with ``var`` bound to each word in ``words``, and
|
---|
721 | concatenate the results (spaced)::
|
---|
722 |
|
---|
723 | $(foreach var,words,body)
|
---|
724 |
|
---|
725 | C-style for-loop. Start by evaluating ``init``. Each iteration will
|
---|
726 | first check whether the ``condition`` (``kmk``-expression) is true,
|
---|
727 | then expand ``body`` concatenating the result to the previous iterations
|
---|
728 | (spaced), and finally evaluate ``next`` [1]_::
|
---|
729 |
|
---|
730 | $(for init,conditions,next,body)
|
---|
731 |
|
---|
732 | C-style while-loop. Each iteration will check whether the ``condition``
|
---|
733 | (``kmk``-expression) is true, then expand ``body`` concatenating the
|
---|
734 | result to the previous iterations [1]_::
|
---|
735 |
|
---|
736 | $(while conditions,body)
|
---|
737 |
|
---|
738 | Evaluate the variable ``var`` replacing any references to ``$(1)``,
|
---|
739 | ``$(2)`` with the first, second, etc. ``param`` values::
|
---|
740 |
|
---|
741 | $(call var,param,...)
|
---|
742 |
|
---|
743 | Evaluate ``text`` then read the results as makefile commands. Expands
|
---|
744 | to the empty string::
|
---|
745 |
|
---|
746 | $(eval text)
|
---|
747 |
|
---|
748 | Same as ``$(eval text)`` except that the ``text`` is expanded in its
|
---|
749 | own variable context [1]_::
|
---|
750 |
|
---|
751 | $(evalctx text)
|
---|
752 |
|
---|
753 | Same as ``$(eval $(value var))`` [1]_::
|
---|
754 |
|
---|
755 | $(evalval var)
|
---|
756 |
|
---|
757 | Same as ``$(evalctx $(value var))`` [1]_::
|
---|
758 |
|
---|
759 | $(evalvalctx var)
|
---|
760 |
|
---|
761 | A combination of ``$(eval )``, ``$(call )`` and ``$(value )`` [1]_::
|
---|
762 |
|
---|
763 | $(evalcall var)
|
---|
764 |
|
---|
765 | A combination of ``$(eval )`` and ``$(call )`` [1]_::
|
---|
766 |
|
---|
767 | $(evalcall var)
|
---|
768 |
|
---|
769 | Remove comments and blank lines from the variable ``var``. Expands to
|
---|
770 | the empty string [1]_::
|
---|
771 |
|
---|
772 | $(eval-opt-var var)
|
---|
773 |
|
---|
774 | Returns accessing ``$<`` of ``target``, either retriving the whole thing
|
---|
775 | or the file at ``pos`` (one-origin) [1]_::
|
---|
776 |
|
---|
777 | $(deps target[, pos])
|
---|
778 |
|
---|
779 | Returns accessing ``$+`` (order + duplicates) of ``target``, either
|
---|
780 | retriving the whole thing or the file at ``pos`` (one-origin) [1]_::
|
---|
781 |
|
---|
782 | $(deps-all target[, pos])
|
---|
783 |
|
---|
784 | Returns accessing ``$?`` of ``target``, either retriving the whole
|
---|
785 | thing or the file at ``pos`` (one-origin) [1]_::
|
---|
786 |
|
---|
787 | $(deps-newer target[, pos])
|
---|
788 |
|
---|
789 | Returns accessing ``$|`` (order only) of ``target``, either retriving the
|
---|
790 | whole thing or the file at ``pos`` (one-origin) [1]_::
|
---|
791 |
|
---|
792 | $(deps-oo target[, pos])
|
---|
793 |
|
---|
794 |
|
---|
795 | Command Functions:
|
---|
796 |
|
---|
797 | Create one or more command lines avoiding the max argument
|
---|
798 | length restriction of the host OS [1]_::
|
---|
799 |
|
---|
800 | $(xargs ar cas mylib.a,$(objects))
|
---|
801 | $(xargs ar cas mylib.a,ar as mylib.a,$(objects))
|
---|
802 |
|
---|
803 |
|
---|
804 | Returns the commands for the specified target separated by new-line, space,
|
---|
805 | or a user defined string. Note that this might not produce the 100% correct
|
---|
806 | result if any of the prerequisite automatic variables are used [1]_::
|
---|
807 |
|
---|
808 | $(commands target)
|
---|
809 | $(commands-sc target)
|
---|
810 | $(commands-usr target,sep)
|
---|
811 |
|
---|
812 | Compares two commands returning the empty string if equal and the 3rd
|
---|
813 | argument if not. This differs from ``$(comp-vars v1,v2,ne)`` in that
|
---|
814 | line by line is stripped of leading spaces, command prefixes and
|
---|
815 | trailing spaces before comparing [1]_::
|
---|
816 |
|
---|
817 | $(comp-cmds cmds-var1, cmds-var2, ne)
|
---|
818 | $(comp-cmds-ex cmds1, cmd2, ne)
|
---|
819 |
|
---|
820 |
|
---|
821 | Compares the values of the two variables returning the empty string if
|
---|
822 | equal and the 3rd argument if not. Leading and trailing spaces is
|
---|
823 | ignored [1]_::
|
---|
824 |
|
---|
825 | $(comp-var var1, var2, ne)
|
---|
826 |
|
---|
827 |
|
---|
828 | Utility functions:
|
---|
829 |
|
---|
830 | When this function is evaluated, ``kmk`` generates a fatal error with the
|
---|
831 | message ``text``::
|
---|
832 |
|
---|
833 | $(error text...)
|
---|
834 |
|
---|
835 | When this function is evaluated, ``kmk`` generates a warning with the
|
---|
836 | message ``text``::
|
---|
837 |
|
---|
838 | $(warning text...)
|
---|
839 |
|
---|
840 | When this function is evaluated, ``kmk`` generates a info with the
|
---|
841 | message ``text``::
|
---|
842 |
|
---|
843 | $(info text...)
|
---|
844 |
|
---|
845 | Execute a shell ``command`` and return its output::
|
---|
846 |
|
---|
847 | $(shell command)
|
---|
848 |
|
---|
849 | Return a string describing how the ``kmk`` variable ``variable`` was defined::
|
---|
850 |
|
---|
851 | $(origin variable)
|
---|
852 |
|
---|
853 | Return a string describing the flavor of the ``kmk`` variable ``variable``::
|
---|
854 |
|
---|
855 | $(flavor variable)
|
---|
856 |
|
---|
857 | Returns the current local time and date formatted in the ``strftime``
|
---|
858 | style specifier ``fmt``. ``fmt`` defaults to ``%Y-%m-%dT%H:%M:%S`` when
|
---|
859 | not specified [1]_::
|
---|
860 |
|
---|
861 | $(date fmt)
|
---|
862 |
|
---|
863 | Returns the current UTC time and date formatted in the ``strftime``
|
---|
864 | style specifier ``fmt``. ``fmt`` defaults to ``%Y-%m-%dT%H:%M:%SZ`` when
|
---|
865 | not specified [1]_::
|
---|
866 |
|
---|
867 | $(date-utc fmt)
|
---|
868 |
|
---|
869 | Reformats the ``in`` time and date using ``fmt``. The ``in-fmt`` defaults
|
---|
870 | to ``fmt`` if not specified. While ``fmt`` defaults to
|
---|
871 | ``%Y-%m-%dT%H:%M:%SZ`` if not specified [1]_::
|
---|
872 |
|
---|
873 | $(date-utc fmt,time,in-fmt)
|
---|
874 |
|
---|
875 | Returns the current nanosecond timestamp (monotonic when possible) [1]_::
|
---|
876 |
|
---|
877 | $(nanots )
|
---|
878 |
|
---|
879 | Returns the size of the specified file, or -1 if the size could not
|
---|
880 | be obtained. This can be used to check if a file exist or not [1]_::
|
---|
881 |
|
---|
882 | $(file-size file)
|
---|
883 |
|
---|
884 | Searches the ``PATH`` ``kmk`` variable for the specified ``files`` [1]_::
|
---|
885 |
|
---|
886 | $(which files...)
|
---|
887 |
|
---|
888 | OS/2: Returns the specified LIBPATH variable value [1]_::
|
---|
889 |
|
---|
890 | $(libpath var)
|
---|
891 |
|
---|
892 | OS/2: Sets the specified LIBPATH variable value, returning the empty
|
---|
893 | string [1]_::
|
---|
894 |
|
---|
895 | $(libpath var,value)
|
---|
896 |
|
---|
897 |
|
---|
898 | Debugging Functions:
|
---|
899 |
|
---|
900 | Returns various make statistics, if no item is specified a default
|
---|
901 | selection is returned [1]_::
|
---|
902 |
|
---|
903 | $(make-stats item[,itemN])
|
---|
904 |
|
---|
905 | Raise a debug breakpoint. Used for debugging ``kmk`` makefile
|
---|
906 | parsing [1]_::
|
---|
907 |
|
---|
908 | $(breakpoint )
|
---|
909 |
|
---|
910 |
|
---|
911 | -----
|
---|
912 |
|
---|
913 | .. [1] ``kmk`` only feature.
|
---|
914 | .. [2] Experimental GNU ``make`` feature that is not enabled by default.
|
---|
915 |
|
---|
916 | -----
|
---|
917 |
|
---|
918 | :Status: $Id: QuickReference-kmk.txt 2170 2008-12-30 20:39:35Z bird $
|
---|
919 | :Copyright: Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
---|
920 | 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
---|
921 | 2007 Free Software Foundation, Inc.
|
---|
922 |
|
---|
923 | Copyright (C) 2008 Knut St. Osmundsen
|
---|