1 Config Language Specification
2 18 October 1999
3 Michael Elizabeth Chastain, <mailto:mec@shout.net>
4
5
6
7 === Introduction
8
9 Config Language is not 'bash'.
10
11 This document describes Config Language, the Linux Kernel Configuration
12 Language. config.in and Config.in files are written in this language.
13
14 Although it looks, and usually acts, like a subset of the 'sh' language,
15 Config Language has a restricted syntax and different semantics.
16
17 Here is a basic guideline for Config Language programming: use only the
18 programming idioms that you see in existing Config.in files. People often
19 draw on their shell programming experience to invent idioms that look
20 reasonable to shell programmers, but silently fail in Config Language.
21
22 Config Language is not 'bash'.
23
24
25
26 === Interpreters
27
28 Four different configuration programs read Config Language:
29
30 scripts/Configure make config, make oldconfig
31 scripts/Menuconfig make menuconfig
32 scripts/tkparse make xconfig
33 mconfig (in development)
34
35 'Configure' is a bash script which interprets Config.in files by sourcing
36 them. Some of the Config Language commands are native bash commands;
37 simple bash functions implement the rest of the commands.
38
39 'Menuconfig' is another bash script. It scans the input files with a
40 small awk script, builds a shell function for each menu, sources the
41 shell functions that it builds, and then executes the shell functions
42 in a user-driven order. Menuconfig uses 'lxdialog', a back-end utility
43 program, to perform actual screen output. 'lxdialog' is a C program
44 which uses curses.
45
46 'scripts/tkparse' is a C program with an ad hoc parser which translates
47 a Config Language script to a huge TCL/TK program. 'make xconfig'
48 then hands this TCL/TK program to 'wish', which executes it.
49
50 'mconfig' is the next generation of Config Language interpreters. It is a
51 C program with a bison parser which translates a Config Language script
52 into an internal syntax tree and then hands the syntax tree to one of
53 several user-interface front ends.
54
55 This document describes the behaviour of all four interpreters, even though
56 mconfig has not been released at the time of writing.
57
58
59
60 === Statements
61
62 A Config Language script is a list of statements. There are 21 simple
63 statements; an 'if' statement; menu blocks; and a 'source' statement.
64
65 A '\' at the end of a line marks a line continuation.
66
67 '#' usually introduces a comment, which continues to the end of the line.
68 Lines of the form '# ... is not set', however, are not comments. They
69 are semantically meaningful, and all four config interpreters implement
70 this meaning.
71
72 Newlines are significant. You may not substitute semicolons for newlines.
73 The 'if' statement does accept a semicolon in one position; you may use
74 a newline in that position instead.
75
76 Here are the basic grammar elements.
77
78 A /prompt/ is a single-quoted string or a double-quoted string.
79 If the word is double-quoted, it may not have any $ substitutions.
80
81 A /word/ is a single unquoted word, a single-quoted string, or a
82 double-quoted string. If the word is unquoted or double quoted,
83 then $-substitution will be performed on the word.
84
85 A /symbol/ is a single unquoted word. A symbol must have a name of
86 the form CONFIG_*. scripts/mkdep.c relies on this convention in order
87 to generate dependencies on individual CONFIG_* symbols instead of
88 making one massive dependency on include/linux/autoconf.h.
89
90 A /dep/ is a dependency. Syntactically, it is a /word/. At run
91 time, a /dep/ must evaluate to "y", "m", "n", or "".
92
93 An /expr/ is a bash-like expression using the operators
94 '=', '!=', '-a', '-o', and '!'.
95
96 Here are all the statements:
97
98 Text statements:
99
100 mainmenu_name /prompt/
101 comment /prompt/
102 text /prompt/
103
104 Ask statements:
105
106 bool /prompt/ /symbol/
107 hex /prompt/ /symbol/ /word/
108 int /prompt/ /symbol/ /word/
109 string /prompt/ /symbol/ /word/
110 tristate /prompt/ /symbol/
111
112 Define statements:
113
114 define_bool /symbol/ /word/
115 define_hex /symbol/ /word/
116 define_int /symbol/ /word/
117 define_string /symbol/ /word/
118 define_tristate /symbol/ /word/
119
120 Dependent statements:
121
122 dep_bool /prompt/ /symbol/ /dep/ ...
123 dep_mbool /prompt/ /symbol/ /dep/ ...
124 dep_hex /prompt/ /symbol/ /word/ /dep/ ...
125 dep_int /prompt/ /symbol/ /word/ /dep/ ...
126 dep_string /prompt/ /symbol/ /word/ /dep/ ...
127 dep_tristate /prompt/ /symbol/ /dep/ ...
128
129 Unset statement:
130
131 unset /symbol/ ...
132
133 Choice statements:
134
135 choice /prompt/ /word/ /word/
136 nchoice /prompt/ /symbol/ /prompt/ /symbol/ ...
137
138 If statements:
139
140 if [ /expr/ ] ; then
141 /statement/
142 ...
143 fi
144
145 if [ /expr/ ] ; then
146 /statement/
147 ...
148 else
149 /statement/
150 ...
151 fi
152
153 Menu block:
154
155 mainmenu_option next_comment
156 comment /prompt/
157 /statement/
158 ...
159 endmenu
160
161 Source statement:
162
163 source /word/
164
165
166
167 === mainmenu_name /prompt/
168
169 This verb is a lot less important than it looks. It specifies the top-level
170 name of this Config Language file.
171
172 Configure: ignores this line
173 Menuconfig: ignores this line
174 Xconfig: uses /prompt/ for the label window.
175 mconfig: ignores this line (mconfig does a better job without it).
176
177 Example:
178
179 # arch/sparc/config.in
180 mainmenu_name "Linux/SPARC Kernel Configuration"
181
182
183
184 === comment /prompt/
185
186 This verb displays its prompt to the user during the configuration process
187 and also echoes it to the output files during output. Note that the
188 prompt, like all prompts, is a quoted string with no dollar substitution.
189
190 The 'comment' verb is not a Config Language comment. It causes the
191 user interface to display text, and it causes output to appear in the
192 output files.
193
194 Configure: implemented
195 Menuconfig: implemented
196 Xconfig: implemented
197 mconfig: implemented
198
199 Example:
200
201 # drivers/net/Config.in
202 comment 'CCP compressors for PPP are only built as modules.'
203
204
205
206 === text /prompt/
207
208 This verb displays the prompt to the user with no adornment whatsoever.
209 It does not echo the prompt to the output file. mconfig uses this verb
210 internally for its help facility.
211
212 Configure: not implemented
213 Menuconfig: not implemented
214 Xconfig: not implemented
215 mconfig: implemented
216
217 Example:
218
219 # mconfig internal help text
220 text 'Here are all the mconfig command line options.'
221
222
223
224 === bool /prompt/ /symbol/
225
226 This verb displays /prompt/ to the user, accepts a value from the user,
227 and assigns that value to /symbol/. The legal input values are "n" and
228 "y".
229
230 Note that the bool verb does not have a default value. People keep
231 trying to write Config Language scripts with a default value for bool,
232 but *all* of the existing language interpreters discard additional values.
233 Feel free to submit a multi-interpreter patch to linux-kbuild if you
234 want to implement this as an enhancement.
235
236 Configure: implemented
237 Menuconfig: implemented
238 Xconfig: implemented
239 mconfig: implemented
240
241 Example:
242
243 # arch/i386/config.in
244 bool 'Symmetric multi-processing support' CONFIG_SMP
245
246
247
248 === hex /prompt/ /symbol/ /word/
249
250 This verb displays /prompt/ to the user, accepts a value from the user,
251 and assigns that value to /symbol/. Any hexadecimal number is a legal
252 input value. /word/ is the default value.
253
254 The hex verb does not accept range parameters.
255
256 Configure: implemented
257 Menuconfig: implemented
258 Xconfig: implemented
259 mconfig: implemented
260
261 Example:
262
263 # drivers/sound/Config.in
264 hex 'I/O base for SB Check from manual of the card' CONFIG_SB_BASE 220
265
266
267
268 === int /prompt/ /symbol/ /word/
269
270 This verb displays /prompt/ to the user, accepts a value from the user,
271 and assigns that value to /symbol/. /word/ is the default value.
272 Any decimal number is a legal input value.
273
274 The int verb does not accept range parameters.
275
276 Configure: implemented
277 Menuconfig: implemented
278 Xconfig: implemented
279 mconfig: implemented
280
281 Example:
282
283 # drivers/char/Config.in
284 int 'Maximum number of Unix98 PTYs in use (0-2048)' \
285 CONFIG_UNIX98_PTY_COUNT 256
286
287
288
289 === string /prompt/ /symbol/ /word/
290
291 This verb displays /prompt/ to the user, accepts a value from the user,
292 and assigns that value to /symbol/. /word/ is the default value. Legal
293 input values are any ASCII string, except for the characters '"' and '\\'.
294 Configure will trap an input string of "?" to display help.
295
296 The default value is mandatory.
297
298 Configure: implemented
299 Menuconfig: implemented
300 Xconfig: implemented
301 mconfig: implemented
302
303 Example:
304
305 # drivers/sound/Config.in
306 string ' Full pathname of DSPxxx.LD firmware file' \
307 CONFIG_PSS_BOOT_FILE /etc/sound/dsp001.ld
308
309
310
311 === tristate /prompt/ /symbol/
312
313 This verb displays /prompt/ to the user, accepts a value from the user,
314 and assigns that value to /symbol/. Legal values are "n", "m", or "y".
315
316 The value "m" stands for "module"; it indicates that /symbol/ should
317 be built as a kernel module. The value "m" is legal only if the symbol
318 CONFIG_MODULES currently has the value "y".
319
320 The tristate verb does not have a default value.
321
322 Configure: implemented
323 Menuconfig: implemented
324 Xconfig: implemented
325 mconfig: implemented
326
327 Example:
328
329 # fs/Config.in
330 tristate 'NFS filesystem support' CONFIG_NFS_FS
331
332
333
334 === define_bool /symbol/ /word/
335
336 This verb the value of /word/ to /symbol/. Legal values are "n" or "y".
337
338 For compatibility reasons, the value of "m" is also legal, because it
339 will be a while before define_tristate is implemented everywhere.
340
341 Configure: implemented
342 Menuconfig: implemented
343 Xconfig: implemented
344 mconfig: implemented
345
346 Example:
347
348 # arch/alpha/config.in
349 if [ "$CONFIG_ALPHA_GENERIC" = "y" ]
350 then
351 define_bool CONFIG_PCI y
352 define_bool CONFIG_ALPHA_NEED_ROUNDING_EMULATION y
353 fi
354
355
356
357 === define_hex /symbol/ /word/
358
359 This verb assigns the value of /word/ to /symbol/. Any hexadecimal
360 number is a legal value.
361
362 Configure: implemented
363 Menuconfig: implemented
364 Xconfig: implemented
365 mconfig: implemented
366
367 Example:
368
369 # Not from the corpus
370 bool 'Specify custom serial port' CONFIG_SERIAL_PORT_CUSTOM
371 if [ "$CONFIG_SERIAL_PORT_CUSTOM" = "y" ]; then
372 hex 'Serial port number' CONFIG_SERIAL_PORT
373 else
374 define_hex CONFIG_SERIAL_PORT 0x3F8
375 fi
376
377
378
379 === define_int /symbol/ /word/
380
381 This verb assigns /symbol/ the value /word/. Any decimal number is a
382 legal value.
383
384 Configure: implemented
385 Menuconfig: implemented
386 Xconfig: implemented
387 mconfig: implemented
388
389 Example:
390
391 # drivers/char/ftape/Config.in
392 define_int CONFIG_FT_ALPHA_CLOCK 0
393
394
395
396 === define_string /symbol/ /word/
397
398 This verb assigns the value of /word/ to /symbol/. Legal input values
399 are any ASCII string, except for the characters '"' and '\\'.
400
401 Configure: implemented
402 Menuconfig: implemented
403 Xconfig: implemented
404 mconfig: implemented
405
406 Example
407
408 # Not from the corpus
409 define_string CONFIG_VERSION "2.2.0"
410
411
412
413 === define_tristate /symbol/ /word/
414
415 This verb assigns the value of /word/ to /symbol/. Legal input values
416 are "n", "m", and "y".
417
418 As soon as this verb is implemented in all interpreters, please use it
419 instead of define_bool to define tristate values. This aids in static
420 type checking.
421
422 Configure: implemented
423 Menuconfig: implemented
424 Xconfig: implemented
425 mconfig: implemented
426
427 Example:
428
429 # drivers/video/Config.in
430 if [ "$CONFIG_FB_AMIGA" = "y" ]; then
431 define_tristate CONFIG_FBCON_AFB y
432 define_tristate CONFIG_FBCON_ILBM y
433 else
434 if [ "$CONFIG_FB_AMIGA" = "m" ]; then
435 define_tristate CONFIG_FBCON_AFB m
436 define_tristate CONFIG_FBCON_ILBM m
437 fi
438 fi
439
440
441
442 === dep_bool /prompt/ /symbol/ /dep/ ...
443
444 This verb evaluates all of the dependencies in the dependency list.
445 Any dependency which has a value of "y" does not restrict the input
446 range. Any dependency which has an empty value is ignored.
447 Any dependency which has a value of "n", or which has some other value,
448 (like "m") restricts the input range to "n". Quoting dependencies is not
449 allowed. Using dependencies with an empty value possible is not
450 recommended. See also dep_mbool below.
451
452 If the input range is restricted to the single choice "n", dep_bool
453 silently assigns "n" to /symbol/. If the input range has more than
454 one choice, dep_bool displays /prompt/ to the user, accepts a value
455 from the user, and assigns that value to /symbol/.
456
457 Configure: implemented
458 Menuconfig: implemented
459 XConfig: implemented
460 mconfig: implemented
461
462 Example:
463
464 # drivers/net/Config.in
465 dep_bool 'Aironet 4500/4800 PCI support 'CONFIG_AIRONET4500_PCI $CONFIG_PCI
466
467 Known bugs:
468 - Xconfig does not write "# foo is not set" to .config (as well as
469 "#undef foo" to autoconf.h) if command is disabled by its dependencies.
470
471
472 === dep_mbool /prompt/ /symbol/ /dep/ ...
473
474 This verb evaluates all of the dependencies in the dependency list.
475 Any dependency which has a value of "y" or "m" does not restrict the
476 input range. Any dependency which has an empty value is ignored.
477 Any dependency which has a value of "n", or which has some other value,
478 restricts the input range to "n". Quoting dependencies is not allowed.
479 Using dependencies with an empty value possible is not recommended.
480
481 If the input range is restricted to the single choice "n", dep_bool
482 silently assigns "n" to /symbol/. If the input range has more than
483 one choice, dep_bool displays /prompt/ to the user, accepts a value
484 from the user, and assigns that value to /symbol/.
485
486 Notice that the only difference between dep_bool and dep_mbool
487 is in the way of treating the "m" value as a dependency.
488
489 Configure: implemented
490 Menuconfig: implemented
491 XConfig: implemented
492 mconfig: not implemented
493
494 Example:
495
496 # Not from the corpus
497 dep_mbool 'Packet socket: mmapped IO' CONFIG_PACKET_MMAP $CONFIG_PACKET
498
499 Known bugs:
500 - Xconfig does not write "# foo is not set" to .config (as well as
501 "#undef foo" to autoconf.h) if command is disabled by its dependencies.
502
503
504 === dep_hex /prompt/ /symbol/ /word/ /dep/ ...
505 === dep_int /prompt/ /symbol/ /word/ /dep/ ...
506 === dep_string /prompt/ /symbol/ /word/ /dep/ ...
507
508 I am still thinking about the semantics of these verbs.
509
510 Configure: not implemented
511 Menuconfig: not implemented
512 XConfig: not implemented
513 mconfig: not implemented
514
515
516
517 === dep_tristate /prompt/ /symbol/ /dep/ ...
518
519 This verb evaluates all of the dependencies in the dependency list.
520 Any dependency which has a value of "y" does not restrict the input range.
521 Any dependency which has a value of "m" restricts the input range to
522 "m" or "n". Any dependency which has an empty value is ignored.
523 Any dependency which has a value of "n", or which has some other value,
524 restricts the input range to "n". Quoting dependencies is not allowed.
525 Using dependencies with an empty value possible is not recommended.
526
527 If the input range is restricted to the single choice "n", dep_tristate
528 silently assigns "n" to /symbol/. If the input range has more than
529 one choice, dep_tristate displays /prompt/ to the user, accepts a value
530 from the user, and assigns that value to /symbol/.
531
532 Configure: implemented
533 Menuconfig: implemented
534 Xconfig: implemented
535 mconfig: implemented
536
537 Example:
538
539 # drivers/char/Config.in
540 dep_tristate 'Parallel printer support' CONFIG_PRINTER $CONFIG_PARPORT
541
542 Known bugs:
543 - Xconfig does not write "# foo is not set" to .config (as well as
544 "#undef foo" to autoconf.h) if command is disabled by its dependencies.
545
546
547 === unset /symbol/ ...
548
549 This verb assigns the value "" to /symbol/, but does not cause /symbol/
550 to appear in the output. The existence of this verb is a hack; it covers
551 up deeper problems with variable semantics in a random-execution language.
552
553 Configure: implemented
554 Menuconfig: implemented
555 Xconfig: implemented (with bugs)
556 mconfig: implemented
557
558 Example:
559
560 # arch/mips/config.in
561 unset CONFIG_PCI
562 unset CONFIG_MIPS_JAZZ
563 unset CONFIG_VIDEO_G364
564
565
566
567 === choice /prompt/ /word/ /word/
568
569 This verb implements a choice list or "radio button list" selection.
570 It displays /prompt/ to the user, as well as a group of sub-prompts
571 which have corresponding symbols.
572
573 When the user selects a value, the choice verb sets the corresponding
574 symbol to "y" and sets all the other symbols in the choice list to "n".
575
576 The second argument is a single-quoted or double-quoted word that
577 describes a series of sub-prompts and symbol names. The interpreter
578 breaks up the word at white space boundaries into a list of sub-words.
579 The first sub-word is the first prompt; the second sub-word is the
580 first symbol. The third sub-word is the second prompt; the fourth
581 sub-word is the second symbol. And so on, for all the sub-words.
582
583 The third word is a literal word. Its value must be a unique abbreviation
584 for exactly one of the prompts. The symbol corresponding to this prompt
585 is the default enabled symbol.
586
587 Note that because of the syntax of the choice verb, the sub-prompts
588 may not have spaces in them.
589
590 Configure: implemented
591 Menuconfig: implemented
592 Xconfig: implemented
593 mconfig: implemented
594
595 Example:
596
597 # arch/i386/config.in
598 choice ' PCI access mode' \
599 "BIOS CONFIG_PCI_GOBIOS \
600 Direct CONFIG_PCI_GODIRECT \
601 Any CONFIG_PCI_GOANY" Any
602
603
604
605 === nchoice /prompt/ /symbol/ /prompt/ /symbol/ ...
606
607 This verb has the same semantics as the choice verb, but with a sensible
608 syntax.
609
610 The first /prompt/ is the master prompt for the entire choice list.
611
612 The first /symbol/ is the default symbol to enable (notice that this
613 is a symbol, not a unique prompt abbreviation).
614
615 The subsequent /prompt/ and /symbol/ pairs are the prompts and symbols
616 for the choice list.
617
618 Configure: not implemented
619 Menuconfig: not implemented
620 XConfig: not implemented
621 mconfig: implemented
622
623
624
625 === if [ /expr/ ] ; then
626
627 This is a conditional statement, with an optional 'else' clause. You may
628 substitute a newline for the semicolon if you choose.
629
630 /expr/ may contain the following atoms and operators. Note that, unlike
631 shell, you must use double quotes around every atom.
632
633 /atom/:
634 "..." a literal
635 "$..." a variable
636
637 /expr/:
638 /atom/ = /atom/ true if atoms have identical value
639 /atom/ != /atom/ true if atoms have different value
640
641 /expr/:
642 /expr/ -o /expr/ true if either expression is true
643 /expr/ -a /expr/ true if both expressions are true
644 ! /expr/ true if expression is not true
645
646 Note that a naked /atom/ is not a valid /expr/. If you try to use it
647 as such:
648
649 # Do not do this.
650 if [ "$CONFIG_EXPERIMENTAL" ]; then
651 bool 'Bogus experimental feature' CONFIG_BOGUS
652 fi
653
654 ... then you will be surprised, because CONFIG_EXPERIMENTAL never has a
655 value of the empty string! It is always "y" or "n", and both of these
656 are treated as true (non-empty) by the bash-based interpreters Configure
657 and Menuconfig.
658
659 Configure: implemented
660 Menuconfig: implemented
661 XConfig: implemented, with bugs
662 mconfig: implemented
663
664 Xconfig has some known bugs, and probably some unknown bugs too:
665
666 - literals with an empty "" value are not properly handled.
667
668
669
670 === mainmenu_option next_comment
671
672 This verb introduces a new menu. The next statement must have a comment
673 verb. The /prompt/ of that comment verb becomes the title of the menu.
674 (I have no idea why the original designer didn't create a 'menu ...' verb).
675
676 Statements outside the scope of any menu are in the implicit top menu.
677 The title of the top menu comes from a variety of sources, depending on
678 the interpreter.
679
680 Configure: implemented
681 Menuconfig: implemented
682 Xconfig: implemented
683 mconfig: implemented
684
685
686
687 === endmenu
688
689 This verb closes the scope of a menu.
690
691 Configure: implemented
692 Menuconfig: implemented
693 Xconfig: implemented
694 mconfig: implemented
695
696
697
698 === source /word/
699
700 This verb interprets the literal /word/ as a filename, and interpolates
701 the contents of that file. The word must be a single unquoted literal
702 word.
703
704 Some interpreters interpret this verb at run time; some interpreters
705 interpret it at parse time.
706
707 Inclusion is textual inclusion, like the C preprocessor #include facility.
708 The source verb does not imply a submenu or any kind of block nesting.
709
710 Configure: implemented (run time)
711 Menuconfig: implemented (parse time)
712 Xconfig: implemented (parse time)
713 mconfig: implemented (parse time)
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.