1 .\" $NetBSD: config.5,v 1.19 2009/02/20 05:22:59 cube Exp $
3 .\" Copyright (c) 2006, 2007 The NetBSD Foundation.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
32 .Nd kernel configuration file syntax
34 The kernel configuration file specifies the way the kernel should be compiled
35 by the rest of the toolchain.
38 to produce a number of files that will allow the user to compile a possibly
40 One compilation can issue several kernel binaries, with different root and
41 dump devices configurations, or with full debugging information.
43 This manual page is intended to serve as a complete reference of all aspects
44 of the syntax used in the many files processed by
46 The novice user will prefer looking at the examples given in
48 in order to understand better how the default configuration can be changed,
49 and how all of its elements interact with each other.
51 The kernel configuration file actually contains the description of all the
52 options, drivers and source files involved in the kernel compilation, and the
53 logic that binds them.
56 statement, usually found in the
58 file, hides this from the user by automatically including all the descriptive
59 files spread all around the kernel source tree, the main one being
62 Thus, the kernel configuration file contains two parts:
63 the description of the compilation options, and the selection of those options.
64 However, it begins with a small preamble that controls a couple of options of
66 and a few statements belong to any of the two sections.
68 The user controls the options selection part, which is located in a file
69 commonly referenced as the
70 .Em main configuration file
72 .Em kernel configuration file .
73 The developer is responsible for describing the options in the relevant files
74 from the kernel source tree.
76 Statements are separated by new-line characters.
77 However, new-line characters can appear in the middle of a given statement,
78 with the value of a space character.
81 is a rather complicated piece of software that tries to comply with any
82 configuration the user might think of.
83 Quite a few different objects are manipulated through the kernel configuration
84 file, therefore some definitions are needed.
85 .Ss Options and attributes
86 The basic objects driving the kernel compilation are
93 usually refers to a feature a given piece of hardware might have.
94 However, the scope of an attribute is rather wide and can just be a place
95 holder to group some source files together.
97 There is a special class of attribute, named
98 .Em interface attribute ,
99 which represents a hook that allows a device to attach to (i.e., be a child of)
102 .Em interface attribute
103 has a (possibly empty) list of
105 to match the actual location of a device.
106 For example, on a PCI bus, devices are located by a
108 that is fixed by the wiring of the motherboard.
109 Additionally, each of those devices can appear through several interfaces named
111 A single PCI device entity is a unique function number of a given device from
112 the considered PCI bus.
113 Therefore, the locators for a
122 can either be a single integer value, or an array of integer values.
123 It can have a default value, in which case it can be wildcarded with a
125 in the options selection section of the configuration file.
128 definition can take one of the following forms:
129 .Bl -enum -offset indent -compact
137 .Ar locator Ns Oo Ar length Oc
139 .Ar locator Ns Oo Ar length Oc = Brq Ar value , ...
141 The variants that specify a default value can be enclosed into square brackets,
142 in which case the locator will not have to be specified later in the options
143 selection section of the configuration file.
145 In the options selection section, the locators are specified when declaring an
146 instance as a space-separated list of
147 .Dq Ao Ar locator Ac Ao Ar value Ac
148 where value can be the
150 wildcard if the locator allows it.
151 .Ss Devices, instances and attachments
152 The main benefit of the kernel configuration file is to allow the user to avoid
153 compiling some drivers, and wire down the configuration of some others.
154 We have already seen that devices attach to each other through
155 .Em interface attributes ,
156 but not everything can attach to anything.
157 Furthermore, the user has the ability to define precise instances for the
161 is simply the reality of a device when it is probed and attached by the kernel.
163 Each driver has a name for its devices.
164 It is called the base device name and is found as
166 in this documentation.
169 is the concatenation of a device name and a number.
170 In the kernel configuration file, instances can sometimes be wildcarded
171 (i.e., the number is replaced by a
175 in order to match all the possible instances of a device.
181 when the instance name is used as an
182 .Em attachment name .
183 In the options selection part of the kernel configuration files, an
186 .Em interface attribute
187 concatenated with a number or the wildcard
190 Some components of the kernel behave like a device although they don't have
191 any actual reality in the hardware.
192 For example, this is the case for special network devices, such as
196 They are integrated in the kernel as pseudo-devices, and can have several
197 instances and even children, just like normal devices.
199 The options description part of the kernel configuration file contains all the
200 logic that ties the source files together, and it is done first through writing
201 down dependencies between
205 In this documentation, the syntax for
207 is a comma-separated list of
212 For example, the use of an Ethernet network card requires the source files that
213 handle the specificities of that protocol.
214 Therefore, all Ethernet network card drivers depend on the
218 Finally, source file selection is possible through the help of
219 conditionals, referred to as
221 later in this documentation.
222 The syntax for those conditions uses well-known operators (
231 .Ss CONTEXT NEUTRAL STATEMENTS
233 .It Ic version Ar yyyymmdd
234 Indicates the syntax version used by the rest of the file, or until the next
237 The argument is an ISO date.
240 binary might only be compatible with a limited range of version numbers.
241 .It Ic include Ar path
243 The path is relative to the top of the kernel source tree, or the inner-most
246 .It Ic cinclude Ar path
247 Conditionally includes a file.
250 it will not produce an error if the file does not exist.
251 The argument obeys the same rules as for
253 .It Ic prefix Op Ar path
256 is given, it pushes a new prefix for
261 statements act like a stack, and an empty
263 argument has the latest prefix popped out.
266 argument is either absolute or relative to the current defined prefix, which
267 defaults to the top of ther kernel source tree.
268 .It Ic ifdef Ar attribute
269 .It Ic ifndef Ar attribute
270 .It Ic elifdef Ar attribute
271 .It Ic elifndef Ar attribute
274 Conditionally interprets portions of the current file.
275 Those statements depend on whether or not the given
277 has been previously defined, through
279 or any other statement that implicitely defines attributes such as
284 .Ic include , cinclude ,
287 the preamble may contain the following optional statements:
290 Defines the build directory for the compilation of the kernel.
291 It replaces the default of
292 .Pa ../compile/\*[Lt]config-file\*[Gt]
293 and is superseded by the
297 .It Ic source Ar path
298 Defines the directory in which the source of the kernel lives.
299 It replaces the default of
301 and is superseded by the
306 .Ss OPTIONS DESCRIPTION
307 The user will not usually have to use descriptive statements, as they are meant
308 for the developer to tie a given piece of code to the rest of the kernel.
309 However, third parties may provide sources to add to the kernel compilation,
310 and the logic that binds them to the
312 kernel will have to be added to the user-edited configuration file.
314 .It Ic devclass Ar class
315 Defines a special attribute, named
317 A given device cannot belong to more than one device class.
319 translates that property by the rule that a device cannot depend on more than
320 one device class, and will properly fill the configuration information file it
321 generates according to that value.
322 .It Ic defflag Oo Ar file Oc Ar option Oo Ar option Oo Ar ... Oc Oc \
324 Defines a boolean option, that can either be selected or be un-selected by the
330 argument names a header file that will contain the C pre-processor definition
332 If no file name is given, it will default to
333 .Ar opt_\*[Lt]option\*[Gt].h .
335 will always create the header file, but if the user choose not to select the
336 option, it will be empty.
337 Several options can be combined in one header file, for convenience.
338 The header file is created in the compilation directory, making them directly
339 accessible by source files.
340 .It Ic defparam Oo Ar file Oc Ar option Oo = Ar value Oc \
341 Oo := Ar lint-value Oc Oo Ar option Oo Ar ... Oc Oc Op : Ar dependencies
344 except the defined option must have a value.
345 Such options are not typed:
346 they can have either a numeric or a string value.
349 is specified, it is treated as a default, and the option is
350 always defined in the corresponding header file.
355 will use it as a value when generating a lint configuration with
357 and ignore it in all other cases.
358 .It Ic deffs Oo Ar file Oc Ar name Op Ar name Op Ar ...
359 Defines a file-system name.
360 It is no more than a regular option, as defined by
362 but it allows the user to select the
363 file-systems to be compiled in the kernel with the
365 statement instead of the
368 .It Ic obsolete defflag Oo Ar file Oc Ar option Op Ar option Op Ar ...
369 .It Ic obsolete defparam Oo Ar file Oc Ar option Op Ar option Op Ar ...
370 Those two statements are identical and mark the listed option names as
372 If the user selects one of the listed options in the kernel configuration
375 will emit a warning and ignore the option.
378 argument should match the original definition of the option.
379 .It Ic define Ar attribute Oo Bro Ar locators Brc Oc Oo : Ar dependencies Oc
384 list is optional, and can be empty.
385 If the pair of brackets are present, the locator list is defined and the
386 declared attribute becomes an
387 .Em interface attribute ,
388 on which devices can attach.
389 .It Ic maxpartitions Ar number
390 Defines the maximum number of partitions the disklabels for the considered
391 architecture can hold.
392 This statement cannot be repeated and should only appear in the
393 .Pa std\&.$\&{ARCH\&}
395 .It Ic maxusers Ar min default max
396 Indicates the range of values that will later be accepted by
400 statement in the options selection part of the configuration file.
401 In case the user doesn't include a
403 statement in the configuration file, the value
406 .It Ic device Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
407 Declares a device of name
411 which can also be empty, indicates the device can have children attached
413 Internally, that means
416 .Ar interface attribute .
417 For every device the user selects,
419 will add the matching
423 However, it is the responsibility of the developer to add the relevant
425 line to the source of the device's driver.
426 .It Ic attach Ar base Ic at Ar attr Oo , Ar attr Oo , Ar ... Oc Oc Oo Ic with \
427 Ar name Oc Oo : dependencies Oc
428 All devices must have at least one declared attachment.
429 Otherwise, they will never be found in the
432 The attributes on which an instance of device
435 .Ar interface attributes ,
438 in case the device is at the top-level, which is usually the case of e.g.,
440 The instances of device
442 will later attach to one interface attribute from the specified list.
446 definitions must use different names using the
449 It is then possible to use the associated
451 as a conditional element in a
454 .It Ic defpseudo Ar base Oo : dependencies Oc
455 Declares a pseudo-device.
456 Those devices don't need an attachment to be declared, they will always be
457 attached if they were selected by the user.
458 .It Ic defpseudodev Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
459 Declares a pseudo-device.
460 Those devices don't need an attachment to be declared, they will always be
461 attached if they were selected by the user.
462 This declaration should be used if the pseudodevice uses
464 functions to manage its instances or attach children.
465 As for normal devices, an optional list of
467 can be defined, which implies an interface attribute named
469 allowing the pseudo-device to have children.
470 Interface attributes can also be defined in the
473 .It Ic file Ar path Oo Ar condition Oc Oo Ic needs-count Oc \
474 Oo Ic needs-flag Oc Op Ic compile with Ar rule
475 Adds a source file to the list of files to be compiled into the kernel, if the
480 option indicates that the source file requires the number of all the countable
481 objects it depends on (through the
484 It is usually used for
486 whose number can be specified by the user in the
489 Countable objects are devices and pseudo-devices.
490 For the former, the count is the number of declared instances.
491 For the latter, it is the number specified by the user, defaulting to 1.
494 options requires that a flag indicating the selection of an attribute to
495 be created, but the precise number isn't needed.
496 This is useful for source files that only partly depend on the attribute,
497 and thus need to add pre-processor statements for it.
502 both produce a header file for each of the considered attributes.
503 The name of that file is
504 .Pa \*[Lt]attribute\*[Gt].h .
505 It contains one pre-processor definition of
507 set to 0 if the attribute was not selected by the user, or to the number of
508 instances of the device in the
510 case, or to 1 in all the other cases.
514 argument specifies the
516 rule that will be used to compile the source file.
517 If it is not given, the default rule for the type of the file will be used.
518 For a given file, there can be more than one
520 statement, but not from the same configuration source file, and all later
521 statements can only specify a
526 This is useful when a file needs special consideration from one particular
528 .It Ic object Ar path Op Ar condition
529 Adds an object file to the list of objects to be linked into the kernel, if the
532 This is most useful for third parties providing binary-only components.
533 .It Ic device-major Ar base Oo Ic char Ar number Oc Oo Ic block Ar number Oc \
535 Associates a major device number with the device
537 A device can be a character device, a block device, or both, and can have
538 different numbers for each.
541 indicates when the relevant line should be added to
543 and works just like the
546 .It Ic makeoptions Ar condition name Ns += Ns Ar value Op , Ar condition \
547 name Ns += Ns Ar value
548 Appends to a definition in the generated
551 .Ss OPTIONS SELECTION
553 .It Ic machine Ar machine Op Ar arch Op Ar subarch Op Ar ...
556 statement should appear first in the kernel configuration file, with the
557 exception of context-neutral statements.
560 include, in that order, the following files:
561 .Bl -enum -offset indent -compact
565 .Pa arch/${ARCH}/conf/files.${ARCH}
568 .Pa arch/${SUBARCH}/conf/files.${SUBARCH}
569 for each defined sub-architecture
571 .Pa arch/${MACHINE}/conf/files.${MACHINE}
573 It also defines an attribute for the
579 .It Ic package Ar path
581 .Bd -literal -offset indent
586 .It Ic ident Ar string
587 Defines the indentification string of the kernel.
588 This statement is optional, and the name of the main configuration file will be
589 used as a default value.
590 .It Ic maxusers Ar number
591 Despite its name, this statement does not limit the maximum number of users on
593 There is no such limit, actually.
594 However, some kernel structures need to be adjusted to accommodate with more
597 parameter is used for example to compute the maximum number of opened files,
598 and the maximum number of processes, which itself is used to adjust a few
600 .It Ic options Ar name Oo = Ar value Oc Op , Ar name Oo = Ar \
606 if the options requires it (see the
612 If the option has not been declared in the options description part of the
613 kernel configuration machinery, it will be added as a pre-processor definition
614 when source files are compiled.
615 .It Ic no options Ar name Op , Ar name Op , Ar ...
616 Un-selects the option
620 has not been previously selected, the statement produces an error.
621 .It Oo Ic no Oc Ic file-system Ar name Op , Ar name Op , Ar ...
622 Adds or removes support for all the listed file-systems.
623 .It Ic config Ar name Ic root on Ar device Oo Ic type Ar fs Oc Op Ic dumps on \
627 to the list of kernel binaries to compile from the configuration file, using
628 the specified root and dump devices information.
634 parameters can be wildcarded with
636 to let the kernel automatically discover those values.
640 statement must appear in the configuration file.
641 .It Ic no config Ar name
644 from the list of kernel binaries to compile from the configuration file.
645 .It Ar instance Ic at Ar attachment Op Ar locator specification
646 Configures an instance of a device attaching at a specific location in the
648 All parameters can be wildcarded, with a
657 .It Ic no Ar instance Op Ic at Ar attachment
658 Removes the previously configured instances of a device that exactly match the
660 If two instances differ only by their locators, both are removed.
663 is specified, all matching instances are removed.
667 is a bare device name, all the previously defined instances of that device,
668 regardless of the numbers or wildcard, are removed.
669 .It Ic no device at Ar attachment
670 Removes all previously configured instances that attach to the specified
676 all instances attaching to all the variants of
679 .It Ic pseudo-device Ar device Op Ar number
680 Adds support for the specified pseudo-device.
683 is passed to the initialisation function of the pseudo-device, usually to
684 indicate how many instances should be created.
685 It defaults to 1, and some pseudo-devices ignore that parameter.
686 .It Ic no pseudo-device Ar name
687 Removes support for the specified pseudo-device.
688 .It Ic makeoptions Ar name Ns = Ns value Op , Ar name Ns += Ns value \
690 Adds or appends to a definition in the generated
692 A definition cannot be overriden, it must be removed before it can be added
694 .It Ic no makeoptions Ar name Op , Ar name Op , Ar ...
695 Removes one or more definitions from the generated
699 The files are relative to the kernel source top directory (e.g.,
702 .Bl -tag -width arch/${MACHINE}/conf/std.${MACHINE}
703 .It Pa arch/${MACHINE}/conf/std.${MACHINE}
704 Standard configuration for the given architecture.
705 This file should always be included.
706 .It Pa arch/${MACHINE}/conf/GENERIC
707 Standard options selection file for the given architecture.
708 Users should always start changing their main kernel configuration file by
709 editing a copy of this file.
711 Main options description file.
715 uses several examples to cover all the practical aspects of writing or
716 modifying a kernel configuration file.
720 .Xr config.samples 5 ,