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
15 Here is a summary of the directives ``kmk`` recognizes:
17 Define a multi-line, recursively-expanded variable::
22 Conditionally evaluate part of the makefile::
32 if1of (set-a,set-b) [1]
33 ifn1of (set-a,set-b) [1]
38 Include another makefile::
44 Include another dependency file [1]_::
48 Define a variable, overriding any previous definition, even one from the
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
59 Tell ``kmk`` to export all variables to child processes by default::
63 Tell ``kmk`` whether or not to export a particular variable to child
67 export variable = value
68 export variable := value
69 export variable += value
70 export variable <= value [1]
71 export variable ?= value
74 Define a variable in the local context instead of the global one [1]_::
76 local variable = value
77 local variable := value
78 local variable += value
79 local variable <= value
80 local variable ?= value
84 Specify a search path for files matching a ``%`` pattern::
88 Remove all search paths previously specified for pattern::
92 Remove all search paths previously specified in any vpath directive::
101 Here is a summary of the automatic variables.
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 |
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 +-----------+-----------------------------------------------------------------+
156 All variables starting with a ``.`` is reserved by ``kmk``. The following
157 variables are specially used or/and defined by ``kmk``:
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. |
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 |
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 +--------------------------+--------------------------------------------------+
243 The following variables reflects ``kmk`` options. Do not set these. [1]_
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 +-------------------------------------+---------------------------------------+
270 Certain names have special meanings if they appear as targets.
272 +-------------------------------+---------------------------------------------+
273 | Target | Description |
274 +===============================+=============================================+
275 | ``.DEFAULT`` | The recipe is used for any target for which |
276 | | no rules are found. |
277 +-------------------------------+---------------------------------------------+
278 | ``.DELETE_ON_ERROR`` | If mentioned, ``kmk`` will delete the |
279 | | targets of a rule if it has changed and its |
280 | | recipe fails or is interrupted. |
281 +-------------------------------+---------------------------------------------+
282 | ``.EXPORT_ALL_VARIABLES`` | If mentioned, all variables will by default |
283 | | be exported to child processes. |
284 +-------------------------------+---------------------------------------------+
285 | ``.IGNORE`` | Ignore errors in the execution of the recipe|
286 | | for the targets ``.IGNORE`` depends on, if |
287 | | no prequisites all targets are affected. |
288 +-------------------------------+---------------------------------------------+
289 | ``.INTERMEDIATE`` | The prerequisites are treated as |
290 | | intermediate files (implicite rules). |
291 +-------------------------------+---------------------------------------------+
292 | ``.LOW_RESOLUTION_TIME`` | ``kmk`` will assume prerequisite files are |
293 | | created with low resolution time stamps. |
294 +-------------------------------+---------------------------------------------+
295 | ``.NOTPARALLEL`` | If mentioned without any prerequisites, |
296 | | ``kmk`` will run serially as if -j1 was |
297 | | given. If it has prerequisites ``kmk`` [1]_ |
298 | | will only do this for the targets among |
300 +-------------------------------+---------------------------------------------+
301 | ``.PHONY`` | The prerequisites are considered phony and |
302 | | will be rebuilt unconditionally. |
303 +-------------------------------+---------------------------------------------+
304 | ``.PRECIOUS`` | The targets which ``.PRECIOUS`` depends |
305 | | will to be deleted if ``kmk`` is killed or |
306 | | interrupted while their building. |
307 +-------------------------------+---------------------------------------------+
308 | ``.SECONDARY`` | The prerequisites are treated as |
309 | | intermediate files, except that they are |
310 | | never automatically deleted. If used with |
311 | | no prerequisites all targets gets this |
313 +-------------------------------+---------------------------------------------+
314 | ``.SECONDEXPANSION`` | If mentioned, all prerequisite lists after |
315 | | it will be expanded a second time after all |
316 | | makefiles have been read. |
317 +-------------------------------+---------------------------------------------+
318 | ``.SECONDTARGETEXPANSION`` | If mentioned, all targets after it will be |
319 | [1]_ | expanded a second time after all makefiles |
320 | | have been read. |
321 +-------------------------------+---------------------------------------------+
322 | ``.SILENT`` | ``kmk`` will not print the recipe for |
323 | | targets listed as prerequisites, if none |
324 | | then it applies to all targets. |
325 +-------------------------------+---------------------------------------------+
326 | ``.SUFFIXES`` | The prerequisites are the list of suffixes |
327 | | used in checking for suffix rules. If it |
328 | | appears without prerequisites it the suffix |
329 | | will be cleared. |
330 +-------------------------------+---------------------------------------------+
337 Builtin commands [1]_ all start with ``kmk_builtin_``, so in order to save
338 space this prefix has been omitted in the table below. All commands comes in an
339 external edition that can be used by/in the shell, these are prefixed ``kmk_``.
341 +---------------+-------------------------------------------------------------+
342 | Command | Description |
343 +===============+=============================================================+
344 | ``append`` | Append text to a file. The builtin version can output the |
345 | | value of a variable or the commands of a target. |
346 +---------------+-------------------------------------------------------------+
347 | ``cat`` | The BSD ``cat`` command. |
348 +---------------+-------------------------------------------------------------+
349 | ``chmod`` | The BSD ``chmod`` command. |
350 +---------------+-------------------------------------------------------------+
351 | ``cmp`` | The BSD ``cmp`` command. |
352 +---------------+-------------------------------------------------------------+
353 | ``cp`` | The BSD ``cp`` command with some twaking. |
354 +---------------+-------------------------------------------------------------+
355 | ``echo`` | The BSD ``echo`` command. |
356 +---------------+-------------------------------------------------------------+
357 | ``expr`` | The BSD ``expr`` command. |
358 +---------------+-------------------------------------------------------------+
359 | ``install`` | The BSD ``install`` command with some tweaking. |
360 +---------------+-------------------------------------------------------------+
361 | ``kDepIDB`` | Extract dependencies from a Visual C++ .IDB file. |
362 +---------------+-------------------------------------------------------------+
363 | ``ln`` | The BSD ``ln`` command. |
364 +---------------+-------------------------------------------------------------+
365 | ``md5sum`` | Typical MD5 sum program, custom kBuild version. |
366 +---------------+-------------------------------------------------------------+
367 | ``mkdir`` | The BSD ``mkdir`` command. |
368 +---------------+-------------------------------------------------------------+
369 | ``mv`` | The BSD ``mv`` command with some tweaking. |
370 +---------------+-------------------------------------------------------------+
371 | ``printf`` | The BSD ``printf`` command. |
372 +---------------+-------------------------------------------------------------+
373 | ``rm`` | The BSD ``rm`` command with some tweaking. |
374 +---------------+-------------------------------------------------------------+
375 | ``rmdir`` | The BSD ``rmdir`` command with some tweaking. |
376 +---------------+-------------------------------------------------------------+
377 | ``sleep`` | Typical ``sleep`` program, custom kBuild version. |
378 +---------------+-------------------------------------------------------------+
379 | ``test`` | The BSD ``test`` program with some tweaking. |
380 +---------------+-------------------------------------------------------------+
382 Some additional external commands are available in the ``kmk`` / ``kBuild``
383 environment (``kSomething`` command are not prefixed with ``kmk_``):
385 +---------------+-------------------------------------------------------------+
386 | Command | Description |
387 +===============+=============================================================+
388 | ``kDepPre`` | Extract dependencies from the C/C++ preprocessor output. |
389 +---------------+-------------------------------------------------------------+
390 | ``kObjCache`` | Simple object file cache program. |
391 +---------------+-------------------------------------------------------------+
392 | ``ash`` | Almquist's shell (NetBSD variant). |
393 +---------------+-------------------------------------------------------------+
394 | ``gmake`` | Vanilla GNU ``make`` from same sources as ``kmk``. |
395 +---------------+-------------------------------------------------------------+
396 | ``redirect`` | Shell avoidance tool. Sets up file descriptors, environment |
397 | | variables and current directory before kicking of program. |
398 +---------------+-------------------------------------------------------------+
399 | ``sed`` | GNU ``sed`` with some tweaks to avoid involving the shell. |
400 +---------------+-------------------------------------------------------------+
401 | ``time`` | Stopwatch utility for measuring program execution time(s). |
402 +---------------+-------------------------------------------------------------+
409 ``kmk``-expressions [1]_ are related to the C/C++ preprocessor in some ways as
410 well as ``nmake`` and BSD ``make``. There are however some peculiarities
411 because of the way GNU ``make`` choose to represent booleans in its function
412 library, so, strings can be turned into boolean by taking any non-empty string
415 Quoting using single quotes results in hard strings, while double quotes and
416 unquoted string results in soft strings that can be converted to number or
417 boolean to fit the situation.
419 Here's the operator table in decending precedence order:
421 +---------------+--------+-----------------------------------------------------+
422 | Operator | Type | Description |
423 +===============+========+=====================================================+
424 | ``defined`` | Unary | Checks if the following variable exists. |
425 +---------------+ +-----------------------------------------------------+
426 | ``exists`` | | Checks if the following file exists. |
427 +---------------+ +-----------------------------------------------------+
428 | ``target`` | | Checks if the following target exists. |
429 +---------------+ +-----------------------------------------------------+
430 | ``bool`` | | Casts the following value to boolean. |
431 +---------------+ +-----------------------------------------------------+
432 | ``num`` | | Casts the following value to a number. |
433 +---------------+ +-----------------------------------------------------+
434 | ``str`` | | Casts the following value to a string. |
435 +---------------+--------+-----------------------------------------------------+
436 | ``!`` | Unary | Logical NOT. |
437 +---------------+ +-----------------------------------------------------+
438 | ``+`` | | Pluss prefix. |
439 +---------------+ +-----------------------------------------------------+
440 | ``-`` | | Minus prefix. |
441 +---------------+ +-----------------------------------------------------+
442 | ``~`` | | Bitwise one's complement. |
443 +---------------+--------+-----------------------------------------------------+
444 | ``*`` | Binary | Multiplication (product). |
445 +---------------+ +-----------------------------------------------------+
446 | ``/`` | | Division (quotient). |
447 +---------------+ +-----------------------------------------------------+
448 | ``%`` | | Modulus (remainder). |
449 +---------------+--------+-----------------------------------------------------+
450 | ``+`` | Binary | Addition (sum). |
451 +---------------+ +-----------------------------------------------------+
452 | ``-`` | | Subtraction (difference). |
453 +---------------+--------+-----------------------------------------------------+
454 | ``<<`` | Binary | Bitwise left shift. |
455 +---------------+ +-----------------------------------------------------+
456 | ``>>`` | | Bitwise right shift. |
457 +---------------+--------+-----------------------------------------------------+
458 | ``<=`` | Binary | Less or equal than. |
459 +---------------+ +-----------------------------------------------------+
460 | ``<`` | | Less than. |
461 +---------------+ +-----------------------------------------------------+
462 | ``>=`` | | Greater or equal than. |
463 +---------------+ +-----------------------------------------------------+
464 | ``>`` | | Greater than. |
465 +---------------+--------+-----------------------------------------------------+
466 | ``==`` | Binary | Equal to. |
467 +---------------+ +-----------------------------------------------------+
468 | ``!=`` | | Not equal to. |
469 +---------------+--------+-----------------------------------------------------+
470 | ``&`` | Binary | Bitwise AND. |
471 +---------------+--------+-----------------------------------------------------+
472 | ``^`` | Binary | Bitwise XOR. |
473 +---------------+--------+-----------------------------------------------------+
474 | ``|`` | Binary | Bitwise OR. |
475 +---------------+--------+-----------------------------------------------------+
476 | ``&&`` | Binary | Logical AND. |
477 +---------------+--------+-----------------------------------------------------+
478 | ``||`` | Binary | Logical OR. |
479 +---------------+--------+-----------------------------------------------------+
487 String Manipulation Functions:
489 Replace ``from`` with ``to`` in ``text``::
491 $(subst from,to,text)
493 Replace words matching ``pattern`` with ``replacement`` in ``text``::
495 $(patsubst pattern,replacement,text)
497 Remove excess whitespace characters from ``string``::
501 Locate ``find`` in ``text``, returning ``find`` if found::
503 $(findstring find,text)
505 Select words in ``text`` that match one of the ``pattern`` words::
507 $(filter pattern...,text)
509 Select words in ``text`` that do not match any of the ``pattern`` words::
511 $(filter-out pattern...,text)
513 Sort the words in ``list`` lexicographically, removing duplicates::
517 Sort the words in ``list`` lexicographically in reserve order, removing
522 Count the number of words in ``text``::
526 Extract the ``n``\th word (one-origin) of ``text``::
530 Returns the list of words in ``text`` from ``s`` to ``e`` (one-origin)::
534 Extract the first word of ``names``::
536 $(firstword names...)
538 Extract the last word of ``names``::
542 Join two parallel lists of words::
546 Fold ``text`` to upper case [1]_::
550 Fold ``text`` to lower case [1]_::
554 String formatting a la the unix ``printf`` command [1]_::
556 $(printf fmt, arg...)
558 Return the length of a string or a (unexpanded) variable [1]_::
563 Find the position of ``needle`` in ``haystack``, returns 0 if not found.
564 Negative ``start`` indices are relative to the end of ``haystack``, while
565 positive ones are one based [1]_::
567 $(pos needle, haystack[, start])
568 $(lastpos needle, haystack[, start])
570 Returns the specified substring. The ``start`` works like with ``$(pos )``.
571 If the substring is partially outside the ``string`` the result will be
572 padded with ``pad`` if present [1]_::
574 $(substr string, start[, length[, pad]])
576 Insert ``in`` into ``str`` at the specified position. ``n`` works like with
577 ``$(pos )``, except that ``0`` is the end of the string [1]_::
579 $(insert in, str[, n[, length[, pad]]])
581 Translate ``string`` exchanging characters in ``from-set`` with ``to-set``,
582 optionally completing ``to-set`` with ``pad-char`` if specified. If no
583 ``pad-char`` characters absent in ``to-set`` will be deleted [1]_::
585 $(translate string, from-set[, to-set[, pad-char]])
588 Functions for file names:
590 Extract the directory part of each file ``name``::
594 Extract the non-directory part of each file ``name``::
598 Extract the suffix (the last ``.`` and following characters) of each file
603 Extract the base name (name without suffix) of each file name::
607 Extract the root specification of each file name (a bit complicated on
608 Windows & OS/2) [1]_::
612 Append ``suffix`` to each word in ``names``::
614 $(addsuffix suffix,names...)
616 Prepend ``prefix`` to each word in ``names``::
618 $(addprefix prefix,names...)
620 Find file names matching a shell file name ``pattern`` (not a ``%``
623 $(wildcard pattern...)
625 For each file name in ``names``, expand to an absolute name that does not
626 contain any ``.``, ``..``, nor symlinks::
630 For each file name in ``names``, expand to an absolute name that does not
631 contain any ``.`` or ``..`` components, but preserves symlinks::
635 Same as ``$(abspath )`` except that the current directory can be
636 specified as ``curdir`` [1]_::
638 $(abspathex names...[, curdir])
641 Arithmetic Functions:
643 Returns the sum of the arguments [1]_::
645 $(int-add addend1, addend2[, addendN])
647 Returns the difference between the first argument and the sum of the
650 $(int-sub minuend, subtrahend[, subtrahendN])
652 Returns the product of the arguments [1]_::
654 $(int-mul factor1, factor2[, factorN])
656 Returns the quotient of first argument and the rest [1]_::
658 $(int-div dividend, divisor[, divisorN])
660 Returns the modulus of the two arguments [1]_::
662 $(int-mod dividend, divisor)
664 Returns the bitwise two-complement of argument [1]_::
668 Returns the result of a bitwise AND of the arguments [1]_::
670 $(int-and val1, val2[, valN])
672 Returns the result of a bitwise OR of the arguments [1]_::
674 $(int-or val1, val2[, valN])
676 Returns the result of a bitwise XOR of the arguments [1]_::
678 $(int-xor val1, val2[, valN])
680 Returns the ``kmk`` boolean (true = non-empty, false = empty) result
681 of ``val1 == val2`` [1]_::
685 Returns the ``kmk`` boolean result of ``val1 != val2`` [1]_::
689 Returns the ``kmk`` boolean result of ``val1 > val2`` [1]_::
693 Returns the ``kmk`` boolean result of ``val1 >= val2`` [1]_::
697 Returns the ``kmk`` boolean result of ``val1 < val2`` [1]_::
701 Returns the ``kmk`` boolean result of ``val1 <= val2`` [1]_::
706 Boolean and Conditional Functions:
708 Condition is false if the ``condition`` evaluates to an empty string
709 (stripped). Evaluate the ``true-part`` if the condition is true, otherwise
712 $(if condition,true-part[,false-part])
714 Test if any of the conditions evalues to non-empty string, returning the
717 $(or condition1[,condition2[,condition3[...]]])
719 Test if all of the conditions evaluates to non-empty strings, returning the
722 $(and condition1[,condition2[,condition3[...]]])
725 Test if the two strings are identical, returning ``kmk`` boolean (true =
726 non-empty, false = empty) [2]_::
730 Invert a ``kmk`` boolean value [2]_::
734 Test if ``variable`` is defined, returning a ``kmk`` boolean value [1]_::
738 Test if ``set-a`` and ``set-b`` intersects, returning a ``kmk`` boolean
741 $(intersects set-a, set-b)
743 Same as ``$(if )`` execpt that the condition is a ``kmk``-expression [1]_::
745 $(if-expr kmk-expression,true-part[,false-part])
747 Select the first true condition (``kmk``-expression) and expand the
748 following body. Special condition strings ``default`` and
751 $(select when1-cond, when1-body[, whenN-cond, whenN-body])
753 Evalutate the ``kmk-expression`` returning what it evalues as. This is
754 the preferred way of doing arithmentic now [1]_::
756 $(expr kmk-expression)
761 Push ``item`` onto the ``stack-var``, returning the empty string [1]_::
763 $(stack-push stack-var, item)
765 Pop the top item off the ``stack-var`` [1]_::
767 $(stack-pop stack-var)
769 Pop the top item off the ``stack-var``, returning the empty string [1]_::
771 $(stack-popv stack-var)
773 Get the top item of the ``stack-var``, returning the empty string [1]_::
775 $(stack-top stack-var)
780 Evaluates to the contents of the variable ``var``, with no expansion
785 Evaluate ``body`` with ``var`` bound to each word in ``words``, and
786 concatenate the results (spaced)::
788 $(foreach var,words,body)
790 C-style for-loop. Start by evaluating ``init``. Each iteration will
791 first check whether the ``condition`` (``kmk``-expression) is true,
792 then expand ``body`` concatenating the result to the previous iterations
793 (spaced), and finally evaluate ``next`` [1]_::
795 $(for init,conditions,next,body)
797 C-style while-loop. Each iteration will check whether the ``condition``
798 (``kmk``-expression) is true, then expand ``body`` concatenating the
799 result to the previous iterations [1]_::
801 $(while conditions,body)
803 Evaluate the variable ``var`` replacing any references to ``$(1)``,
804 ``$(2)`` with the first, second, etc. ``param`` values::
806 $(call var,param,...)
808 Evaluate ``text`` then read the results as makefile commands. Expands
809 to the empty string::
813 Same as ``$(eval text)`` except that the ``text`` is expanded in its
814 own variable context [1]_::
818 Same as ``$(eval $(value var))`` [1]_::
822 Same as ``$(evalctx $(value var))`` [1]_::
826 A combination of ``$(eval )``, ``$(call )`` and ``$(value )`` [1]_::
830 A combination of ``$(eval )`` and ``$(call )`` [1]_::
834 Remove comments and blank lines from the variable ``var``. Expands to
835 the empty string [1]_::
839 Returns accessing ``$<`` of ``target``, either retriving the whole thing
840 or the file at ``pos`` (one-origin) [1]_::
842 $(deps target[, pos])
844 Returns accessing ``$+`` (order + duplicates) of ``target``, either
845 retriving the whole thing or the file at ``pos`` (one-origin) [1]_::
847 $(deps-all target[, pos])
849 Returns accessing ``$?`` of ``target``, either retriving the whole
850 thing or the file at ``pos`` (one-origin) [1]_::
852 $(deps-newer target[, pos])
854 Returns accessing ``$|`` (order only) of ``target``, either retriving the
855 whole thing or the file at ``pos`` (one-origin) [1]_::
857 $(deps-oo target[, pos])
862 Create one or more command lines avoiding the max argument
863 length restriction of the host OS [1]_::
865 $(xargs ar cas mylib.a,$(objects))
866 $(xargs ar cas mylib.a,ar as mylib.a,$(objects))
869 Returns the commands for the specified target separated by new-line, space,
870 or a user defined string. Note that this might not produce the 100% correct
871 result if any of the prerequisite automatic variables are used [1]_::
874 $(commands-sc target)
875 $(commands-usr target,sep)
877 Compares two commands returning the empty string if equal and the 3rd
878 argument if not. This differs from ``$(comp-vars v1,v2,ne)`` in that
879 line by line is stripped of leading spaces, command prefixes and
880 trailing spaces before comparing [1]_::
882 $(comp-cmds cmds-var1, cmds-var2, ne)
883 $(comp-cmds-ex cmds1, cmd2, ne)
886 Compares the values of the two variables returning the empty string if
887 equal and the 3rd argument if not. Leading and trailing spaces is
890 $(comp-var var1, var2, ne)
895 When this function is evaluated, ``kmk`` generates a fatal error with the
900 When this function is evaluated, ``kmk`` generates a warning with the
905 When this function is evaluated, ``kmk`` generates a info with the
910 Execute a shell ``command`` and return its output::
914 Return a string describing how the ``kmk`` variable ``variable`` was defined::
918 Return a string describing the flavor of the ``kmk`` variable ``variable``::
922 Returns the current local time and date formatted in the ``strftime``
923 style specifier ``fmt``. ``fmt`` defaults to ``%Y-%m-%dT%H:%M:%S`` when
928 Returns the current UTC time and date formatted in the ``strftime``
929 style specifier ``fmt``. ``fmt`` defaults to ``%Y-%m-%dT%H:%M:%SZ`` when
934 Reformats the ``in`` time and date using ``fmt``. The ``in-fmt`` defaults
935 to ``fmt`` if not specified. While ``fmt`` defaults to
936 ``%Y-%m-%dT%H:%M:%SZ`` if not specified [1]_::
938 $(date-utc fmt,time,in-fmt)
940 Returns the current nanosecond timestamp (monotonic when possible) [1]_::
944 Returns the size of the specified file, or -1 if the size could not
945 be obtained. This can be used to check if a file exist or not [1]_::
949 Searches the ``PATH`` ``kmk`` variable for the specified ``files`` [1]_::
953 OS/2: Returns the specified LIBPATH variable value [1]_::
957 OS/2: Sets the specified LIBPATH variable value, returning the empty
965 Returns various make statistics, if no item is specified a default
966 selection is returned [1]_::
968 $(make-stats item[,itemN])
970 Raise a debug breakpoint. Used for debugging ``kmk`` makefile
978 .. [1] ``kmk`` only feature.
979 .. [2] Experimental GNU ``make`` feature that is not enabled by default.
984 :Copyright: Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
985 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
986 2007 Free Software Foundation, Inc.
988 Copyright (c) 2008-2009 knut st. osmundsen