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