xref: /netbsd-src/usr.bin/config/config.5 (revision 11a6dbe72840351315e0652b2fc6663628c84cad)
1.\" $NetBSD: config.5,v 1.15 2008/04/30 13:11:00 martin Exp $
2.\"
3.\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
4.\"  All rights reserved.
5.\"
6.\"  Redistribution and use in source and binary forms, with or without
7.\"  modification, are permitted provided that the following conditions
8.\"  are met:
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.
14.\"
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.
26.\"
27.Dd November 9, 2007
28.Dt CONFIG 5
29.Os
30.Sh NAME
31.Nm config
32.Nd kernel configuration file syntax
33.Sh DESCRIPTION
34The kernel configuration file specifies the way the kernel should be compiled
35by the rest of the toolchain.
36It is processed by
37.Xr config 1
38to produce a number of files that will allow the user to compile a possibly
39customised kernel.
40One compilation can issue several kernel binaries, with different root and
41dump devices configurations, or with full debugging information.
42.Pp
43This manual page is intended to serve as a complete reference of all aspects
44of the syntax used in the many files processed by
45.Xr config 1 .
46The novice user will prefer looking at the examples given in
47.Xr config.samples 5
48in order to understand better how the default configuration can be changed,
49and how all of its elements interact with each other.
50.Pp
51The kernel configuration file actually contains the description of all the
52options, drivers and source files involved in the kernel compilation, and the
53logic that binds them.
54The
55.Ic machine
56statement, usually found in the
57.Pa std.${MACHINE}
58file, hides this from the user by automatically including all the descriptive
59files spread all around the kernel source tree, the main one being
60.Pa conf/files .
61.Pp
62Thus, the kernel configuration file contains two parts:
63the description of the compilation options, and the selection of those options.
64However, it begins with a small preamble that controls a couple of options of
65.Xr config 1 ,
66and a few statements belong to any of the two sections.
67.Pp
68The user controls the options selection part, which is located in a file
69commonly referenced as the
70.Em main configuration file
71or simply the
72.Em kernel configuration file .
73The developer is responsible for describing the options in the relevant files
74from the kernel source tree.
75.Pp
76Statements are separated by new-line characters.
77However, new-line characters can appear in the middle of a given statement,
78with the value of a space character.
79.Ss OBJECTS AND NAMES
80.Xr config 1
81is a rather complicated piece of software that tries to comply with any
82configuration the user might think of.
83Quite a few different objects are manipulated through the kernel configuration
84file, therefore some definitions are needed.
85.Ss Options and attributes
86The basic objects driving the kernel compilation are
87.Em options ,
88and are called
89.Ar attributes
90in some contexts.
91An
92.Ar attribute
93usually refers to a feature a given piece of hardware might have.
94However, the scope of an attribute is rather wide and can just be a place
95holder to group some source files together.
96.Pp
97There is a special class of attribute, named
98.Em interface attribute ,
99which represents a hook that allows a device to attach to (i.e., be a child of)
100another device.
101An
102.Em interface attribute
103has a (possibly empty) list of
104.Ar locators
105to match the actual location of a device.
106For example, on a PCI bus, devices are located by a
107.Em device number
108that is fixed by the wiring of the motherboard.
109Additionally, each of those devices can appear through several interfaces named
110.Em functions .
111A single PCI device entity is a unique function number of a given device from
112the considered PCI bus.
113Therefore, the locators for a
114.Xr pci 4
115device are
116.Ar dev
117(for device), and
118.Ar function .
119.Pp
120A
121.Ar locator
122can either be a single integer value, or an array of integer values.
123It can have a default value, in which case it can be wildcarded with a
124.Dq \&?
125in the options selection section of the configuration file.
126A single
127.Ar locator
128definition can take one of the following forms:
129.Bl -enum -offset indent -compact
130.It
131.Ar locator
132.It
133.Ar locator
134=
135.Ar value
136.It
137.Ar locator Ns Oo Ar length Oc
138.It
139.Ar locator Ns Oo Ar length Oc = Brq Ar value , ...
140.El
141The variants that specify a default value can be enclosed into square brackets,
142in which case the locator will not have to be specified later in the options
143selection section of the configuration file.
144.Pp
145In the options selection section, the locators are specified when declaring an
146instance as a space-separated list of
147.Dq Ao Ar locator Ac Ao Ar value Ac
148where value can be the
149.Dq \&?
150wildcard if the locator allows it.
151.Ss Devices, instances and attachments
152The main benefit of the kernel configuration file is to allow the user to avoid
153compiling some drivers, and wire down the configuration of some others.
154We have already seen that devices attach to each other through
155.Em interface attributes ,
156but not everything can attach to anything.
157Furthermore, the user has the ability to define precise instances for the
158devices.
159An
160.Ar instance
161is simply the reality of a device when it is probed and attached by the kernel.
162.Pp
163Each driver has a name for its devices.
164It is called the base device name and is found as
165.Ar base
166in this documentation.
167An
168.Ar instance
169is the concatenation of a device name and a number.
170In the kernel configuration file, instances can sometimes be wildcarded
171(i.e., the number is replaced by a
172.Dq *
173or a
174.Dq \&? )
175in order to match all the possible instances of a device.
176.Pp
177The usual
178.Dq *
179becomes a
180.Dq \&?
181when the instance name is used as an
182.Em attachment name .
183In the options selection part of the kernel configuration files, an
184.Em attachment
185is an
186.Em interface attribute
187concatenated with a number or the wildcard
188.Dq \&? .
189.Ss Pseudo-devices
190Some components of the kernel behave like a device although they don't have
191any actual reality in the hardware.
192For example, this is the case for special network devices, such as
193.Xr tun 4
194and
195.Xr tap 4 .
196They are integrated in the kernel as pseudo-devices, and can have several
197instances and even children, just like normal devices.
198.Ss Dependencies
199The options description part of the kernel configuration file contains all the
200logic that ties the source files together, and it is done first through writing
201down dependencies between
202.Xr config 1
203objects.
204.Pp
205In this documentation, the syntax for
206.Ar dependencies
207is a comma-separated list of
208.Ar options
209and
210.Ar attributes .
211.Pp
212For example, the use of an Ethernet network card requires the source files that
213handle the specificities of that protocol.
214Therefore, all Ethernet network card drivers depend on the
215.Ar ether
216attribute.
217.Ss Conditions
218Finally, source file selection is possible through the help of
219conditionals, referred to as
220.Ar condition
221later in this documentation.
222The syntax for those conditions uses well-known operators (
223.Dq \*[Am] ,
224.Dq |
225and
226.Dq \&! )
227to combine
228.Ar options
229and
230.Ar attributes .
231.Ss CONTEXT NEUTRAL STATEMENTS
232.Bl -ohang
233.It Ic version Ar yyyymmdd
234Indicates the syntax version used by the rest of the file, or until the next
235.Ic version
236statement.
237The argument is an ISO date.
238A given
239.Xr config 1
240binary might only be compatible with a limited range of version numbers.
241.It Ic include Ar path
242Includes a file.
243The path is relative to the top of the kernel source tree, or the inner-most
244defined
245.Ic prefix .
246.It Ic cinclude Ar path
247Conditionally includes a file.
248Contrary to
249.Ic include ,
250it will not produce an error if the file does not exist.
251The argument obeys the same rules as for
252.Ic include .
253.It Ic prefix Op Ar path
254If
255.Ar path
256is given, it pushes a new prefix for
257.Ic include
258and
259.Ic cinclude .
260.Ic prefix
261statements act like a stack, and an empty
262.Ar path
263argument has the latest prefix popped out.
264The
265.Ar path
266argument is either absolute or relative to the current defined prefix, which
267defaults 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
272.It Ic else
273.It Ic endif
274Conditionally interprets portions of the current file.
275Those statements depend on whether or not the given
276.Ar attribute
277has been previously defined, through
278.Ic define
279or any other statement that implicitely defines attributes such as
280.Ic device .
281.El
282.Ss PREAMBLE
283In addition to
284.Ic include , cinclude ,
285and
286.Ic prefix ,
287the preamble may contain the following optional statements:
288.Bl -ohang
289.It Ic build Ar path
290Defines the build directory for the compilation of the kernel.
291It replaces the default of
292.Pa ../compile/\*[Lt]config-file\*[Gt]
293and is superseded by the
294.Fl b
295parameter of
296.Xr config 1 .
297.It Ic source Ar path
298Defines the directory in which the source of the kernel lives.
299It replaces the default of
300.Pa ../../../..
301and is superseded by the
302.Fl s
303parameter of
304.Xr config 1 .
305.El
306.Ss OPTIONS DESCRIPTION
307The user will not usually have to use descriptive statements, as they are meant
308for the developer to tie a given piece of code to the rest of the kernel.
309However, third parties may provide sources to add to the kernel compilation,
310and the logic that binds them to the
311.Nx
312kernel will have to be added to the user-edited configuration file.
313.Bl -ohang
314.It Ic devclass Ar class
315Defines a special attribute, named
316.Em device class .
317A given device cannot belong to more than one device class.
318.Xr config 1
319translates that property by the rule that a device cannot depend on more than
320one device class, and will properly fill the configuration information file it
321generates according to that value.
322.It Ic defflag Oo Ar file Oc Ar option Oo Ar option Oo Ar ... Oc Oc \
323    Op : Ar dependencies
324Defines a boolean option, that can either be selected or be un-selected by the
325user with the
326.Ic options
327statement.
328The optional
329.Ar file
330argument names a header file that will contain the C pre-processor definition
331for the option.
332If no file name is given, it will default to
333.Ar opt_\*[Lt]option\*[Gt].h .
334.Xr config 1
335will always create the header file, but if the user choose not to select the
336option, it will be empty.
337Several options can be combined in one header file, for convenience.
338The header file is created in the compilation directory, making them directly
339accessible 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
342Behaves like
343.Ic defflag ,
344except the defined option must have a value.
345Such options are not typed:
346they can have either a numeric or a string value.
347If a
348.Ar value
349is specified, it is treated as a default, and the option is
350always defined in the corresponding header file.
351If a
352.Ar lint-value
353is specified,
354.Xr config 1
355will use it as a value when generating a lint configuration with
356.Fl L ,
357and ignore it in all other cases.
358.It Ic deffs Oo Ar file Oc Ar name Op Ar name Op Ar ...
359Defines a file-system name.
360It is no more than a regular option, as defined by
361.Ic defflag ,
362but it allows the user to select the
363file-systems to be compiled in the kernel with the
364.Ic file-system
365statement instead of the
366.Ic options
367statement, and
368.Xr config 1
369will enforce the rule that the user must select at least one file-system.
370.It Ic obsolete defflag Oo Ar file Oc Ar option Op Ar option Op Ar ...
371.It Ic obsolete defparam Oo Ar file Oc Ar option Op Ar option Op Ar ...
372Those two statements are identical and mark the listed option names as
373obsolete.
374If the user selects one of the listed options in the kernel configuration
375file,
376.Xr config 1
377will emit a warning and ignore the option.
378The optional
379.Ar file
380argument should match the original definition of the option.
381.It Ic define Ar attribute Oo Bro Ar locators Brc Oc Oo : Ar dependencies Oc
382Defines an
383.Ar attribute .
384The
385.Ar locators
386list is optional, and can be empty.
387If the pair of brackets are present, the locator list is defined and the
388declared attribute becomes an
389.Em interface attribute ,
390on which devices can attach.
391.It Ic maxpartitions Ar number
392Defines the maximum number of partitions the disklabels for the considered
393architecture can hold.
394This statement cannot be repeated and should only appear in the
395.Pa std\&.$\&{ARCH\&}
396file.
397.It Ic maxusers Ar min default max
398Indicates the range of values that will later be accepted by
399.Xr config 1
400for the
401.Ic maxusers
402statement in the options selection part of the configuration file.
403In case the user doesn't include a
404.Ic maxusers
405statement in the configuration file, the value
406.Ar default
407is used instead.
408.It Ic device Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
409Declares a device of name
410.Ar base .
411The optional list of
412.Ar locators ,
413which can also be empty, indicates the device can have children attached
414directly to it.
415Internally, that means
416.Ar base
417becomes an
418.Ar interface attribute .
419For every device the user selects,
420.Xr config 1
421will add the matching
422.Fn CFDRIVER_DECL
423statement to
424.Pa ioconf.c .
425However, it is the responsibility of the developer to add the relevant
426.Fn CFATTACH_DECL
427line to the source of the device's driver.
428.It Ic attach Ar base Ic at Ar attr Oo , Ar attr Oo , Ar ... Oc Oc Oo Ic with \
429    Ar name Oc Oo : dependencies Oc
430All devices must have at least one declared attachment.
431Otherwise, they will never be found in the
432.Xr autoconf 9
433process.
434The attributes on which an instance of device
435.Ar base
436can attach must be
437.Ar interface attributes ,
438or
439.Ic root
440in case the device is at the top-level, which is usually the case of e.g.,
441.Xr mainbus 4 .
442The instances of device
443.Ar base
444will later attach to one interface attribute from the specified list.
445.Pp
446Different
447.Ic attach
448definitions must use different names using the
449.Ic with
450option.
451It is then possible to use the associated
452.Ar name
453as a conditional element in a
454.Ic file
455statement.
456.It Ic defpseudo Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
457Declares a pseudo-device.
458Those devices don't need an attachment to be declared, they will always be
459attached if they were selected by the user.
460As normal devices, an optional list of
461.Ar locators
462can be defined, allowing the pseudo-device to have children.
463.It Ic file Ar path Oo Ar condition Oc Oo Ic needs-count Oc \
464    Oo Ic needs-flag Oc Op Ic compile with Ar rule
465Adds a source file to the list of files to be compiled into the kernel, if the
466.Ar conditions
467are met.
468The
469.Ic needs-count
470option indicates that the source file requires the number of all the countable
471objects it depends on (through the
472.Ar conditions )
473to be defined.
474It is usually used for
475.Ar pseudo-devices
476whose number can be specified by the user in the
477.Ic pseudo-device
478statement.
479Countable objects are devices and pseudo-devices.
480For the former, the count is the number of declared instances.
481For the latter, it is the number specified by the user, defaulting to 1.
482The
483.Ic needs-flag
484options requires that a flag indicating the selection of an attribute to
485be created, but the precise number isn't needed.
486This is useful for source files that only partly depend on the attribute,
487and thus need to add pre-processor statements for it.
488.Pp
489.Ic needs-count
490and
491.Ic needs-flag
492both produce a header file for each of the considered attributes.
493The name of that file is
494.Pa \*[Lt]attribute\*[Gt].h .
495It contains one pre-processor definition of
496.Dv NATTRIBUTE
497set to 0 if the attribute was not selected by the user, or to the number of
498instances of the device in the
499.Ic needs-count
500case, or to 1 in all the other cases.
501.Pp
502The
503.Ar rule
504argument specifies the
505.Xr make 1
506rule that will be used to compile the source file.
507If it is not given, the default rule for the type of the file will be used.
508For a given file, there can be more than one
509.Ic file
510statement, but not from the same configuration source file, and all later
511statements can only specify a
512.Ar rule
513argument, and no
514.Ar conditions
515or flags.
516This is useful when a file needs special consideration from one particular
517architecture.
518.It Ic object Ar path Op Ar condition
519Adds an object file to the list of objects to be linked into the kernel, if the
520.Ar conditions
521are met.
522This is most useful for third parties providing binary-only components.
523.It Ic device-major Ar base Oo Ic char Ar number Oc Oo Ic block Ar number Oc \
524    Op Ar condition
525Associates a major device number with the device
526.Ar base .
527A device can be a character device, a block device, or both, and can have
528different numbers for each.
529The
530.Ar condition
531indicates when the relevant line should be added to
532.Pa ioconf.c ,
533and works just like the
534.Ic file
535statement.
536.It Ic makeoptions Ar condition name Ns += Ns Ar value Op , Ar condition \
537    name Ns += Ns Ar value
538Appends to a definition in the generated
539.Pa Makefile .
540.El
541.Ss OPTIONS SELECTION
542.Bl -ohang
543.It Ic machine Ar machine Op Ar arch Op Ar subarch Op Ar ...
544The
545.Ic machine
546statement should appear first in the kernel configuration file, with the
547exception of context-neutral statements.
548It makes
549.Xr config 1
550include, in that order, the following files:
551.Bl -enum -offset indent -compact
552.It
553.Pa conf/files
554.It
555.Pa arch/${ARCH}/conf/files.${ARCH}
556if defined
557.It
558.Pa arch/${SUBARCH}/conf/files.${SUBARCH}
559for each defined sub-architecture
560.It
561.Pa arch/${MACHINE}/conf/files.${MACHINE}
562.El
563It also defines an attribute for the
564.Ar machine ,
565the
566.Ar arch
567and each of the
568.Ar subarch .
569.It Ic package Ar path
570Simpler version of:
571.Bd -literal -offset indent
572prefix PATH
573include FILE
574prefix
575.Ed
576.It Ic ident Ar string
577Defines the indentification string of the kernel.
578This statement is optional, and the name of the main configuration file will be
579used as a default value.
580.It Ic maxusers Ar number
581Despite its name, this statement does not limit the maximum number of users on
582the system.
583There is no such limit, actually.
584However, some kernel structures need to be adjusted to accommodate with more
585users, and the
586.Ic maxusers
587parameter is used for example to compute the maximum number of opened files,
588and the maximum number of processes, which itself is used to adjust a few
589other parameters.
590.It Ic options Ar name Oo = Ar value Oc Op , Ar name Oo = Ar \
591    value Oc , Ar ...
592Selects the option
593.Ar name ,
594affecting it a
595.Ar value
596if the options requires it (see the
597.Ic defflag
598and
599.Ic defparam
600statements).
601.Pp
602If the option has not been declared in the options description part of the
603kernel configuration machinery, it will be added as a pre-processor definition
604when source files are compiled.
605.It Ic no options Ar name Op , Ar name Op , Ar ...
606Un-selects the option
607.Ar name .
608If option
609.Ar name
610has not been previously selected, the statement produces an error.
611.It Oo Ic no Oc Ic file-system Ar name Op , Ar name Op , Ar ...
612Adds or removes support for all the listed file-systems.
613A kernel must have support for at least one file-system.
614.It Ic config Ar name Ic root on Ar device Oo Ic type Ar fs Oc Op Ic dumps on \
615    Ar device
616Adds
617.Ar name
618to the list of kernel binaries to compile from the configuration file, using
619the specified root and dump devices information.
620.Pp
621Any of the
622.Ar device
623and
624.Ar fs
625parameters can be wildcarded with
626.Dq \&?
627to let the kernel automatically discover those values.
628.Pp
629At least one
630.Ic config
631statement must appear in the configuration file.
632.It Ic no config Ar name
633Removes
634.Ar name
635from the list of kernel binaries to compile from the configuration file.
636.It Ar instance Ic at Ar attachment Op Ar locator specification
637Configures an instance of a device attaching at a specific location in the
638device tree.
639All parameters can be wildcarded, with a
640.Dq *
641for
642.Ar instance ,
643and a
644.Dq \&?
645for
646.Ar attachment
647and the locators.
648.It Ic no Ar instance Op Ic at Ar attachment
649Removes the previously configured instances of a device that exactly match the
650given specification.
651If two instances differ only by their locators, both are removed.
652If no
653.Ar attachment
654is specified, all matching instances are removed.
655.Pp
656If
657.Ar instance
658is a bare device name, all the previously defined instances of that device,
659regardless of the numbers or wildcard, are removed.
660.It Ic no device at Ar attachment
661Removes all previously configured instances that attach to the specified
662attachment.
663If
664.Ar attachment
665ends with a
666.Dq * ,
667all instances attaching to all the variants of
668.Ar attachment
669are removed.
670.It Ic pseudo-device Ar device Op Ar number
671Adds support for the specified pseudo-device.
672The parameter
673.Ar number
674is passed to the initialisation function of the pseudo-device, usually to
675indicate how many instances should be created.
676It defaults to 1, and some pseudo-devices ignore that parameter.
677.It Ic no pseudo-device Ar name
678Removes support for the specified pseudo-device.
679.It Ic makeoptions Ar name Ns = Ns value Op , Ar name Ns += Ns value \
680    Op , Ar ...
681Adds or appends to a definition in the generated
682.Pa Makefile .
683A definition cannot be overriden, it must be removed before it can be added
684again.
685.It Ic no makeoptions Ar name Op , Ar name Op , Ar ...
686Removes one or more definitions from the generated
687.Pa Makefile .
688.El
689.Sh FILES
690The files are relative to the kernel source top directory (e.g.,
691.Pa /usr/src/sys ) .
692.Pp
693.Bl -tag -width arch/${MACHINE}/conf/std.${MACHINE}
694.It Pa arch/${MACHINE}/conf/std.${MACHINE}
695Standard configuration for the given architecture.
696This file should always be included.
697.It Pa arch/${MACHINE}/conf/GENERIC
698Standard options selection file for the given architecture.
699Users should always start changing their main kernel configuration file by
700editing a copy of this file.
701.It Pa conf/files
702Main options description file.
703.El
704.Sh EXAMPLES
705.Xr config.samples 5
706uses several examples to cover all the practical aspects of writing or
707modifying a kernel configuration file.
708.Sh SEE ALSO
709.Xr config 1 ,
710.Xr options 4 ,
711.Xr config.samples 5 ,
712.Xr config 9
713