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