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