1.\" $NetBSD: config.1,v 1.19 2015/09/01 16:01:23 uebayasi Exp $ 2.\" 3.\" Copyright (c) 1980, 1991, 1993 4.\" The Regents of the University of California. 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 University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)config.8 8.2 (Berkeley) 4/19/94 31.\" 32.Dd September 1, 2015 33.Dt CONFIG 1 34.Os 35.Sh NAME 36.Nm config 37.Nd build kernel compilation directories 38.Sh SYNOPSIS 39.Nm 40.Op Fl dMPpSv 41.Op Fl b Ar builddir 42.Op Fl D Ar var=value 43.Op Fl s Ar srcdir 44.Op Fl U Ar value 45.Op Ar config-file 46.Nm 47.Fl x 48.Op Ar kernel-file 49.Nm 50.Fl L 51.Op Fl v 52.Op Fl s Ar srcdir 53.Op Ar config-file 54.Sh DESCRIPTION 55In its first synopsis form, 56.Nm 57creates a kernel build directory from the machine description file 58.Ar config-file , 59which describes the system to configure. 60Refer to section 61.Sx KERNEL BUILD CONFIGURATION 62for the details of that use 63of 64.Nm . 65.Pp 66In its second synopsis form, 67.Nm 68takes the binary kernel 69.Ar kernel-file 70as its single argument (aside from the mandatory 71.Fl x 72flag), then extracts the embedded configuration file (if any) and 73writes it to standard output. 74If 75.Ar kernel-file 76is not given, and the system is not running 77.Nx 78an error is printed. 79On systems running 80.Nx 81the booted kernel is looked up using the 82.Xr sysctl 3 83variable 84.Dv machdep.booted_kernel 85and if that is not found, 86.Dv _PATH_UNIX 87.Pq Pa /netbsd 88is used. 89Configuration data will be available if the given kernel was compiled 90with either 91.Va INCLUDE_CONFIG_FILE 92or 93.Va INCLUDE_JUST_CONFIG 94options. 95.Pp 96In its third synopsis form, 97.Nm 98is a tool for the kernel developer and generates a 99.Dq lint 100configuration file to be used during regression testing. 101Refer to section 102.Sx LINT CONFIGURATION 103for the details of that use of 104.Nm . 105.Pp 106.Nm 107accepts the following parameters: 108.Bl -tag -width indent 109.It Fl b Ar builddir 110Use 111.Ar builddir 112as the kernel build directory, instead of computing and creating one 113automatically. 114.It Fl d 115Issue diagnostic output for debugging problems with 116.Nm 117itself. 118More 119.Fl d 120options (currently up to 5) produce more output. 121.It Fl D Ar var=value 122Define a makeoptions variable to the given value. 123This is equivalent to appending a 124.Li makeoptions var=value 125line to the config file. 126.It Fl L 127Generate a lint configuration. 128See section 129.Sx LINT CONFIGURATION 130for details. 131.It Fl M 132Do modular build (experimental). 133Instead of linking all object files (*.o) at once, collect related object 134files into an intermediate relocatable object (*.ko), then link those *.ko 135files into the final kernel. 136This changes the order of objects in the kernel binary. 137.It Fl P 138Pack locators to save space in the resulting kernel binary. 139The amount of space saved that way is so small that this option should 140be considered historical, and of no actual use. 141.It Fl p 142Generate a build directory suited for kernel profiling. 143However, this options should be avoided in favor of the relevant options 144inside the configuration file as described in section 145.Sx KERNEL BUILD CONFIGURATION . 146.It Fl s Ar srcdir 147Point to the top of the kernel source tree. 148It must be an absolute path when 149.Nm 150is used to prepare a kernel build directory, but can be relative 151when it is used in combination with the 152.Fl L 153flag. 154.It Fl S 155Use suffix rules and build objects under subdirectories (experimental). 156.It Fl U Ar var 157Undefine the makeoption 158.Ar var . 159This is equivalent to appending the line 160.Li no makeoptions var 161to the config file. 162.It Fl v 163Increase verbosity by enabling some more warnings. 164.It Fl x 165Extract the configuration embedded in a kernel binary. 166.El 167.Ss KERNEL BUILD CONFIGURATION 168There are several different ways to run the 169.Nm 170program. 171The traditional way is to run 172.Nm 173from the 174.Pa conf 175subdirectory of the machine-specific directory of the system source 176(usually 177.Pa /sys/arch/MACHINE/conf , 178where 179.Pa MACHINE 180is one of 181.Pa vax , 182.Pa hp300 , 183and so forth), and to specify as the 184.Ar config-file 185the name of a machine description file located in that directory. 186.Nm 187will by default create files in the directory 188.Pa ../compile/SYSTEMNAME , 189where 190.Pa SYSTEMNAME 191is the last path component of 192.Ar config-file . 193.Nm 194will assume that the top-level kernel source directory is located four 195directories above the build directory. 196.Pp 197Another way is to create the build directory yourself, place the 198machine description file in the build directory with the name 199.Pa CONFIG , 200and run 201.Nm 202from within the build directory without specifying a 203.Ar config-file . 204.Nm 205will then by default create files in the current directory. 206If you run 207.Nm 208this way, you must specify the location of the top-level kernel source 209directory using the 210.Fl s 211option or by using the 212.Dq Li source 213directive at the beginning of the machine description file. 214.Pp 215Finally, you can specify the build directory for 216.Nm 217and run it from anywhere. 218You can specify a build directory with the 219.Fl b 220option or by using the 221.Dq Li build 222directive at the beginning of the machine description file. 223You must specify the location of the top-level kernel source directory if you 224specify a build directory. 225.Pp 226If 227.Ar config-file 228is a binary kernel, 229.Nm 230will try to extract the configuration file embedded into it, which will 231be present if that kernel was built either with 232.Va INCLUDE_CONFIG_FILE 233or 234.Va INCLUDE_JUST_CONFIG 235options. 236This work mode requires you to manually specify a build directory with 237the 238.Fl b 239option, which implies the need to provide a source tree too. 240.Pp 241If the 242.Fl p 243option is supplied, 244.Pa .PROF 245is appended to the default compilation directory name, and 246.Nm 247acts as if the lines 248.Dq Li makeoptions PROF="-pg" 249and 250.Dq Li options GPROF 251appeared in the machine description file. 252This will build a system that includes profiling code; see 253.Xr kgmon 8 254and 255.Xr gprof 1 . 256The 257.Fl p 258flag is expected to be used for 259.Dq one-shot 260profiles of existing systems; for regular profiling, it is probably 261wiser to create a separate machine description file containing the 262.Li makeoptions 263line. 264.Pp 265The old undocumented 266.Fl g 267flag is no longer supported. 268Instead, use 269.Dq Li makeoptions DEBUG="-g" 270and (typically) 271.Dq Li options KGDB . 272.Pp 273The output of 274.Nm 275consists of a number of files, principally 276.Pa ioconf.c , 277a description of I/O devices that may be attached to the system; and a 278.Pa Makefile , 279used by 280.Xr make 1 281in building the kernel. 282.Pp 283After running 284.Nm , 285it is wise to run 286.Dq Li make depend 287in the directory where the new makefile 288was created. 289.Nm 290prints a reminder of this when it completes. 291.Pp 292If 293.Nm 294stops due to errors, the problems reported should be corrected and 295.Nm 296should be run again. 297.Nm 298attempts to avoid changing the compilation directory 299if there are configuration errors, 300but this code is not well-tested, 301and some problems (such as running out of disk space) 302are unrecoverable. 303.Ss LINT CONFIGURATION 304A so-called 305.Dq lint 306configuration should include everything from the kernel that can 307possibly be selected. 308The rationale is to provide a way to reach all the code a user might 309select, in order to make sure all options and drivers compile without 310error for a given source tree. 311.Pp 312When used with the 313.Fl L 314flag, 315.Nm 316takes the regular configuration file 317.Ar config-file 318and prints on the standard output a configuration file that includes 319.Ar config-file , 320selects all options and file-systems the user can possibly select, 321and defines an instance of every possible attachment as described by 322the kernel option definition files used by 323.Ar config-file . 324.Pp 325The resulting configuration file is meant as a way to select all 326possible features in order to test that each of them compiles. 327It is not meant to result in a kernel binary that can run on any 328hardware. 329.Pp 330Unlike the first synopsis form, the provided 331.Ar srcdir 332is relative to the current working directory. 333In the first synopsis form, it is relative to the build directory. 334.Sh SEE ALSO 335The SYNOPSIS portion of each device in section 4. 336.\".Rs 337.\" .%T "Building 4.4 BSD Systems with Config" 338.\" .%T "Device Support in 4.4BSD" 339.\".Re 340.Pp 341.Xr options 4 , 342.Xr config 5 , 343.Xr config 9 344.Sh HISTORY 345The 346.Nm 347command appeared in 348.Bx 4.1 . 349It was completely revised in 350.Bx 4.4 . 351The 352.Fl x 353option appeared in 354.Nx 2.0 . 355The 356.Fl L 357option appeared in 358.Nx 5.0 . 359