]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - share/man/man7/build.7
MFC r225858, 225859, 226172:
[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 September 29, 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 For each architecture,
222 execute a
223 .Cm buildworld
224 followed by a
225 .Cm buildkernel
226 for all kernels for that architecture,
227 including
228 .Pa LINT .
229 This command takes a long time.
230 .It Cm update
231 Get updated sources as configured in
232 .Xr make.conf 5 .
233 .It Cm tinderbox
234 Execute the same targets as
235 .Cm universe .
236 In addition print a summary of all failed targets at the end and
237 exit with an error if there were any.
238 .It Cm toolchains
239 Create a build toolchain for each architecture supported by the build system.
240 .El
241 .Pp
242 Kernel specific build targets in
243 .Pa /usr/src
244 are:
245 .Bl -tag -width ".Cm reinstallkernel"
246 .It Cm buildkernel
247 Rebuild the kernel and the kernel modules.
248 .It Cm installkernel
249 Install the kernel and the kernel modules to directory
250 .Pa ${DESTDIR}/boot/kernel ,
251 renaming any pre-existing directory with this name to
252 .Pa kernel.old
253 if it contained the currently running kernel.
254 The target directory under
255 .Pa ${DESTDIR}
256 may be modified using the
257 .Va INSTKERNNAME
258 and
259 .Va KODIR
260 .Xr make 1
261 variables.
262 .It Cm kernel
263 Equivalent to
264 .Cm buildkernel
265 followed by
266 .Cm installkernel
267 .It Cm kernel-toolchain
268 Rebuild the tools needed for kernel compilation.
269 Use this if you did not do a
270 .Cm buildworld
271 first.
272 .It Cm reinstallkernel
273 Reinstall the kernel and the kernel modules, overwriting the contents
274 of the target directory.
275 As with the
276 .Cm installkernel
277 target, the target directory can be specified using the
278 .Xr make 1
279 variable
280 .Va INSTKERNNAME .
281 .El
282 .Pp
283 Convenience targets for cleaning up the install destination directory
284 denoted by variable
285 .Va DESTDIR
286 include:
287 .Bl -tag -width ".Cm delete-old-libs"
288 .It Cm check-old
289 Print a list of old files and directories in the system.
290 .It Cm delete-old
291 Delete obsolete base system files and directories interactively.
292 When
293 .Li -DBATCH_DELETE_OLD_FILES
294 is specified at the command line, the delete operation will be
295 non-interactive.
296 The variables
297 .Va DESTDIR ,
298 .Va TARGET_ARCH
299 and
300 .Va TARGET
301 should be set as with
302 .Dq Li "make installworld" .
303 .It Cm delete-old-libs
304 Delete obsolete base system libraries interactively.
305 This target should only be used if no 3rd party software uses these
306 libraries.
307 When
308 .Li -DBATCH_DELETE_OLD_FILES
309 is specified at the command line, the delete operation will be
310 non-interactive.
311 The variables
312 .Va DESTDIR ,
313 .Va TARGET_ARCH
314 and
315 .Va TARGET
316 should be set as with
317 .Dq Li "make installworld" .
318 .El
319 .Sh ENVIRONMENT
320 Variables that influence all builds include:
321 .Bl -tag -width ".Va MAKEOBJDIRPREFIX"
322 .It Va DEBUG_FLAGS
323 Defines a set of debugging flags that will be used to build all userland
324 binaries under
325 .Pa /usr/src .
326 When
327 .Va DEBUG_FLAGS
328 is defined, the
329 .Cm install
330 and
331 .Cm installworld
332 targets install binaries from the current
333 .Va MAKEOBJDIRPREFIX
334 without stripping,
335 so that debugging information is retained in the installed binaries.
336 .It Va DESTDIR
337 The directory hierarchy prefix where built objects will be installed.
338 If not set,
339 .Va DESTDIR
340 defaults to the empty string.
341 .It Va MAKEOBJDIRPREFIX
342 Defines the prefix for directory names in the tree of built objects.
343 Defaults to
344 .Pa /usr/obj
345 if not defined.
346 This variable should only be set in the environment and not via
347 .Pa /etc/make.conf
348 or the command line.
349 .It Va NO_WERROR
350 If defined, compiler warnings will not cause the build to halt,
351 even if the makefile says otherwise.
352 .El
353 .Pp
354 Additionally, builds in
355 .Pa /usr/src
356 are influenced by the following
357 .Xr make 1
358 variables:
359 .Bl -tag -width ".Va SUBDIR_OVERRIDE"
360 .It Va KERNCONF
361 Overrides which kernel to build and install for the various kernel
362 make targets.
363 It defaults to
364 .Cm GENERIC .
365 .It Va KERNFAST
366 If set, the build target
367 .Cm buildkernel
368 defaults to setting
369 .Va NO_KERNELCLEAN ,
370 .Va NO_KERNELCONFIG ,
371 .Va NO_KERNELDEPEND
372 and
373 .Va NO_KERNELOBJ .
374 When set to a value other than
375 .Cm 1
376 then
377 .Va KERNCONF
378 is set to the value of
379 .Va KERNFAST .
380 .It Va LOCAL_DIRS
381 If set, this variable supplies a list of additional directories to
382 build, relative to the root of the source tree.
383 .It Va PORTS_MODULES
384 A list of ports with kernel modules that should be built and installed
385 as part of the
386 .Cm buildkernel
387 and
388 .Cm installkernel
389 process.
390 .Bd -literal -offset indent
391 make PORTS_MODULES=emulators/kqemu-kmod kernel
392 .Ed
393 .It Va SUBDIR_OVERRIDE
394 Override the default list of sub-directories and only build the
395 sub-directory named in this variable.
396 This variable is useful when debugging failed builds.
397 .Bd -literal -offset indent
398 make some-target SUBDIR_OVERRIDE=foo/bar
399 .Ed
400 .It Va TARGET
401 The target hardware platform.
402 This is analogous to the
403 .Dq Nm uname Fl m
404 output.
405 This is necessary to cross-build some target architectures.
406 For example, cross-building for PC98 machines requires
407 .Va TARGET_ARCH Ns = Ns Li i386
408 and
409 .Va TARGET Ns = Ns Li pc98 .
410 If not set,
411 .Va TARGET
412 defaults to the current hardware platform.
413 .It Va TARGET_ARCH
414 The target machine processor architecture.
415 This is analogous to the
416 .Dq Nm uname Fl p
417 output.
418 Set this to cross-build for a different architecture.
419 If not set,
420 .Va TARGET_ARCH
421 defaults to the current machine architecture, unless
422 .Va TARGET
423 is also set, in which case it defaults to the appropriate
424 value for that platform.
425 Typically, one only needs to set
426 .Va TARGET .
427 .El
428 .Pp
429 Builds under directory
430 .Pa /usr/src
431 are also influenced by defining one or more of the following symbols,
432 using the
433 .Fl D
434 option of
435 .Xr make 1 :
436 .Bl -tag -width ".Va -DNO_KERNELDEPEND"
437 .It Va NO_CLEANDIR
438 If set, the build targets that clean parts of the object tree use the
439 equivalent of
440 .Dq make clean
441 instead of
442 .Dq make cleandir .
443 .It Va NO_CLEAN
444 If set, no object tree files are cleaned at all.
445 Setting
446 .Va NO_CLEAN
447 implies
448 .Va NO_KERNELCLEAN ,
449 so when
450 .Va NO_CLEAN
451 is set no kernel objects are cleaned either.
452 .It Va NO_CTF
453 If set, the build process does not run the DTrace CTF conversion tools
454 on built objects.
455 .It Va NO_SHARE
456 If set, the build does not descend into the
457 .Pa /usr/src/share
458 subdirectory (i.e. manpages, locale data files, timezone data files and
459 other
460 .Pa /usr/src/share
461 files will not be rebuild from their sources).
462 .It Va NO_KERNELCLEAN
463 If set, the build process does not run
464 .Dq make clean
465 as part of the
466 .Cm buildkernel
467 target.
468 .It Va NO_KERNELCONFIG
469 If set, the build process does not run
470 .Xr config 8
471 as part of the
472 .Cm buildkernel
473 target.
474 .It Va NO_KERNELDEPEND
475 If set, the build process does not run
476 .Dq make depend
477 as part of the
478 .Cm buildkernel
479 target.
480 .It Va NO_KERNELOBJ
481 If set, the build process does not run
482 .Dq make obj
483 as part of the
484 .Cm buildkernel
485 target.
486 .It Va NO_DOCUPDATE
487 If set, the update process does not update the source of the
488 .Fx
489 documentation as part of the
490 .Dq make update
491 target.
492 .It Va NO_PORTSUPDATE
493 If set, the update process does not update the Ports tree as part of the
494 .Dq make update
495 target.
496 .El
497 .Pp
498 Builds under directory
499 .Pa /usr/doc
500 are influenced by the following
501 .Xr make 1
502 variables:
503 .Bl -tag -width ".Va DOC_LANG"
504 .It Va DOC_LANG
505 If set, restricts the documentation build to the language subdirectories
506 specified as its content.
507 The default action is to build documentation for all languages.
508 .El
509 .Pp
510 Builds using the
511 .Cm universe
512 target are influenced by the following
513 .Xr make 1
514 variables:
515 .Bl -tag -width ".Va MAKE_JUST_KERNELS"
516 .It Va JFLAG
517 Pass the value of this variable to each
518 .Xr make 1
519 invocation used to build worlds and kernels.
520 This can be used to enable multiple jobs within a single architecture's build
521 while still building each architecture serially.
522 .It Va MAKE_JUST_KERNELS
523 Only build kernels for each supported architecture.
524 .It Va MAKE_JUST_WORLDS
525 Only build worlds for each supported architecture.
526 .It Va UNIVERSE_TARGET
527 Execute the specified
528 .Xr make 1
529 target for each supported architecture instead of the default action of
530 building a world and one or more kernels.
531 .El
532 .Sh FILES
533 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
534 .It Pa /usr/doc/Makefile
535 .It Pa /usr/doc/share/mk/doc.project.mk
536 .It Pa /usr/ports/Mk/bsd.port.mk
537 .It Pa /usr/ports/Mk/bsd.sites.mk
538 .It Pa /usr/share/examples/etc/make.conf
539 .It Pa /usr/src/Makefile
540 .It Pa /usr/src/Makefile.inc1
541 .El
542 .Sh EXAMPLES
543 For an
544 .Dq approved
545 method of updating your system from the latest sources, please see the
546 .Sx COMMON ITEMS
547 section in
548 .Pa src/UPDATING .
549 .Pp
550 The following sequence of commands can be used to cross-build the
551 system for the sparc64 architecture on an i386 host:
552 .Bd -literal -offset indent
553 cd /usr/src
554 make TARGET=sparc64 buildworld
555 make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld
556 .Ed
557 .Sh SEE ALSO
558 .Xr cc 1 ,
559 .Xr install 1 ,
560 .Xr make 1 ,
561 .Xr make.conf 5 ,
562 .Xr src.conf 5 ,
563 .Xr ports 7 ,
564 .Xr release 7 ,
565 .Xr config 8 ,
566 .Xr mergemaster 8 ,
567 .Xr reboot 8 ,
568 .Xr shutdown 8
569 .Sh AUTHORS
570 .An Mike W. Meyer Aq mwm@mired.org .