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