]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - share/man/man7/build.7
MFC 217733: Properly document what the top-level `make tinderbox` does.
[FreeBSD/stable/8.git] / share / man / man7 / build.7
1 .\" Copyright (c) 2000
2 .\"     Mike W. Meyer
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd January 22, 2011
28 .Dt BUILD 7
29 .Os
30 .Sh NAME
31 .Nm build
32 .Nd information on how to build the system
33 .Sh DESCRIPTION
34 The sources for the
35 .Fx
36 system and its applications are contained in three different directories,
37 normally
38 .Pa /usr/src ,
39 .Pa /usr/doc ,
40 and
41 .Pa /usr/ports .
42 Directory
43 .Pa /usr/src
44 contains the
45 .Dq "base system"
46 sources, which is loosely defined as the things required to rebuild
47 the system to a useful state.
48 Directory
49 .Pa /usr/doc
50 contains the source for the system documentation, excluding the manual
51 pages.
52 Directory
53 .Pa /usr/ports
54 contains a tree that provides a consistent interface for building and
55 installing third party applications.
56 For more information about the ports build process, see
57 .Xr ports 7 .
58 .Pp
59 The
60 .Xr make 1
61 command is used in each of these directories to build and install the
62 things in that directory.
63 Issuing the
64 .Xr make 1
65 command in any directory or
66 subdirectory of those directories has the same effect as issuing the
67 same command in all subdirectories of that directory.
68 With no target specified, the things in that directory are just built.
69 .Pp
70 A source tree is allowed to be read-only.
71 As described in
72 .Xr make 1 ,
73 objects are usually built in a separate object directory hierarchy
74 specified by the environment variable
75 .Va MAKEOBJDIRPREFIX ,
76 or under
77 .Pa /usr/obj
78 if variable
79 .Va MAKEOBJDIRPREFIX
80 is not set.
81 For a given source directory, its canonical object directory
82 would be
83 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
84 if
85 .Xr make 1
86 variable
87 .Va MAKEOBJDIRPREFIX
88 is set, or
89 .Pa /usr/obj${.CURDIR}
90 if this variable is not set.
91 Cross-builds set the object directory as described in the
92 documentation for the
93 .Cm buildworld
94 target below.
95 .Pp
96 The build may be controlled by defining
97 .Xr make 1
98 variables described in the
99 .Sx ENVIRONMENT
100 section below, and by the variables documented in
101 .Xr make.conf 5 .
102 .Pp
103 The following list provides the names and actions for the targets
104 supported by the build system:
105 .Bl -tag -width ".Cm cleandepend"
106 .It Cm clean
107 Remove any files created during the build process.
108 .It Cm cleandepend
109 Remove the file
110 .Pa ${.OBJDIR}/${DEPENDFILE}
111 generated by a prior
112 .Dq Li "make depend"
113 step.
114 .It Cm cleandir
115 Remove the canonical object directory if it exists, or perform
116 actions equivalent to
117 .Dq Li "make clean cleandepend"
118 if it does not.
119 This target will also remove an
120 .Pa obj
121 link in
122 .Pa ${.CURDIR}
123 if that exists.
124 .Pp
125 It is advisable to run
126 .Dq Li "make cleandir"
127 twice: the first invocation will remove the canonical object directory
128 and the second one will clean up
129 .Pa ${.CURDIR} .
130 .It Cm depend
131 Generate a list of build dependencies in file
132 .Pa ${.OBJDIR}/${DEPENDFILE} .
133 .It Cm install
134 Install the results of the build to the appropriate location in the
135 installation directory hierarchy specified in variable
136 .Va DESTDIR .
137 .It Cm obj
138 Create the canonical object directory associated with the current
139 directory.
140 .It Cm objlink
141 Create a symbolic link to the canonical object directory in
142 .Pa ${.CURDIR} .
143 .It Cm tags
144 Generate a tags file using the program specified in the
145 .Xr make 1
146 variable
147 .Va CTAGS .
148 The build system supports
149 .Xr ctags 1
150 and
151 .Nm "GNU Global" .
152 .El
153 .Pp
154 The other supported targets under directory
155 .Pa /usr/src
156 are:
157 .Bl -tag -width ".Cm distributeworld"
158 .It Cm buildenv
159 Spawn an interactive shell with environment variables set up for
160 cross-building the system.
161 The target architecture needs to be specified with
162 .Xr make 1
163 variables
164 .Va TARGET_ARCH
165 and
166 .Va TARGET .
167 .Pp
168 This target is only useful after a complete cross-toolchain including
169 the compiler, linker, assembler, headers and libraries has been
170 built; see the
171 .Cm toolchain
172 target below.
173 .It Cm buildworld
174 Build everything but the kernel, configure files in
175 .Pa etc ,
176 and
177 .Pa release .
178 The actual build location prefix used is
179 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
180 for native builds, and
181 .Pa ${MAKEOBJDIRPREFIX}/${TARGET}${.CURDIR}
182 for cross builds and native builds with variable
183 .Va CROSS_BUILD_TESTING
184 set.
185 .It Cm cleanworld
186 Attempt to clean up targets built by a preceding
187 .Cm buildworld
188 step.
189 .It Cm distributeworld
190 Distribute everything compiled by a preceding
191 .Cm buildworld
192 step.
193 Files are placed in the directory hierarchy specified by
194 .Xr make 1
195 variable
196 .Va DISTDIR .
197 This target is used while building a release; see
198 .Xr release 7 .
199 .It Cm installworld
200 Install everything built by a preceding
201 .Cm buildworld
202 step into the directory hierarchy pointed to by
203 .Xr make 1
204 variable
205 .Va DESTDIR .
206 .Pp
207 If installing onto an NFS file system and running
208 .Xr make 1
209 with the
210 .Fl j
211 option, make sure that
212 .Xr rpc.lockd 8
213 is running on both client and server.
214 See
215 .Xr rc.conf 5
216 on how to make it start at boot time.
217 .It Cm toolchain
218 Create the build toolchain needed to build the rest of the system.
219 For cross-architecture builds, this step creates a cross-toolchain.
220 .It Cm universe
221 Execute a
222 .Cm buildworld
223 and
224 .Cm buildkernel
225 for all kernels including
226 .Pa LINT ,
227 for each architecture supported by the build system.
228 This command takes a long time.
229 .It Cm update
230 Get updated sources as configured in
231 .Xr make.conf 5 .
232 .It Cm tinderbox
233 Execute the same targets as
234 .Cm universe .
235 In addition print a summary of all failed targets at the end and
236 exit with an error if there were any.
237 .El
238 .Pp
239 Kernel specific build targets in
240 .Pa /usr/src
241 are:
242 .Bl -tag -width ".Cm reinstallkernel"
243 .It Cm buildkernel
244 Rebuild the kernel and the kernel modules.
245 .It Cm installkernel
246 Install the kernel and the kernel modules to directory
247 .Pa ${DESTDIR}/boot/kernel ,
248 renaming any pre-existing directory with this name to
249 .Pa kernel.old
250 if it contained the currently running kernel.
251 The target directory under
252 .Pa ${DESTDIR}
253 may be modified using the
254 .Va INSTKERNNAME
255 and
256 .Va KODIR
257 .Xr make 1
258 variables.
259 .It Cm kernel
260 Equivalent to
261 .Cm buildkernel
262 followed by
263 .Cm installkernel
264 .It Cm kernel-toolchain
265 Rebuild the tools needed for kernel compilation.
266 Use this if you did not do a
267 .Cm buildworld
268 first.
269 .It Cm reinstallkernel
270 Reinstall the kernel and the kernel modules, overwriting the contents
271 of the target directory.
272 As with the
273 .Cm installkernel
274 target, the target directory can be specified using the
275 .Xr make 1
276 variable
277 .Va INSTKERNNAME .
278 .El
279 .Pp
280 Convenience targets for cleaning up the install destination directory
281 denoted by variable
282 .Va DESTDIR
283 include:
284 .Bl -tag -width ".Cm delete-old-libs"
285 .It Cm check-old
286 Print a list of old files and directories in the system.
287 .It Cm delete-old
288 Delete obsolete base system files and directories interactively.
289 When
290 .Li -DBATCH_DELETE_OLD_FILES
291 is specified at the command line, the delete operation will be
292 non-interactive.
293 The variables
294 .Va DESTDIR ,
295 .Va TARGET_ARCH
296 and
297 .Va TARGET
298 should be set as with
299 .Dq Li "make installworld" .
300 .It Cm delete-old-libs
301 Delete obsolete base system libraries interactively.
302 This target should only be used if no 3rd party software uses these
303 libraries.
304 When
305 .Li -DBATCH_DELETE_OLD_FILES
306 is specified at the command line, the delete operation will be
307 non-interactive.
308 The variables
309 .Va DESTDIR ,
310 .Va TARGET_ARCH
311 and
312 .Va TARGET
313 should be set as with
314 .Dq Li "make installworld" .
315 .El
316 .Sh ENVIRONMENT
317 Variables that influence all builds include:
318 .Bl -tag -width ".Va MAKEOBJDIRPREFIX"
319 .It Va DEBUG_FLAGS
320 Defines a set of debugging flags that will be used to build all userland
321 binaries under
322 .Pa /usr/src .
323 When
324 .Va DEBUG_FLAGS
325 is defined, the
326 .Cm install
327 and
328 .Cm installworld
329 targets install binaries from the current
330 .Va MAKEOBJDIRPREFIX
331 without stripping,
332 so that debugging information is retained in the installed binaries.
333 .It Va DESTDIR
334 The directory hierarchy prefix where built objects will be installed.
335 If not set,
336 .Va DESTDIR
337 defaults to the empty string.
338 .It Va MAKEOBJDIRPREFIX
339 Defines the prefix for directory names in the tree of built objects.
340 Defaults to
341 .Pa /usr/obj
342 if not defined.
343 This variable should only be set in the environment and not via
344 .Pa /etc/make.conf
345 or the command line.
346 .It Va NO_WERROR
347 If defined, compiler warnings will not cause the build to halt,
348 even if the makefile says otherwise.
349 .El
350 .Pp
351 Additionally, builds in
352 .Pa /usr/src
353 are influenced by the following
354 .Xr make 1
355 variables:
356 .Bl -tag -width ".Va SUBDIR_OVERRIDE"
357 .It Va KERNCONF
358 Overrides which kernel to build and install for the various kernel
359 make targets.
360 It defaults to
361 .Cm GENERIC .
362 .It Va KERNFAST
363 If set, the build target
364 .Cm buildkernel
365 defaults to setting 
366 .Va NO_KERNELCLEAN ,
367 .Va NO_KERNELCONFIG ,
368 .Va NO_KERNELDEPEND 
369 and
370 .Va NO_KERNELOBJ .
371 When set to a value other than
372 .Cm 1
373 then 
374 .Va KERNCONF 
375 is set to the value of 
376 .Va KERNFAST .
377 .It Va LOCAL_DIRS
378 If set, this variable supplies a list of additional directories to
379 build, relative to the root of the source tree.
380 .It Va SUBDIR_OVERRIDE
381 Override the default list of sub-directories and only build the
382 sub-directory named in this variable.
383 This variable is useful when debugging failed builds.
384 .Bd -literal -offset indent
385 make some-target SUBDIR_OVERRIDE=foo/bar
386 .Ed
387 .It Va TARGET
388 The target hardware platform.
389 This is analogous to the
390 .Dq Nm uname Fl m
391 output.
392 This is necessary to cross-build some target architectures.
393 For example, cross-building for PC98 machines requires
394 .Va TARGET_ARCH Ns = Ns Li i386
395 and
396 .Va TARGET Ns = Ns Li pc98 .
397 If not set,
398 .Va TARGET
399 defaults to the current hardware platform.
400 .It Va TARGET_ARCH
401 The target machine processor architecture.
402 This is analogous to the
403 .Dq Nm uname Fl p
404 output.
405 Set this to cross-build for a different architecture.
406 If not set,
407 .Va TARGET_ARCH
408 defaults to the current machine architecture, unless 
409 .Va TARGET
410 is also set, in which case it defaults to the appropriate
411 value for that platform.
412 Typically, one only needs to set 
413 .Va TARGET .
414 .El
415 .Pp
416 Builds under directory
417 .Pa /usr/src
418 are also influenced by defining one or more of the following symbols,
419 using the
420 .Fl D
421 option of
422 .Xr make 1 :
423 .Bl -tag -width ".Va -DNO_KERNELDEPEND"
424 .It Va NO_CLEANDIR
425 If set, the build targets that clean parts of the object tree use the
426 equivalent of
427 .Dq make clean
428 instead of
429 .Dq make cleandir .
430 .It Va NO_CLEAN
431 If set, no object tree files are cleaned at all.
432 Setting
433 .Va NO_CLEAN
434 implies
435 .Va NO_KERNELCLEAN ,
436 so when
437 .Va NO_CLEAN
438 is set no kernel objects are cleaned either.
439 .It Va NO_CTF
440 If set, the build process does not run the DTrace CTF conversion tools
441 on built objects.
442 .It Va NO_SHARE
443 If set, the build does not descend into the
444 .Pa /usr/src/share
445 subdirectory (i.e. manpages, locale data files, timezone data files and
446 other
447 .Pa /usr/src/share
448 files will not be rebuild from their sources).
449 .It Va NO_KERNELCLEAN
450 If set, the build process does not run
451 .Dq make clean
452 as part of the
453 .Cm buildkernel
454 target.
455 .It Va NO_KERNELCONFIG
456 If set, the build process does not run
457 .Xr config 8
458 as part of the
459 .Cm buildkernel
460 target.
461 .It Va NO_KERNELDEPEND
462 If set, the build process does not run
463 .Dq make depend
464 as part of the
465 .Cm buildkernel
466 target.
467 .It Va NO_KERNELOBJ
468 If set, the build process does not run
469 .Dq make obj
470 as part of the
471 .Cm buildkernel
472 target.
473 .It Va NO_DOCUPDATE
474 If set, the update process does not update the source of the
475 .Fx
476 documentation as part of the
477 .Dq make update
478 target.
479 .It Va NO_PORTSUPDATE
480 If set, the update process does not update the Ports tree as part of the
481 .Dq make update
482 target.
483 .El
484 .Pp
485 Builds under directory
486 .Pa /usr/doc
487 are influenced by the following
488 .Xr make 1
489 variables:
490 .Bl -tag -width ".Va DOC_LANG"
491 .It Va DOC_LANG
492 If set, restricts the documentation build to the language subdirectories
493 specified as its content.
494 The default action is to build documentation for all languages.
495 .El
496 .Sh FILES
497 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
498 .It Pa /usr/doc/Makefile
499 .It Pa /usr/doc/share/mk/doc.project.mk
500 .It Pa /usr/ports/Mk/bsd.port.mk
501 .It Pa /usr/ports/Mk/bsd.sites.mk
502 .It Pa /usr/share/examples/etc/make.conf
503 .It Pa /usr/src/Makefile
504 .It Pa /usr/src/Makefile.inc1
505 .El
506 .Sh EXAMPLES
507 For an
508 .Dq approved
509 method of updating your system from the latest sources, please see the
510 .Sx COMMON ITEMS
511 section in
512 .Pa src/UPDATING .
513 .Pp
514 The following sequence of commands can be used to cross-build the
515 system for the sparc64 architecture on an i386 host:
516 .Bd -literal -offset indent
517 cd /usr/src
518 make TARGET=sparc64 buildworld
519 make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld
520 .Ed
521 .Sh SEE ALSO
522 .Xr cc 1 ,
523 .Xr install 1 ,
524 .Xr make 1 ,
525 .Xr make.conf 5 ,
526 .Xr src.conf 5 ,
527 .Xr ports 7 ,
528 .Xr release 7 ,
529 .Xr config 8 ,
530 .Xr mergemaster 8 ,
531 .Xr reboot 8 ,
532 .Xr shutdown 8
533 .Sh AUTHORS
534 .An Mike W. Meyer Aq mwm@mired.org .