forked from NetBSD/src
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBUILDING.mdoc
1992 lines (1992 loc) · 39.9 KB
/
BUILDING.mdoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.\" $NetBSD: BUILDING.mdoc,v 1.150 2024/04/26 17:38:44 rillig Exp $
.\"
.\" Copyright (c) 2001-2023 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Todd Vierling and Luke Mewburn.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\" NOTE: After changing this file, run "make regen" in the src/doc
.\" directory, and check in both src/BUILDING and src/doc/BUILDING.mdoc.
.\"
.\" Toolchain prefix for commands
.ds toolprefix nb
.
.Dd July 21, 2023
.Dt BUILDING 8
.Os NetBSD
.\" turn off hyphenation
.hym 999
.
.\" if this file is processed with real roff (doc.tmac)
.\" now that the tmac files have been lazily read,
.\" we can override ``quotes'' with "quotes" for ascii output
.ie '\*[Lq]'``' \{\
.ds Lq \*q
.ds Rq \*q
.\}
.\" and disable hyphenation
.nr hyphen-flags 0
.
.Sh NAME
.
.Nm BUILDING
.Nd Procedure for building
.Nx
from source code
.
.Sh REQUIREMENTS
.
.Nx
is designed to be buildable on most POSIX-compliant host systems.
The basic build procedure is the same whether compiling
.Em natively
(on the same
.Nx
architecture) or
.Em cross compiling
(on another architecture or OS).
.Pp
This source tree contains the
.Sy build.sh
shell script which supports both native and cross builds of
.Nx .
.Pp
This source tree contains a special subtree,
.Dq tools ,
which uses the host system to create a build toolchain for the target
architecture.
The host system must have at least C and C++
compilers in order to create the toolchain
.Xr ( make 1
is not required); all other tools
(including
.Xr make 1
as
.Sy \*[toolprefix]make )
are created as part of the
.Nx
build process.
(See the
.Sx Environment variables
section below if you need
to override or manually select your compilers.)
.Pp
.Em Note :
Within this document, cross-references to manual pages are to the
.Nx
manual pages, not the host system manual pages.
The
.Xr mdoc 7
source
to the
.Nx
manual pages can be found within the source tree,
and these and can be formatted with
.Xr mandoc 1
or
.Xr nroff 1
if those are available on the host system.
The
.Nx
manual pages are also available at
.Lk https://man.netbsd.org
.
.Sh FILES
.
.Ss Source tree layout
.
.Bl -tag -width "BUILDING.mdoc"
.
.It Pa BUILDING
This document (in plaintext).
Generated from
.Pa doc/BUILDING.mdoc .
.
.It Pa Makefile
The main Makefile for
.Nx ;
should only be run for native builds with an appropriately up-to-date
version of
.Nx
.Xr make 1 .
Intended for expert use with knowledge of its shortcomings,
it has been superseded by the
.Sy build.sh
shell script as the recommended means for building
.Nx .
.
.It Pa UPDATING
Special notes for updating from an earlier revision of
.Nx .
It is important to read this file before every build of an updated
source tree.
.
.It Pa build.sh
Bourne-compatible shell script used for building the host build tools
and the
.Nx
system from scratch.
Can be used for both native and cross builds, and should be used instead of
.Xr make 1
as it performs additional checks to prevent common issues going undetected, such
as building with an outdated version of
.Xr make 1 .
.
.It Pa crypto/dist/ , dist/ , gnu/dist/
Sources imported verbatim from third parties, without mangling the
existing build structure.
Other source trees in
.Pa bin
through
.Pa usr.sbin
use the
.Nx
.Xr make 1
.Dq reachover
Makefile semantics when building these programs for a native host.
.
.It Pa distrib/ , etc/
Sources for items used when making a full release snapshot, such as
files installed in
.Sy DESTDIR Ns Pa /etc
on the destination system, boot media, and release notes.
.
.It Pa doc/BUILDING.mdoc
The source to this document, in
.Xr mdoc 7
format.
Used to generate
.Pa BUILDING .
.
.It Pa external/ , sys/external/
Sources and build infrastructure for components imported (mostly) unchanged
from upstream maintainers, sorted by applicable license.
This is (slowly) replacing the
.Pa crypto/dist ,
.Pa dist ,
and
.Pa gnu/dist
directories.
.
.It Pa external/mit/xorg/
.Dq Reachover
build structure for modular Xorg; the source is in
.Sy X11SRCDIR .
.
.It Pa mk.conf
Optional source tree specific
.Xr mk.conf 5 ,
used (if present) instead of
.Pa /etc/mk.conf
unless
.Sy MAKECONF
is defined.
.Pp
.Em Note :
Not part of the
.Nx
source repository.
.
.It Pa regress/ , tests/
Regression test harness.
Can be cross-compiled, but only run natively.
.Pa tests/
uses the
.Xr atf 7
test framework;
.Pa regress/
contains older tests that have not yet been migrated to
.Xr atf 7 .
.
.It Pa sys/
.Nx
kernel sources.
.
.It Pa tools/
.Dq Reachover
build structure for the host build tools.
This has a special method of determining out-of-date status.
.
.It Pa tools/compat/README
Special notes for cross-hosting a NetBSD build on non-NetBSD platforms.
.
.It Other directories including Pa bin/ ... usr.sbin/
Sources to the
.Nx
userland (non-kernel) programs.
If any of these directories are missing, they will be skipped during the build.
.
.El
.
.Ss Build tree layout
.
The
.Nx
build tree is described in
.Xr hier 7
(whose
.Xr mdoc 7
source is in
.Pa share/man/man7/hier.7 ) ,
and the release layout is described in
.Xr release 7
(whose
.Xr mdoc 7
source is in
.Pa share/man/man7/release.7 ) .
.
.Sh CONFIGURATION
.
.Ss Environment variables
.
.de DFLT
.Pp
.Em Default :
..
.de DFLTn
.DFLT
.Dq no .
..
.de DFLTu
.DFLT
Unset.
..
.de DFLTy
.DFLT
.Dq yes .
..
.de NODEF
.Pp
Forced to
.Dq no
if
.Sy \\$*
is defined,
usually in the Makefile before any
.Xr make 1
.Cm \&.include
directives.
..
.de NOVAR
.Pp
Forced to
.Dq no
if
.Sy \\$* .
..
.de YorN
Can be set to
.Dq yes
or
.Dq no .
..
.
Several environment variables control the behaviour of
.Nx
builds.
.
.Bl -tag -width 14n
.
.\" These entries are sorted alphabetically.
.
.It Sy HOST_CC
Path name to C compiler used to create the toolchain.
.DFLT
.Dq cc .
.
.It Sy HOST_CFLAGS
Flags passed to the host C compiler.
.DFLT
.Dq \&-O .
.
.It Sy HOST_CPPFLAGS
Flags passed to the host C/C++ pre-processor.
.DFLTu
.
.It Sy HOST_CXX
Path name to C++ compiler used to create the toolchain.
.DFLT
Unset, but defaults to
.Dq c++
where required.
.
.It Sy HOST_CXXFLAGS
Flags passed to the host C++ compiler.
.DFLTu
.
.It Sy HOST_SH
Path name to a shell available on the host system
and suitable for use during the build.
The
.Nx
build system requires a modern Bourne-like shell
with POSIX-compliant features,
and also requires support for the
.Dq local
keyword to declare local variables in shell functions
(which is a widely-implemented but non-standardised feature).
.Pp
Depending on the host system, a suitable shell may be
.Pa /bin/sh ,
.Pa /usr/xpg4/bin/sh ,
.Pa /bin/ksh
(provided it is a variant of ksh that supports the
.Dq local
keyword,
such as ksh88, but not ksh93),
or
.Pa /usr/local/bin/bash .
.Pp
Most parts of the build require
.Sy HOST_SH
to be an absolute path; however,
.Sy build.sh
allows it to be a simple command name, which will be converted
to an absolute path by searching the
.Ev PATH .
.DFLT
.Dq sh .
.
.It Sy INSTALLBOOT_UBOOT_PATHS
A colon-separated list of search paths used by
.Xr installboot 8
to find U-Boot packages.
.DFLTu
.
.It Sy MACHINE
Machine type, e.g.,
.Dq macppc .
.DFLTu
.
.It Sy MACHINE_ARCH
Machine architecture, e.g.,
.Dq powerpc .
.DFLTu
.
.It Sy MAKE
Path name to invoke
.Xr make 1
as.
.DFLT
.Dq make .
.
.It Sy MAKECONF
The name of the
.Xr make 1
configuration file.
See
.Sx make variables
and
.Xr mk.conf 5 .
.Pp
.Em Note :
Only settable in the process environment.
.DFLT
.Dq Pa /etc/mk.conf ,
although
.Sy build.sh
will set the default to the full path to
.Pa mk.conf
if the latter is present in the same directory as
.Sy build.sh .
.
.It Sy MAKEFLAGS
Flags to invoke
.Xr make 1
with.
.Pp
.Em Note :
.Sy build.sh
ignores the value of
.Sy MAKEFLAGS
passed in the environment, but allows
.Sy MAKEFLAGS
to be set via the
.Fl V
option.
.DFLT
.Dq \&-X
on systems with a small
.Dv ARG_MAX
(Cygwin, Darwin, FreeBSD);
otherwise unset.
.
.It Sy MAKEOBJDIR
Directory to use as the
.Sy .OBJDIR
for the current directory.
The value is subjected to variable expansion by
.Xr make 1 .
Typical usage is to set this variable to a value involving the use of
.Sq ${.CURDIR:S...}
or
.Sq ${.CURDIR:C...} ,
to derive the value of
.Sy .OBJDIR
from the value of
.Sy .CURDIR .
Used only if
.Sy MAKEOBJDIRPREFIX
is not defined.
.Pp
.Em Note :
.Sy MAKEOBJDIR
can be provided only in the environment or via the
.Fl O
flag of
.Sy build.sh ;
it cannot usefully be set inside a Makefile, including in
.Xr mk.conf 5
or
.Sy MAKECONF .
.DFLTu
.
.It Sy MAKEOBJDIRPREFIX
Top level directory of the object directory tree.
The value is subjected to variable expansion by
.Xr make 1 .
.Sy build.sh
will create the
${MAKEOBJDIRPREFIX}
directory if necessary, but if
.Xr make 1
is used without
.Sy build.sh ,
then rules in
.Aq bsd.obj.mk
will abort the build if the
${MAKEOBJDIRPREFIX}
directory does not exist.
If the value is defined and valid, then
${MAKEOBJDIRPREFIX}/${.CURDIR}
is used as the
.Sy .OBJDIR
for the current directory.
The current directory may be read only.
.Pp
.Em Note :
.Sy MAKEOBJDIRPREFIX
can be provided only in the environment or via the
.Fl M
flag of
.Sy build.sh ;
it cannot usefully be set inside a Makefile, including in
.Xr mk.conf 5
or
.Sy MAKECONF .
.DFLTu
.
.It Ev TMPDIR
Top-level directory to store temporary directories used by
.Sy build.sh
before paths to other directories such as
.Sy .OBJDIR
can be determined.
.Pp
.Em Note :
Must support execution of binaries.
I.e., without
.Xr mount 8 Ns 's
.Fl o
.Cm noexec
option.
.DFLT
.Dq Pa /tmp .
.
.El
.
.Ss make variables
.
Variables that control the behavior of
.Nx
builds are documented in
.Xr mk.conf 5
(whose
.Xr mdoc 7
source is in
.Pa share/man/man5/mk.conf.5 ) .
.Pp
Unless otherwise specified, these variables may be set in
either the process environment or the
.Xr make 1
configuration file
.Xr mk.conf 5
specified by
.Sy MAKECONF .
.Pp
.Em Note :
Variables set in the environment, either directly or via
.Sy build.sh
options to set specific values in the
.Sy \*[toolprefix]make- Ns Sy MACHINE
wrapper script do not override variables set in the
.Xr mk.conf 5
file.
To allow variables in
.Xr mk.conf 5
to be overridden by the environment or
.Sy build.sh
options, define the variables using the
.Dq Li ?=
.Xr make 1
variable assignment operator.
For example,
.Bd -unfilled -offset indent
.Li MAKEVERBOSE?=1
.Ed
.Pp
The supported
.Xr mk.conf 5
make variables are:
.\" Keep in sync with share/man/man5/mk.conf.5 section NETBSD SYSTEM VARIABLES
.Bd -ragged -offset indent
.Sy BSDOBJDIR ,
.Sy BSDSRCDIR ,
.Sy BUILD ,
.Sy BUILDID ,
.Sy BUILDINFO ,
.Sy BUILDSEED ,
.Sy CDEXTRA ,
.Sy CONFIGOPTS ,
.Sy COPTS ,
.Sy CPUFLAGS ,
.Sy DESTDIR ,
.Sy EXTERNAL_TOOLCHAIN ,
.Sy INSTALLBOOT_BOARDS ,
.Sy INSTALLWORLDDIR ,
.Sy KERNARCHDIR ,
.Sy KERNCONFDIR ,
.Sy KERNEL_DIR ,
.Sy KERNOBJDIR ,
.Sy KERNSRCDIR ,
.Sy LOCALTIME ,
.Sy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USE_SSP ,
.Sy USE_XZ_SETS ,
.Sy USE_YP ,
.Sy X11MOTIFPATH ,
.Sy X11SRCDIR .
.Ed
.Pp
The obsolete
.Xr mk.conf 5
make variables are:
.\" Keep in sync with share/man/man5/mk.conf.5 section OBSOLETE VARIABLES
.Bd -ragged -offset indent
.Sy EXTSRCSRCDIR ,
.Sy MKBFD ,
.Sy MKCRYPTO ,
.Sy MKEXTSRC ,
.Sy MKKDEBUG ,
.Sy MKKERBEROS4 ,
.Sy MKLLD ,
.Sy MKLLDB ,
.Sy MKMCLINKER ,
.Sy MKPERFUSE ,
.Sy MKTOOLSDEBUG ,
.Sy NBUILDJOBS ,
.Sy SHAREDSTRINGS ,
.Sy USE_COMBINE ,
.Sy USE_NEW_TOOLCHAIN .
.Ed
.
.Sh BUILDING
.
.Ss make command line options
This is not a summary of all the options available to
.Xr make 1 ;
only the options used most frequently with
.Nx
builds are listed here.
.
.Bl -tag -width "var=value"
.
.It Fl j Ar njob
Run up to
.Ar njob
.Xr make 1
subjobs in parallel.
Makefiles should use .WAIT or have explicit dependencies
as necessary to enforce build ordering.
.
.It Fl m Ar dir
Specify the default directory for searching for system Makefile
segments, mainly the
.Aq bsd.*.mk
files.
When building any full
.Nx
source tree, this should be set to the
.Dq Pa share/mk
directory in the source tree.
This is set automatically when building from the top level, or when using
.Sy build.sh .
.
.It Fl n
Show the commands that would have been executed, but do not
actually execute them.
This will still cause recursion to take place.
.
.It Fl V Ar var
Show
.Xr make 1 Ns 's
idea of the value of
.Ar var .
Does not build any targets.
.
.It Ar var Ns Sy = Ns Ar value
Set the variable
.Ar var
to
.Ar value ,
overriding any setting specified by the process environment, the
.Sy MAKECONF
configuration file, or the system Makefile segments.
.
.El
.
.Ss make targets
.
These default targets may be built by running
.Xr make 1
in any subtree of the
.Nx
source code.
It is recommended that none of these be used from the top
level Makefile; as a specific exception,
.Dq make obj
and
.Dq make cleandir
are useful in that context.
.
.Bl -tag -width "dependall"
.
.It Sy all
Build programs, libraries, and preformatted documentation.
.
.It Sy clean
Remove program and library object code files.
.
.It Sy cleandir
Same as
.Sy clean ,
but also remove preformatted documentation, dependency files generated
by
.Dq make depend ,
and any other files known to be created at build time.
.
.It Sy depend
Create dependency files
.Pa ( .depend )
containing more detailed information about the dependencies of source
code on header files.
Allows programs to be recompiled automatically when a dependency changes.
.
.It Sy dependall
Does a
.Dq make depend
immediately followed by a
.Dq make all .
This improves cache locality of the build since both passes read the source
files in their entirety.
.
.It Sy distclean
Synonym for
.Sy cleandir .
.
.It Sy includes
Build and install system header files.
Typically needed before any system libraries or programs can be built.
.
.It Sy install
Install programs, libraries, and documentation into
.Sy DESTDIR .
Few files will be installed to
.Sy DESTDIR Ns Pa /dev ,
.Sy DESTDIR Ns Pa /etc ,
.Sy DESTDIR Ns Pa /root
or
.Sy DESTDIR Ns Pa /var
in order to prevent user supplied configuration data from being overwritten.
.It Sy lint
Run
.Xr lint 1
against the C source code, where appropriate, and generate
system-installed lint libraries.
.
.It Sy obj
Create object directories to be used for built files, instead of
building directly in the source tree.
.
.It Sy tags
Create
.Xr ctags 1
searchable function lists usable by the
.Xr ex 1
and
.Xr vi 1
text editors.
.
.El
.
.Ss make targets for the top level
.
Additional
.Xr make 1
targets are usable specifically from the top source level to facilitate
building the entire
.Nx
source tree.
.
.Bl -tag -width "distribution"
.
.It Sy build
Build the entire
.Nx
system (except the kernel).
This orders portions of the source tree such that prerequisites
will be built in the proper order.
.
.It Sy distribution
Do a
.Dq make build ,
and then install a full distribution (which does not include a kernel) into
.Sy DESTDIR ,
including files in
.Sy DESTDIR Ns Pa /dev ,
.Sy DESTDIR Ns Pa /etc ,
.Sy DESTDIR Ns Pa /root
and
.Sy DESTDIR Ns Pa /var .
.
.It Sy buildworld
As per
.Dq make distribution ,
except that it ensures that
.Sy DESTDIR
is not the root directory.
.
.It Sy installworld
Install the distribution from
.Sy DESTDIR
to
.Sy INSTALLWORLDDIR ,
which defaults to the root directory.
Ensures that
.Sy INSTALLWORLDDIR
is not the root directory if cross compiling.
.Pp
The
.Sy INSTALLSETS
environment variable may be set to a space-separated list of
distribution sets to be installed.
By default, all sets except
.Dq etc
and
.Dq xetc
are installed, so most files in
.Sy INSTALLWORLDDIR Ns Pa /etc
will not be installed or modified.
.Pp
.Em Note :
Before performing this operation with
.Sy INSTALLWORLDDIR Ns = Ns Pa / ,
it is highly recommended that you upgrade your kernel and reboot.
After performing this operation,
it is recommended that you use
.Xr etcupdate 8
to update files in
.Sy INSTALLWORLDDIR Ns Pa /etc ,
and
.Xr postinstall 8
to check for or fix inconsistencies.
.It Sy sets
Create distribution sets from
.Sy DESTDIR
into
.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/sets .
Should be run after
.Dq make distribution ,
as
.Dq make build
alone does not install all of the required files.
.
.It Sy sourcesets
Create source sets of the source tree into
.Sy RELEASEDIR Ns Pa /source/sets .
.
.It Sy syspkgs
Create syspkgs from
.Sy DESTDIR
into
.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/syspkgs .
Should be run after
.Dq make distribution ,
as
.Dq make build
alone does not install all of the required files.
.
.It Sy release
Do a
.Dq make distribution ,
build kernels, distribution media, and install sets
(this as per
.Dq make sets ) ,
and
then package the system into a standard release layout as described by
.Xr release 7 .
This requires that
.Sy RELEASEDIR
be set (see above).
.
.It Sy iso-image
Create a
.Nx
installation CD-ROM image in the
.Sy RELEASEDIR Ns Pa /images