| 1 | {{{ |
| 2 | #!rst |
| 3 | |
| 4 | kmk Quick Reference |
| 5 | =================== |
| 6 | |
| 7 | This appendix summarizes the directives, text manipulation functions, and |
| 8 | special variables which ``kmk`` understands. |
| 9 | |
| 10 | .. See section Special Built-in Target Names and Summary of Options, for other |
| 11 | summaries. |
| 12 | |
| 13 | |
| 14 | Directives |
| 15 | ---------- |
| 16 | |
| 17 | Here is a summary of the directives ``kmk`` recognizes: |
| 18 | |
| 19 | Define a multi-line, recursively-expanded variable:: |
| 20 | |
| 21 | define variable |
| 22 | endef |
| 23 | |
| 24 | Conditionally evaluate part of the makefile:: |
| 25 | |
| 26 | ifdef variable |
| 27 | ifndef variable |
| 28 | ifeq (a,b) |
| 29 | ifeq "a" "b" |
| 30 | ifeq 'a' 'b' |
| 31 | ifneq (a,b) |
| 32 | ifneq "a" "b" |
| 33 | ifneq 'a' 'b' |
| 34 | if1of (set-a,set-b) |
| 35 | ifn1of (set-a,set-b) |
| 36 | if expression |
| 37 | else |
| 38 | endif |
| 39 | |
| 40 | Include another makefile:: |
| 41 | |
| 42 | include file |
| 43 | -include file |
| 44 | sinclude file |
| 45 | |
| 46 | Include another dependency file:: |
| 47 | |
| 48 | includedep file |
| 49 | |
| 50 | Define a variable, overriding any previous definition, even one from the |
| 51 | command line:: |
| 52 | |
| 53 | override variable = value |
| 54 | override variable := value |
| 55 | override variable += value |
| 56 | override variable <= value |
| 57 | override variable ?= value |
| 58 | override define variable |
| 59 | endef |
| 60 | |
| 61 | Tell ``kmk`` to export all variables to child processes by default:: |
| 62 | |
| 63 | export |
| 64 | |
| 65 | Tell ``kmk`` whether or not to export a particular variable to child |
| 66 | processes:: |
| 67 | |
| 68 | export variable |
| 69 | export variable = value |
| 70 | export variable := value |
| 71 | export variable += value |
| 72 | export variable <= value |
| 73 | export variable ?= value |
| 74 | unexport variable |
| 75 | |
| 76 | Define a variable in the local context instead of the global one:: |
| 77 | |
| 78 | local variable = value |
| 79 | local variable := value |
| 80 | local variable += value |
| 81 | local variable <= value |
| 82 | local variable ?= value |
| 83 | local define variable |
| 84 | endef |
| 85 | |
| 86 | Specify a search path for files matching a ``%`` pattern:: |
| 87 | |
| 88 | vpath pattern path |
| 89 | |
| 90 | Remove all search paths previously specified for pattern:: |
| 91 | |
| 92 | vpath pattern |
| 93 | |
| 94 | Remove all search paths previously specified in any vpath directive:: |
| 95 | |
| 96 | vpath |
| 97 | |
| 98 | |
| 99 | |
| 100 | Automatic variables |
| 101 | ------------------- |
| 102 | |
| 103 | Here is a summary of the automatic variables. |
| 104 | |
| 105 | +-----------+-----------------------------------------------------------------+ |
| 106 | | Variable | Description | |
| 107 | +===========+=================================================================+ |
| 108 | | ``$@`` | The file name of the target. | |
| 109 | +-----------+-----------------------------------------------------------------+ |
| 110 | | ``$<`` | The name of the first prerequisite. | |
| 111 | +-----------+-----------------------------------------------------------------+ |
| 112 | | ``$?`` | The names of all the prerequisites that are newer than the | |
| 113 | | | target, with spaces between them. | |
| 114 | +-----------+-----------------------------------------------------------------+ |
| 115 | | ``$^`` | The names of all the prerequisites, duplicates omitted. | |
| 116 | +-----------+-----------------------------------------------------------------+ |
| 117 | | ``$+`` | The names of all the prerequisites, duplicates and order | |
| 118 | | | preserved | |
| 119 | +-----------+-----------------------------------------------------------------+ |
| 120 | | ``$*`` | The stem with which an implicit rule matches. | |
| 121 | +-----------+-----------------------------------------------------------------+ |
| 122 | | ``$|`` | The name of all the order only prerequisites. | |
| 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 | | ``$(|D)`` | The 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 | | ``$(|F)`` | The file-within-directory part of ``$|``. | |
| 151 | +-----------+-----------------------------------------------------------------+ |
| 152 | |
| 153 | |
| 154 | |
| 155 | Special variables |
| 156 | ----------------- |
| 157 | |
| 158 | All variables starting with a ``.`` is reserved by ``kmk``. The following |
| 159 | variables are specially used or/and defined by ``kmk``: |
| 160 | |
| 161 | +--------------------------+--------------------------------------------------+ |
| 162 | | Variable | Description | |
| 163 | +==========================+==================================================+ |
| 164 | | ``.DEFAULT_GOAL`` | The makefile default goal. You can set this in | |
| 165 | | | the makefile, if you don't it will default to | |
| 166 | | | the first target that is encountered. | |
| 167 | +--------------------------+--------------------------------------------------+ |
| 168 | | ``.FEATURES`` | List of GNU ``make`` features. Do not set this. | |
| 169 | +--------------------------+--------------------------------------------------+ |
| 170 | | ``.INCLUDE_DIRS`` | List of include directories, ``-I`` arguments | |
| 171 | | | and defaults. Do not set this. | |
| 172 | +--------------------------+--------------------------------------------------+ |
| 173 | | ``.RECIPEPREFIX`` | Recipe prefix, defaults to tab. | |
| 174 | +--------------------------+--------------------------------------------------+ |
| 175 | | ``.VARIABLES`` | Special variable which exands to the list of | |
| 176 | | | variable. Do not set this. | |
| 177 | +--------------------------+--------------------------------------------------+ |
| 178 | | ``CURDIR`` | Set to the pathname of the current working | |
| 179 | | | directory (after all ``-C`` options are | |
| 180 | | | processed, if any). Do not set this. | |
| 181 | +--------------------------+--------------------------------------------------+ |
| 182 | | ``KBUILD_VERSION``, | The kBuild version string and the break down | |
| 183 | | ``KBUILD_VERSION_MAJOR``,| into individual components. | |
| 184 | | ``KBUILD_VERSION_MINOR``,| | |
| 185 | | ``KBUILD_VERSION_PATCH``,| | |
| 186 | | ``KBUILD_KMK_REVISION`` | | |
| 187 | +--------------------------+--------------------------------------------------+ |
| 188 | | ``KBUILD_HOST`` | The host operating system. | |
| 189 | +--------------------------+--------------------------------------------------+ |
| 190 | | ``KBUILD_HOST_ARCH`` | The host architecture. | |
| 191 | +--------------------------+--------------------------------------------------+ |
| 192 | | ``KBUILD_HOST_CPU`` | The host CPU ``kmk`` is built for, set to | |
| 193 | | | ``blend`` if not any particular CPU. | |
| 194 | +--------------------------+--------------------------------------------------+ |
| 195 | | ``KBUILD_PATH`` | Where the kBuild scripts are. | |
| 196 | +--------------------------+--------------------------------------------------+ |
| 197 | | ``KBUILD_BIN_PATH`` | Where the host specific kBuild binaries are. | |
| 198 | +--------------------------+--------------------------------------------------+ |
| 199 | | ``KMK``, | The name with which ``kmk`` was invoked. Using | |
| 200 | | ``MAKE`` | this variable in recipes has special meaning. | |
| 201 | +--------------------------+--------------------------------------------------+ |
| 202 | | ``KMK_BUILTIN`` | List of built-in commands. | |
| 203 | +--------------------------+--------------------------------------------------+ |
| 204 | | ``KMK_FEATURES`` | List of ``kmk`` specific features. | |
| 205 | +--------------------------+--------------------------------------------------+ |
| 206 | | ``KMK_FLAGS`` | The flags given to ``kmk``. You can set this in | |
| 207 | | | the environment or a makefile to set flags. | |
| 208 | | | | |
| 209 | | | It is never appropriate to use ``KMK_FLAGS`` | |
| 210 | | | directly in a recipe line: its contents may not | |
| 211 | | | be quoted correctly for use in the shell. Always | |
| 212 | | | allow recursive ``kmk``'s to obtain these values | |
| 213 | | | through the environment from its parent. | |
| 214 | +--------------------------+--------------------------------------------------+ |
| 215 | | ``KMK_LEVEL`` | The number of levels of recursion (sub-makes). | |
| 216 | +--------------------------+--------------------------------------------------+ |
| 217 | | ``KMK_VERSION`` | The GNU ``make`` version number. | |
| 218 | +--------------------------+--------------------------------------------------+ |
| 219 | | ``MAKECMDGOALS`` | The targets given to ``kmk`` on the command line.| |
| 220 | | | Do not set this. | |
| 221 | +--------------------------+--------------------------------------------------+ |
| 222 | | ``MAKEFILES`` | Makefiles to be read on every invocation of | |
| 223 | | | ``kmk``. | |
| 224 | +--------------------------+--------------------------------------------------+ |
| 225 | | ``MAKEFILE_LIST`` | List of the makefiles that ``kmk`` has opened. | |
| 226 | +--------------------------+--------------------------------------------------+ |
| 227 | | ``MAKESHELL`` | OS/2 and MS-DOS only, the name of the command | |
| 228 | | | interpreter that is to be used by ``kmk``. This | |
| 229 | | | value takes precedence over the value of SHELL. | |
| 230 | +--------------------------+--------------------------------------------------+ |
| 231 | | ``SHELL`` | The name of the default command interpreter, | |
| 232 | | | kmk_ash. You can set SHELL in the makefile to | |
| 233 | | | change the shell used to run recipes. The SHELL | |
| 234 | | | variable is handled specially when importing | |
| 235 | | | from and exporting to the environment. | |
| 236 | +--------------------------+--------------------------------------------------+ |
| 237 | | ``SUFFIXES`` | The default list of suffixes before ``kmk`` | |
| 238 | | | reads any makefiles (always empty). | |
| 239 | +--------------------------+--------------------------------------------------+ |
| 240 | | ``VPATH`` | Directory search path for files not found in the | |
| 241 | | | current directory. | |
| 242 | +--------------------------+--------------------------------------------------+ |
| 243 | |
| 244 | |
| 245 | The following variables reflects ``kmk`` options. Do not set these. |
| 246 | |
| 247 | +-------------------------------------+---------------------------------------+ |
| 248 | | Variable | Description | |
| 249 | +=====================================+=======================================+ |
| 250 | | ``KMK_OPTS_JOBS`` | -j slots, ``0`` if not given. | |
| 251 | +-------------------------------------+---------------------------------------+ |
| 252 | | ``KMK_OPTS_KEEP_GOING`` | -k indictor (``0``/``1``). | |
| 253 | +-------------------------------------+---------------------------------------+ |
| 254 | | ``KMK_OPTS_JUST_PRINT`` | -n indicator (``0``/``1``). | |
| 255 | +-------------------------------------+---------------------------------------+ |
| 256 | | ``KMK_OPTS_PRORITY`` | --priority level, ``0`` if not given. | |
| 257 | +-------------------------------------+---------------------------------------+ |
| 258 | | ``KMK_OPTS_AFFINITY`` | --affinity mask, ``0`` if not given. | |
| 259 | +-------------------------------------+---------------------------------------+ |
| 260 | | ``KMK_OPTS_STATISTICS`` | --statistics indicator (``0``/``1``). | |
| 261 | +-------------------------------------+---------------------------------------+ |
| 262 | | ``KMK_OPTS_PRINT_TIME`` | The --print-time value. | |
| 263 | +-------------------------------------+---------------------------------------+ |
| 264 | | ``KMK_OPTS_PRETTY_COMMAND_PRINTING``| --pretty-command-printing indicator. | |
| 265 | +-------------------------------------+---------------------------------------+ |
| 266 | |
| 267 | |
| 268 | |
| 269 | Built-in functions |
| 270 | ------------------ |
| 271 | |
| 272 | |
| 273 | String Manipulation Functions: |
| 274 | |
| 275 | Replace ``from`` with ``to`` in ``text``:: |
| 276 | |
| 277 | $(subst from,to,text) |
| 278 | |
| 279 | Replace words matching ``pattern`` with ``replacement`` in ``text``:: |
| 280 | |
| 281 | $(patsubst pattern,replacement,text) |
| 282 | |
| 283 | Remove excess whitespace characters from ``string``:: |
| 284 | |
| 285 | $(strip string) |
| 286 | |
| 287 | Locate ``find`` in ``text``, returning ``find`` if found:: |
| 288 | |
| 289 | $(findstring find,text) |
| 290 | |
| 291 | Select words in ``text`` that match one of the ``pattern`` words:: |
| 292 | |
| 293 | $(filter pattern...,text) |
| 294 | |
| 295 | Select words in ``text`` that do not match any of the ``pattern`` words:: |
| 296 | |
| 297 | $(filter-out pattern...,text) |
| 298 | |
| 299 | Sort the words in ``list`` lexicographically, removing duplicates:: |
| 300 | |
| 301 | $(sort list) |
| 302 | |
| 303 | Sort the words in ``list`` lexicographically in reserve order, removing |
| 304 | duplicates:: |
| 305 | |
| 306 | $(rsort list) |
| 307 | |
| 308 | Count the number of words in ``text``:: |
| 309 | |
| 310 | $(words text) |
| 311 | |
| 312 | Extract the ``n``\th word (one-origin) of ``text``:: |
| 313 | |
| 314 | $(word n,text) |
| 315 | |
| 316 | Returns the list of words in ``text`` from ``s`` to ``e`` (one-origin):: |
| 317 | |
| 318 | $(wordlist s,e,text) |
| 319 | |
| 320 | Extract the first word of ``names``:: |
| 321 | |
| 322 | $(firstword names...) |
| 323 | |
| 324 | Extract the last word of ``names``:: |
| 325 | |
| 326 | $(lastword names...) |
| 327 | |
| 328 | Join two parallel lists of words:: |
| 329 | |
| 330 | $(join list1,list2) |
| 331 | |
| 332 | Fold ``text`` to upper case:: |
| 333 | |
| 334 | $(toupper text) |
| 335 | |
| 336 | Fold ``text`` to lower case:: |
| 337 | |
| 338 | $(tolower text) |
| 339 | |
| 340 | String formatting a la the unix ``printf`` command:: |
| 341 | |
| 342 | $(printf fmt, arg...) |
| 343 | |
| 344 | |
| 345 | Functions for file names: |
| 346 | |
| 347 | Extract the directory part of each file ``name``:: |
| 348 | |
| 349 | $(dir names...) |
| 350 | |
| 351 | Extract the non-directory part of each file ``name``:: |
| 352 | |
| 353 | $(notdir names...) |
| 354 | |
| 355 | Extract the suffix (the last ``.`` and following characters) of each file |
| 356 | ``name``:: |
| 357 | |
| 358 | $(suffix names...) |
| 359 | |
| 360 | Extract the base name (name without suffix) of each file name:: |
| 361 | |
| 362 | $(basename names...) |
| 363 | |
| 364 | Append ``suffix`` to each word in ``names``:: |
| 365 | |
| 366 | $(addsuffix suffix,names...) |
| 367 | |
| 368 | Prepend ``prefix`` to each word in ``names``:: |
| 369 | |
| 370 | $(addprefix prefix,names...) |
| 371 | |
| 372 | Find file names matching a shell file name ``pattern`` (not a ``%`` |
| 373 | pattern):: |
| 374 | |
| 375 | $(wildcard pattern...) |
| 376 | |
| 377 | For each file name in ``names``, expand to an absolute name that does not |
| 378 | contain any ``.``, ``..``, nor symlinks:: |
| 379 | |
| 380 | $(realpath names...) |
| 381 | |
| 382 | For each file name in ``names``, expand to an absolute name that does not |
| 383 | contain any ``.`` or ``..`` components, but preserves symlinks:: |
| 384 | |
| 385 | $(abspath names...) |
| 386 | |
| 387 | Same as ``$(abspath )`` except that the current directory can be |
| 388 | specified as ``curdir``:: |
| 389 | |
| 390 | $(abspathex names...[, curdir]) |
| 391 | |
| 392 | |
| 393 | Arithmetic Functions: |
| 394 | |
| 395 | Returns the sum of the arguments:: |
| 396 | |
| 397 | $(int-add addend1, addend2[, addendN]) |
| 398 | |
| 399 | Returns the difference between the first argument and the sum of the rest:: |
| 400 | |
| 401 | $(int-sub minuend, subtrahend[, subtrahendN]) |
| 402 | |
| 403 | Returns the product of the arguments:: |
| 404 | |
| 405 | $(int-mul factor1, factor2[, factorN]) |
| 406 | |
| 407 | Returns the quotient of first argument and the rest:: |
| 408 | |
| 409 | $(int-div dividend, divisor[, divisorN]) |
| 410 | |
| 411 | Returns the modulus of the two arguments:: |
| 412 | |
| 413 | $(int-mod dividend, divisor) |
| 414 | |
| 415 | Returns the bitwise two-complement of argument:: |
| 416 | |
| 417 | $(int-not val) |
| 418 | |
| 419 | Returns the result of a bitwise AND of the arguments:: |
| 420 | |
| 421 | $(int-and val1, val2[, valN]) |
| 422 | |
| 423 | Returns the result of a bitwise OR of the arguments:: |
| 424 | |
| 425 | $(int-or val1, val2[, valN]) |
| 426 | |
| 427 | Returns the result of a bitwise XOR of the arguments:: |
| 428 | |
| 429 | $(int-xor val1, val2[, valN]) |
| 430 | |
| 431 | Returns the ``kmk`` boolean (true = non-empty, false = empty) result |
| 432 | of ``val1 == val2``:: |
| 433 | |
| 434 | $(int-eq val1, val2) |
| 435 | |
| 436 | Returns the ``kmk`` boolean result of ``val1 != val2``:: |
| 437 | |
| 438 | $(int-ne val1, val2) |
| 439 | |
| 440 | Returns the ``kmk`` boolean result of ``val1 > val2``:: |
| 441 | |
| 442 | $(int-gt val1, val2) |
| 443 | |
| 444 | Returns the ``kmk`` boolean result of ``val1 >= val2``:: |
| 445 | |
| 446 | $(int-ge val1, val2) |
| 447 | |
| 448 | Returns the ``kmk`` boolean result of ``val1 < val2``:: |
| 449 | |
| 450 | $(int-lt val1, val2) |
| 451 | |
| 452 | Returns the ``kmk`` boolean result of ``val1 <= val2``:: |
| 453 | |
| 454 | $(int-le val1, val2) |
| 455 | |
| 456 | |
| 457 | (Mostly) Boolean Functions: |
| 458 | |
| 459 | Condition is false if the ``condition`` evaluates to an empty string |
| 460 | (stripped). Evaluate the ``true-part`` if the condition is true, otherwise |
| 461 | the ``false-part``:: |
| 462 | |
| 463 | $(if condition,true-part[,false-part]) |
| 464 | |
| 465 | Test if any of the conditions evalues to non-empty string, returning the |
| 466 | first one:: |
| 467 | |
| 468 | $(or condition1[,condition2[,condition3[...]]]) |
| 469 | |
| 470 | Test if all of the conditions evaluates to non-empty strings, returning the |
| 471 | last one:: |
| 472 | |
| 473 | $(and condition1[,condition2[,condition3[...]]]) |
| 474 | |
| 475 | |
| 476 | Test if the two strings are identical, returning ``kmk`` boolean (true = |
| 477 | non-empty, false = empty):: |
| 478 | |
| 479 | $(eq str1, str2) |
| 480 | |
| 481 | Invert a ``kmk`` boolean value:: |
| 482 | |
| 483 | $(not val) |
| 484 | |
| 485 | Test if ``variable`` is defined, returning a ``kmk`` boolean value:: |
| 486 | |
| 487 | $(defined variable) |
| 488 | |
| 489 | Test if ``set-a`` and ``set-b`` intersects, returning a ``kmk`` boolean |
| 490 | value:: |
| 491 | |
| 492 | $(intersects set-a, set-b) |
| 493 | |
| 494 | Same as ``$(if )`` execpt that the condition is a ``kmk`` expression:: |
| 495 | |
| 496 | $(if kmk-expression,true-part[,false-part]) |
| 497 | |
| 498 | Evalutate the ``kmk`` expression returning what it evalues as. This is |
| 499 | the preferred way of doing arithmentic now:: |
| 500 | |
| 501 | $(expr kmk-expression) |
| 502 | |
| 503 | |
| 504 | Stack Fuctions: |
| 505 | |
| 506 | Push ``item`` onto the ``stack-var``, returning the empty string:: |
| 507 | |
| 508 | $(stack-push stack-var, item) |
| 509 | |
| 510 | Pop the top item off the ``stack-var``:: |
| 511 | |
| 512 | $(stack-pop stack-var) |
| 513 | |
| 514 | Pop the top item off the ``stack-var``, returning the empty string:: |
| 515 | |
| 516 | $(stack-popv stack-var) |
| 517 | |
| 518 | Get the top item of the ``stack-var``, returning the empty string:: |
| 519 | |
| 520 | $(stack-top stack-var) |
| 521 | |
| 522 | |
| 523 | Advanced Functions: |
| 524 | |
| 525 | Evaluates to the contents of the variable ``var``, with no expansion |
| 526 | performed on it:: |
| 527 | |
| 528 | $(value var) |
| 529 | |
| 530 | Evaluate ``text`` with ``var`` bound to each word in ``words``, and |
| 531 | concatenate the results (spaced):: |
| 532 | |
| 533 | $(foreach var,words,text) |
| 534 | |
| 535 | Evaluate the variable ``var`` replacing any references to ``$(1)``, |
| 536 | ``$(2)`` with the first, second, etc. ``param`` values:: |
| 537 | |
| 538 | $(call var,param,...) |
| 539 | |
| 540 | Evaluate ``text`` then read the results as makefile commands. Expands |
| 541 | to the empty string:: |
| 542 | |
| 543 | $(eval text) |
| 544 | |
| 545 | Same as ``$(eval text)`` except that the ``text`` is expanded in its |
| 546 | own variable context:: |
| 547 | |
| 548 | $(evalctx text) |
| 549 | |
| 550 | Same as ``$(eval $(value var))``:: |
| 551 | |
| 552 | $(evalval var) |
| 553 | |
| 554 | Same as ``$(evalctx $(value var))``:: |
| 555 | |
| 556 | $(evalvalctx var) |
| 557 | |
| 558 | A combination of ``$(eval )``, ``$(call )`` and ``$(value )``:: |
| 559 | |
| 560 | $(evalcall var) |
| 561 | |
| 562 | A combination of ``$(eval )`` and ``$(call )``:: |
| 563 | |
| 564 | $(evalcall var) |
| 565 | |
| 566 | Remove comments and blank lines from the variable ``var``. Expands to |
| 567 | the empty string:: |
| 568 | |
| 569 | $(eval-opt-var var) |
| 570 | |
| 571 | Returns accessing ``$<`` of ``target``, either retriving the whole thing |
| 572 | or the file at ``pos`` (one-origin):: |
| 573 | |
| 574 | $(deps target[, pos]) |
| 575 | |
| 576 | Returns accessing ``$+`` (order + duplicates) of ``target``, either |
| 577 | retriving the whole thing or the file at ``pos`` (one-origin):: |
| 578 | |
| 579 | $(deps-all target[, pos]) |
| 580 | |
| 581 | Returns accessing ``$?`` of ``target``, either retriving the whole |
| 582 | thing or the file at ``pos`` (one-origin):: |
| 583 | |
| 584 | $(deps-newer target[, pos]) |
| 585 | |
| 586 | Returns accessing ``$|`` (order only) of ``target``, either retriving the |
| 587 | whole thing or the file at ``pos`` (one-origin):: |
| 588 | |
| 589 | $(deps-oo target[, pos]) |
| 590 | |
| 591 | |
| 592 | Command Functions: |
| 593 | |
| 594 | Create one or more command lines avoiding the max argument |
| 595 | length restriction of the host OS:: |
| 596 | |
| 597 | $(xargs ar cas mylib.a,$(objects)) |
| 598 | $(xargs ar cas mylib.a,ar as mylib.a,$(objects)) |
| 599 | |
| 600 | |
| 601 | Returns the commands for the specified target separated by new-line, space, |
| 602 | or a user defined string. Note that this might not produce the 100% correct |
| 603 | result if any of the prerequisite automatic variables are used:: |
| 604 | |
| 605 | $(commands target) |
| 606 | $(commands-sc target) |
| 607 | $(commands-usr target,sep) |
| 608 | |
| 609 | Compares two commands returning the empty string if equal and the 3rd |
| 610 | argument if not. This differs from ``$(comp-vars v1,v2,ne)`` in that |
| 611 | line by line is stripped of leading spaces, command prefixes and |
| 612 | trailing spaces before comparing:: |
| 613 | |
| 614 | $(comp-cmds cmds-var1, cmds-var2, ne) |
| 615 | $(comp-cmds-ex cmds1, cmd2, ne) |
| 616 | |
| 617 | |
| 618 | Compares the values of the two variables returning the empty string if |
| 619 | equal and the 3rd argument if not. Leading and trailing spaces is ignored:: |
| 620 | |
| 621 | $(comp-var var1, var2, ne) |
| 622 | |
| 623 | |
| 624 | Utility functions: |
| 625 | |
| 626 | When this function is evaluated, ``kmk`` generates a fatal error with the |
| 627 | message ``text``:: |
| 628 | |
| 629 | $(error text...) |
| 630 | |
| 631 | When this function is evaluated, ``kmk`` generates a warning with the |
| 632 | message ``text``:: |
| 633 | |
| 634 | $(warning text...) |
| 635 | |
| 636 | When this function is evaluated, ``kmk`` generates a info with the |
| 637 | message ``text``:: |
| 638 | |
| 639 | $(info text...) |
| 640 | |
| 641 | Execute a shell ``command`` and return its output:: |
| 642 | |
| 643 | $(shell command) |
| 644 | |
| 645 | Return a string describing how the ``kmk`` variable ``variable`` was defined:: |
| 646 | |
| 647 | $(origin variable) |
| 648 | |
| 649 | Return a string describing the flavor of the ``kmk`` variable ``variable``:: |
| 650 | |
| 651 | $(flavor variable) |
| 652 | |
| 653 | Returns the current local time and date formatted in the ``strftime`` |
| 654 | style specifier ``fmt``. ``fmt`` defaults to ``%Y-%m-%dT%H:%M:%S`` when |
| 655 | not specified:: |
| 656 | |
| 657 | $(date fmt) |
| 658 | |
| 659 | Returns the current UTC time and date formatted in the ``strftime`` |
| 660 | style specifier ``fmt``. ``fmt`` defaults to ``%Y-%m-%dT%H:%M:%SZ`` when |
| 661 | not specified:: |
| 662 | |
| 663 | $(date-utc fmt) |
| 664 | |
| 665 | Reformats the ``in`` time and date using ``fmt``. The ``in-fmt`` defaults |
| 666 | to ``fmt`` if not specified. While ``fmt`` defaults to |
| 667 | ``%Y-%m-%dT%H:%M:%SZ`` if not specified:: |
| 668 | |
| 669 | $(date-utc fmt,time,in-fmt) |
| 670 | |
| 671 | Returns the current nanosecond timestamp (monotonic when possible):: |
| 672 | |
| 673 | $(nanots ) |
| 674 | |
| 675 | Returns the size of the specified file, or -1 if the size could not |
| 676 | be obtained. This can be used to check if a file exist or not:: |
| 677 | |
| 678 | $(file-size file) |
| 679 | |
| 680 | Searches the ``PATH`` ``kmk`` variable for the specified ``files``:: |
| 681 | |
| 682 | $(which files...) |
| 683 | |
| 684 | OS/2: Returns the specified LIBPATH variable value:: |
| 685 | |
| 686 | $(libpath var) |
| 687 | |
| 688 | OS/2: Sets the specified LIBPATH variable value, returning the empty string:: |
| 689 | |
| 690 | $(libpath var,value) |
| 691 | |
| 692 | |
| 693 | Debugging Functions: |
| 694 | |
| 695 | Returns various make statistics, if no item is specified a default |
| 696 | selection is returned:: |
| 697 | |
| 698 | $(make-stats item[,itemN]) |
| 699 | |
| 700 | Raise a debug breakpoint. Used for debugging ``kmk`` makefile parsing:: |
| 701 | |
| 702 | $(breakpoint ) |
| 703 | |
| 704 | |
| 705 | |
| 706 | Special targets |
| 707 | --------------- |
| 708 | |
| 709 | todo |
| 710 | |
| 711 | |
| 712 | ----- |
| 713 | |
| 714 | :Status: $Id: QuickReference-kmk.txt 2146 2008-12-27 20:22:53Z bird $ |
| 715 | :Copyright: Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, |
| 716 | 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, |
| 717 | 2007 Free Software Foundation, Inc. |
| 718 | |
| 719 | Copyright (C) 2008 Knut St. Osmundsen |
| 720 | |
| 721 | }}} |