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