PREFIX only used in main.c
[unix-history] / usr / src / usr.sbin / config / SMM.doc / 3.t
CommitLineData
b8b2a7ff
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
57349e41 5.\" @(#)3.t 6.2 (Berkeley) %G%
b8b2a7ff 6.\"
57349e41
MK
7.\".ds RH "System Building Process
8.ne 2i
9.NH
10SYSTEM BUILDING PROCESS
b8b2a7ff
KM
11.PP
12In this section we consider the steps necessary to build a bootable system
13image. We assume the system source is located in the ``/sys'' directory
14and that, initially, the system is being configured from source code.
15.PP
16Under normal circumstances there are 5 steps in building a system.
17.IP 1) 3
18Create a configuration file for the system.
19.IP 2) 3
20Make a directory for the system to be constructed in.
21.IP 3) 3
22Run
23.I config
24on the configuration file to generate the files required
25to compile and load the system image.
26.IP 4)
27Construct the source code interdependency rules for the
57349e41
MK
28configured system with
29.I make depend
30using
31.IR make (1).
b8b2a7ff
KM
32.IP 5)
33Compile and load the system with
57349e41 34.IR make .
b8b2a7ff
KM
35.PP
36Steps 1 and 2 are usually done only once. When a system configuration
37changes it usually suffices to just run
38.I config
39on the modified configuration file, rebuild the source code dependencies,
40and remake the system. Sometimes,
41however, configuration dependencies may not be noticed in which case
42it is necessary to clean out the relocatable object files saved
43in the system's directory; this will be discussed later.
44.NH 2
45Creating a configuration file
46.PP
47Configuration files normally reside in the directory ``/sys/conf''.
48A configuration file is most easily constructed by copying an
57349e41
MK
49existing configuration file and modifying it. The 4.3BSD distribution
50contains a number of configuration files for machines at Berkeley;
51one may be suitable or, in worst case, a copy
52of the generic configuration file may be edited.
b8b2a7ff
KM
53.PP
54The configuration file must have the same name as the directory in
55which the configured system is to be built.
56Further,
57.I config
58assumes this directory is located in the parent directory of
59the directory in which it
60is run. For example, the generic
61system has a configuration file ``/sys/conf/GENERIC'' and an accompanying
57349e41
MK
62directory named ``/sys/GENERIC''.
63Although it is not required that the system sources and configuration
64files reside in ``/sys,'' the configuration and compilation procedure
65depends on the relative locations of directories within that hierarchy,
66as most of the system code and the files created by
b8b2a7ff 67.I config
57349e41
MK
68use pathnames of the form ``../''.
69If the system files are not located in ``/sys,''
70it is desirable to make a symbolic link there for use in installation
71of other parts of the system that share files with the kernel.
b8b2a7ff 72.PP
57349e41 73When building the configuration file, be sure to include the items
b8b2a7ff
KM
74described in section 2. In particular, the machine type,
75cpu type, timezone, system identifier, maximum users, and root device
76must be specified. The specification of the hardware present may take
77a bit of work; particularly if your hardware is configured at non-standard
78places (e.g. device registers located at funny places or devices not
79supported by the system). Section 4 of this document
80gives a detailed description of the configuration file syntax,
81section 5 explains some sample configuration files, and
82section 6 discusses how to add new devices to
83the system. If the devices to be configured are not already
84described in one of the existing configuration files you should check
85the manual pages in section 4 of the UNIX Programmers Manual. For each
86supported device, the manual page synopsis entry gives a
87sample configuration line.
88.PP
89Once the configuration file is complete, run it through
90.I config
91and look for any errors. Never try and use a system which
92.I config
93has complained about; the results are unpredictable.
94For the most part,
95.IR config 's
96error diagnostics are self explanatory. It may be the case that
97the line numbers given with the error messages are off by one.
98.PP
99A successful run of
100.I config
101on your configuration file will generate a number of files in
102the configuration directory. These files are:
103.IP \(bu 3
104A file to be used by \fImake\fP\|(1)
57349e41
MK
105in compiling and loading the system,
106.IR Makefile .
b8b2a7ff 107.IP \(bu 3
57349e41
MK
108One file for each possible system image for this machine,
109.IR swapxxx.c ,
110where
111.I xxx
112is the name of the system image,
b8b2a7ff
KM
113which describes where swapping, the root file system, and other
114miscellaneous system devices are located.
115.IP \(bu 3
116A collection of header files, one per possible device the
117system supports, which define the hardware configured.
118.IP \(bu 3
57349e41 119A file containing the I/O configuration tables used by the system
b8b2a7ff
KM
120during its
121.I autoconfiguration
57349e41
MK
122phase,
123.IR ioconf.c .
b8b2a7ff
KM
124.IP \(bu 3
125An assembly language file of interrupt vectors which
57349e41
MK
126connect interrupts from the machine's external buses to the main
127system path for handling interrupts,
128and a file that contains counters and names for the interrupt vectors.
b8b2a7ff
KM
129.PP
130Unless you have reason to doubt
131.IR config ,
132or are curious how the system's autoconfiguration scheme
133works, you should never have to look at any of these files.
134.NH 2
135Constructing source code dependencies
136.PP
137When
138.I config
139is done generating the files needed to compile and link your system it
140will terminate with a message of the form ``Don't forget to run make depend''.
141This is a reminder that you should change over to the configuration
142directory for the system just configured and type ``make depend''
143to build the rules used by
144.I make
145to recognize interdependencies in the system source code.
146This will insure that any changes to a piece of the system
147source code will result in the proper modules being recompiled
148the next time
149.I make
150is run.
151.PP
152This step is particularly important if your site makes changes
153to the system include files. The rules generated specify which source code
154files are dependent on which include files. Without these rules,
155.I make
57349e41
MK
156will not recognize when it must rebuild modules
157due to the modification of a system header file.
158The dependency rules are generated by a pass of the C preprocessor
159and reflect the global system options.
160This step must be repeated when the configuration file is changed
161and
162.I config
163is used to regenerate the system makefile.
b8b2a7ff
KM
164.NH 2
165Building the system
166.PP
167The makefile constructed by
168.I config
169should allow a new system to be rebuilt by simply typing ``make image-name''.
170For example, if you have named your bootable system image ``vmunix'',
171then ``make vmunix''
172will generate a bootable image named ``vmunix''. Alternate system image names
173are used when the root file system location and/or swapping configuration
174is done in more than one way. The makefile which
175.I config
176creates has entry points for each system image defined in
177the configuration file.
178Thus, if you have configured ``vmunix'' to be a system with the root file
179system on an ``hp'' device and ``hkvmunix'' to be a system with the root
180file system on an ``hk'' device, then ``make vmunix hkvmunix'' will generate
181binary images for each.
57349e41
MK
182As the system will generally use the disk from which it is loaded
183as the root filesystem, separate system images are only required
184to support different swap configurations.
b8b2a7ff
KM
185.PP
186Note that the name of a bootable image is different from the system
187identifier. All bootable images are configured for the same system;
188only the information about the root file system and paging devices differ.
189(This is described in more detail in section 4.)
190.PP
191The last step in the system building process is to rearrange certain commonly
192used symbols in the symbol table of the system image; the makefile
193generated by
194.I config
195does this automatically for you.
196This is advantageous for programs such as
57349e41 197\fInetstat\fP\|(1) and \fIvmstat\fP\|(1),
b8b2a7ff
KM
198which run much faster when the symbols they need are located at
199the front of the symbol table.
200Remember also that many programs expect
201the currently executing system to be named ``/vmunix''. If you install
202a new system and name it something other than ``/vmunix'', many programs
203are likely to give strange results.
204.NH 2
205Sharing object modules
206.PP
207If you have many systems which are all built on a single machine
208there are at least two approaches to saving time in building system
209images. The best way is to have a single system image which is run on
210all machines. This is attractive since it minimizes disk space used
211and time required to rebuild systems after making changes. However,
212it is often the case that one or more systems will require a separately
213configured system image. This may be due to limited memory (building
214a system with many unused device drivers can be expensive), or to
215configuration requirements (one machine may be a development machine
216where disk quotas are not needed, while another is a production machine
217where they are), etc. In these cases it is possible
218for common systems to share relocatable object modules which are not
57349e41 219configuration dependent; most of the modules in the directory ``/sys/sys''
b8b2a7ff
KM
220are of this sort.
221.PP
222To share object modules, a generic system should be built. Then, for
223each system configure the system as before, but before recompiling and
57349e41
MK
224linking the system, type ``make links'' in the system compilation directory.
225This will cause the system
b8b2a7ff
KM
226to be searched for source modules which are safe to share between systems
227and generate symbolic links in the current directory to the appropriate
228object modules in the directory ``../GENERIC''. A shell script,
229``makelinks'' is generated with this request and may be checked for
230correctness. The file ``/sys/conf/defines'' contains a list of symbols
231which we believe are safe to ignore when checking the source code
232for modules which may be shared. Note that this list includes the definitions
233used to conditionally compile in the virtual memory tracing facilities, and
234the trace point support used only rarely (even at Berkeley).
235It may be necessary
57349e41
MK
236to modify this file to reflect local needs. Note further that
237interdependencies which are not directly visible
b8b2a7ff
KM
238in the source code are not caught. This means that if you place
239per-system dependencies in an include file, they will not be recognized
240and the shared code may be selected in an unexpected fashion.
241.NH 2
242Building profiled systems
243.PP
244It is simple to configure a system which will automatically
245collect profiling information as it operates. The profiling data
246may be collected with \fIkgmon\fP\|(8) and processed with
247\fIgprof\fP\|(1)
248to obtain information regarding the system's operation. Profiled
249systems maintain histograms of the program counter as well as the
57349e41 250number of invocations of each routine. The \fIgprof\fP
b8b2a7ff
KM
251command will also generate a dynamic call graph of the executing
252system and propagate time spent in each routine along the arcs
57349e41 253of the call graph (consult the \fIgprof\fP documentation for elaboration).
b8b2a7ff 254The program counter sampling can be driven by the system clock, or
57349e41
MK
255if you have an alternate real time clock, this can be used. The
256latter is highly recommended, as use of the system clock will result
257in statistical anomalies, and time spent in the clock routine will
258not be accurately attributed.
b8b2a7ff
KM
259.PP
260To configure a profiled system, the
261.B \-p
262option should be supplied to \fIconfig\fP.
263A profiled system is about 5-10% larger in its text space due to
264the calls to count the subroutine invocations. When the system
265executes, the profiling data is stored in a buffer which is 1.2
266times the size of the text space. The overhead for running a
267profiled system varies; under normal load we see anywhere from 5-25%
268of the system time spent in the profiling code.
269.PP
270Note that systems configured for profiling should not be shared as
271described above unless all the other shared systems are also to be
272profiled.