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