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