forked from Prajna/mach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mach3_build.doc
599 lines (456 loc) · 28.5 KB
/
mach3_build.doc
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
BUILDING MACH 3.0
Mary R.Thompson
18 June 1993
1. Introduction
We have now switched our Makefiles to use the OSF/ODE make program and OSF
style Makefiles. This make program is basically the one by Adam De Boor that
was released on the BSD 4.3-Reno tape. The OSF modified it to support CMU style
object and shadow directories. The version we are using came from the OSF DCE v
2.1 tape. The programs are all available without license restrictions and have
been placed in the buildtools/ode directory. Currently they are used to build
themselves, the mk, ux, user and BNR-server (bsdss). We have also switched to
use gcc 2.3.3 for all our compilations. Sources for this compiler are in
buildtools/gnu. You can build it yourself and install it where you want it or
you can use the binary version we provide in the mach3.release collection.
External users need to setenv GCC_EXEC_PREFIX
<your_installation_dir>/@sys/lib/lib-gcc/, since otherwise gcc will try to find
it's components in /afs/cs.cmu.edu/project/mach3/latest/release/@sys/lib/lib-
gcc/, followed by /usr/local/lib/gcc-lib and /usr/lib/gcc.
Once all the tools are installed, the procedure for building components of
the system is to run a script that sets a number of environment variables that
the Makefiles depend on, then switch to the directory containing the sources of
the target to be built, and type odemake.
There are several documents to help you understand how this process works.
There are OSF man pages on make.1 and makefiles.5, a man page on the additional
makefiles for the mach3 project, a man page for setvar.1 and a postscript
tutorial by Adam de Boor on the make program.
2. Bootstraping the ODE tools
This section can be skipped if binary versions of the following tools are
already available: gcc 2.3.3, odemake, genpath, makepath, md, release, wh and
setvar. At CMU these files are in
/afs/cs/project/mach3/{latest,alpha}/release/@sys. External to CMU they can be
obtained by supping the mach3.release collection.
The ODE tools were designed by the OSF to be portable to different machines
and versions of Unix. The first step in this process is to build the tools
themselves. A script (or set of scripts) has been provided for this purpose.
The first script is setup.sh which we have placed in the buildtools/ode/setup
directory. It is called with a context argument which defines the machine and
host OS, in our case it is one of i386_mach, i386_bnr, pmax_mach, sun3_mach,
sun4_mach, vax_mach, luna88k_mach or pmax_mach_X_alpha. The setup.sh script
runs a sub-script, <context>/setup.sh which is used to set the machine and OS
specific variables. If you are trying to build the tools on a platform other
than Mach or BNR you should create a customized script for your new context.
The location and procedure for running the setup script is pretty inflexible
since it needs to set up a directory structure and know where the sources are.
The directory structure (which may be rooted wherever you wish) that it assumes
is as follows:
src/{buildtools,mk,ux,user,bsdss}/...
src/buildtools/ode/{setup,mk,bin,lib}
obj/<context>/{buildtools,mk,ux,user,bsdss}/...
release/<context>/{bin,lib,include,etc,man,special}/...
export/<context>/{bin,include,lib,special}/...
Actually the setup.sh script only cares about the source directory names in
the ode subdirectory and the location of the object directory. There must be a
Makeconf file in the src/buildtools directory that specifies MAKEOBJDIR to
match where setup.sh believes it is.
To run the setup script you should
cd src/buildtools/ode/setup
sh -x setup.sh <context> >& log &
The script will create all the obj, release and export directories that it
needs, use the bin/make/bootstrap.sh script to build make, install make in
export/<context>/bin/odemake, which it has added to PATH. The bootstrap.sh
script defines some variables dependent on the context. If you are building in
a new context you will need to modify this script. It then uses this odemake
and the Makefiles in ode/setup/mk to build genpath, makepath, release, md and
wh and to install them in export/<context>/bin.
The version of gcc 2.3.3 we provide is the standard gnu release, with some
configuration changes for Mach. The gnu directory contains scripts and
instructions on how to do build it.
At this point you have the bootstrap tools that are needed to build the rest
of the system. You still need to have the standard Unix tools: csh, sed, yacc,
lex, awk, tar and an assembler and loader available. Now you should run the
setvar script and build the complete buildtools directory. This will rebuild
the odetools plus a few additional things depending on what platform you are
building on.
3. Setting the environment for odemake
3.1. setvar
The ODE make and makefiles depend on certain environment variables. A set of
scripts, buildtools/ode/setup/{setvar.csh,<context>/setvar.csh} have been
provided which make sure that all the necessary target directories exist, exec
a shell and set the necessary variables.
There are three different situations in which the build may take place.
1. Everything is in the local source, export or release area. This
includes all the tools we provide and whatever exported includes or
libs are needed.
2. The local area contains all the sources of the programs that are to
be built, but tools and includes or libraries from other areas are
to be found in a complete system release area.
3. The local area is a shadow of some system release area, and contains
only the sources that are different from the originals. In this case
sources as well as tools, libs and includes are to come from the
system release area, unless they exist in the local area.
setvar can be called with a variety of arguments to deal with these cases.
setvar.csh [-basedir <dir>] [-masterbase <dir> ]
[-systembase <dir> ] [-makesyspath <dir>]
[-target <machine>] <host_context>
The options are:
-basedir <dir>: the base of the tree which contains the local src, obj and
export directories. Defaults to the parent of a superior src
directory.
-masterbase <dir>:
when shadowing set this to the base of the source and release
directory that is being shadowed.
-systembase <dir>:
is the base of the tree that contains a current system release.
When shadowing a fully built release area this variable does
not need to be set, since anything that is not in the local
area should be found in either the master/release area or on
the default PATH. If not shadowing and this variable is not
set, then a bootstrap script should be run to get the the
system tools and include files generated and released into the
local export directory.
-makesyspath <dir>:
is a list of directories (separated by ':'s) that is searched
by odemake to find the .mk rules files. Defaults to
<basedir>/export/<host_context>/lib/mk, followed by
masterbase/release if shadowing, and systembase if it was
given.
-target <machine>:
should only be used when cross-building and the target_machine
is different from the host_machine. Otherwise target_machine
is set from the host_context
-savepath: if set, the current PATH will be added to the end of the PATH
that is set here. By default PATH will only contain the minimum
necessary to build.
-help: prints a brief help message
host_context: is host_machine_os specification that selects sub setvar.csh
that sets machine specific variables such as HOST_MACHINE,
target_machine, target_cpu and default search paths.
For example:
Case 1: where everything is local in the directory
/mach3/{src,export,release}
cd /mach3/src
/mach3/export/i386_mach/etc/setup/setvar i386_mach
Case 2: /usr/mrt/mach3 is contains all the sources for a kernel build but
other tools are to be found in the system release area,
/afs/cs/project/mach3/latest/release.
cd /usr/mrt/mach3/src
alias sv `/afs/cs/project/mach3/latest/release/@sys/etc/setup/setvar`
sv -systembase /afs/cs/project/mach3/latest/release/@sys i386_mach
Case 3: /mach3 is a local shadow area for a kernel build and the master area
is /afs/cs/project/mach3/latest.
alias sv `/afs/cs/project/mach3/latest/release/@sys/etc/setup/setvar`
sv -basedir /mach3 -masterbase /afs/cs/project/mach3/latest i386_mach
3.2. Environment variables
The following environment variables are set by context/setvar.csh
HOST_MACHINE,TARGET_MACHINE,target_machine,TARGET_CPU,target_cpu
type of machine
TARGET_OS,target_os
set to mach
DEFCPATH Default path to search for include files.
OBJECT_FORMAT format objects are to be built-in. e.g A_OUT, COFF, MACH_O
ARCHIVE_FORMAT format of archive files. e.g. BSDARCH,
Some flags for porting the ODE tools
The following environment variables are set by setvar.csh
PATH Path to be searched for binaries. This is the export directory,
the release directory and whatever DEFPATH was set for this
system.
CPATH Path to be searched for include files. Used by the C
preprocessor.
LPATH Path to be searched to find crt0.o and migcom.
INCDIRS a list of -Idirs to be passed to the pre-processor instead of
relying on CPATH
LIBDIRS a list of -Ldirs to be passed to the loader instead of relying
on LPATH
PROJECT_NAME,project_name
Selects the project specific make rules by causing the
inclusion of osf.<project_name>.mk into the makefiles. Set to
mach3 for all the Mach 3.0 collections.
RULES_MK the name of the stardard make rules file to start the includes
in. It is set to osf.std.mk which is looked for in the
MAKESYSPATH directory. This is used instead of the BSD
standard sys.mk.
EXPORTBASE, SOURCEBASE, OBJECTDIR
bases of the respective trees. SOURCEBASE and OBJECTDIR are
used by genpath. OBJECTDIR is also used by Makeconf.
SOURCEDIR Can be set to define a backing directory for the sources. Used
by genpath and Makeconf
In an OSF environment, the setvar.csh script is replaced by rc-files and the
workon program.
4. Building from a set of sources
The basic procedure for building from a set of Mach 3.0 sources is to execute
the setvar.csh script, cd to the directory in which the sources are to be found
and type odemake.
odemake will descend down the subtree as specified in the
EXP{BIN,INC,LIB}_SUBDIRS variables in the Makefile, first building and
exporting any export targets, and then into the SUBDIRS list building the rest
of the targets. Once all the exported targets are in place, individual targets
can be built by cd'ing to the source directory and typing odemake <target>.
The target export_all will do only the exporting passes, and the target
export_<file> will export a single file or program. The target install_all
along with a TOSTAGE argument will release everything that has been previously
built to the TOSTAGE area. See the man page makefiles(5) for more possible
targets.
The following sections describe in detail the build steps for the
micro-kernel (mk tree) and the unix-server (ux tree). You do not really need to
understand this unless you want to modify these programs.
4.1. Make variables
The odemake envrionment uses a set of standard rules files that define lots
of variables as well as standard rules. These files are included by the
.include <${RULES_MK}> in each Makefile. ${RULES_MK} is defined as osf.rules.mk
and is found on the $MAKESYSPATH path which is
{export,release}/<context>/lib/mk. The majority of variables are defined in
osf.<projectname>.mk, in our case osf.mach3.mk and osf.std.mk. The rest of the
.mk files are rules. In general, these .mk files define variables only if they
have not been previously defined which allows you to overide these values with
environment variables or by setting them in Makefiles. The values are often
fuctions of other variables set in the environment or Makefiles.
Variables are defined for most programs that might be used by rules: e.g.
_CC_, _LD_, RM, RANLIB etc, and for default flags used by the rules. Many of
the flags follow the pattern of combining
DEF_xFLAGS set conditionally in osf.mach3.mk
${.TARGET}_xFLAGS or xFLAGS
set in the Makefile
${.TARGET}_xENV or xENV
set in the environment
${.TARGET}_xARGS or xARGS
set on the command line
4.2. Makeconf
The Makeconf file is read by odemake before any other Makefiles and sets a
few basic variables. Its location is used by odemake to determine two other
variables.
CONFIG Selects what configuration options are chosen for the kernel
and Unix server. Defined in Makeconf.
MAKEOBJDIR The directory in which the objects are placed. If this is
undefined the objects are put in the source directory. Defined
in Makeconf as a function of OBJECTDIR
MAKESRCPATH The base of the Master sources if you are shadowing. Set in
Makeconf if SOURCEDIR is defined.
MAKECONF Defined by odemake as the absolute pathname of the Makeconf
file that it is using. This value is used in our Makefiles to
determine the base of the source and/or object,release trees.
Exported to the environment.
MAKETOP Defined by odemake as the relative pathname from the directory
in which odemake was invoked to the directory containing the
Makeconf file.
4.3. Search path variables
odemake uses an agumented version of $VPATH to search for source files. It
gives -I flags to cc and mig to search for header files, -I flags to md to
shorten dependencies and -L flags to ld to search for libraries. The variables
that are used to set these values are:
VPATH The search path that odemake uses to find the prerequisite
files when it is evaluating a dependency rule. This may be set
by individual Makefiles, but odemake expands any given names to
include the same names in the source tree and any backing
source areas. (See Shadowing) If a file name starts with "./"
only the current directory, which is normally in the object
tree, is searched.
INCDIRS and LIBDIRS
set by setvar to the local export directory and and master or
system release area. These directories are not expanded.
INCFLAGS and LIBFLAGS
set in Makefiles and expanded by genpath relative to the local
source area, and any master source area.
4.4. Building the mk tree
The make procedure for the mk tree is more complicated than a build of a tree
of simple unrelated programs. The mk/Makefile has been set up to build and
install the pieces of this tree in the order in which they are needed. If you
are not absolutely sure of what you are doing you should always start the
odemake in the directory mk. If you start off in one of the subdirectories you
may either find that files are missing or you are getting incorrect versions of
files from incorrect directories. The building of the kernel itself is also
complicated by the fact that it needs to be dynamically configured for
different hardware platforms and configurations. This is accomplished following
the tradition of BSD 4.3 of having the config program write the Makefile, named
Makefile.internal, that will be used to build the kernel.
Mach has the added complication that the bootable kernel is built in two
pieces: the kernel itself named mach_kernel and the default pager named
bootstrap. Another program, makeboot, binds the two files together into a
single load image named mach.boot as the final step of the kernel build.
The layout of the mk source tree is as follows:
bootstrap Makefile and sources to build the default pager.
conf a link to kernel/conf.
include contains the Makefiles to build, export and install the mk
collection include files that are used outside of kernel
builds.
user/libmach Makefile and sources to build crt0.o, libmach.a and
libmach_sa.a
user/threads Makefile and sources to build libthreads.a
kernel/src/{config,doconf,makeboot,mig}
Makefiles and sources to build each of these programs which are
needed to build the kernel
kernel/conf The Makefile templates and configuration files that config uses
to create the Makefile for the kernel, Makefile.internal.
kernel The Makefile that starts off the building of the kernel and all
the kernel sources. It ends up switching to the configuration
directory and calling odemake with the newly created
Makefile.internal as the Makefile that actually compiles files
for the kernel.
When you do a odemake in the mk directory, it will proceed to make and export
all of the export targets in each of the subdirectories in the EXPDIRS list in
each Makefile in the order in which they appear. If you wish to start the make
at any other place in this tree, you need to be sure that all the prerequisite
tools, libraries and includes have been exported.
In case you are curious what all the steps are doing this a summary of the
major ones:
- cd kernel/src/mig/include; odemake MAKEFILE_PASS=FIRST
build_all
exports the include files that are needed to build mig.
- kernel/src/mig
builds and exports mig.
- cd include; odemake MAKEFILE_PASS=FIRST build_all
exports all the kernel include files that are needed by external
programs
- cd user/libmach; odemake MAKEFILE_PASS=FIRST build_all
builds and exports crt0.o, libmach.a and libmach_sa.a
- cd user/threads; odemake MAKEFILE_PASS=FIRST build_all
builds and exports libthreads.a
- cd makeboot; odemake MAKEFILE_PASS=SECOND build_all
builds and exports the default pager,
- cd mk/kernel/src/makeboot; make MAKEFILE_PASS=SECOND build_all
build and exports makeboot program
- cd mk/kernel/src/config; make MAKEFILE_PASS=SECOND build_all
build and exports config program
- cd mk/kernel/src/doconf; make MAKEFILE_PASS=SECOND build_all
exports doconf script
- cd kernel/conf; odemake MAKEFILE_PASS=BASIC build_all
Runs the Makefile that is in the conf directory, which runs doconf to
generate the <CONF> file from MASTER, MASTER.local,
<target_cpu>/{MASTER,MASTER.local} Then cds<CONFIG>; runs the config
program which reads the <CONF> file, conf/files,
conf/<target_cpu>/files. conf/template.mk,
conf/<target_cpu>/template.mk and generates the options .h files and
the Makefile.internal in the object directory.
- cd <CONFIG>; make MAKEFILE_PASS=BASIC build_all
runs the generated Makefile that builds the kernel.
There are several shortcut targets that can be used carefully during
repetitive kernel builds.
- cd mk/kernel; odemake kernel
exports any kernel headers you might have changed and rebuilds the
kernel.
- cd mk/kernel; odemake kernel_only
only builds the kernel, does not worry about changes to header files.
- cd mk/kernel/<CONFIG>; odemake file.o
Can be used after you create an empty directory with the CONFIG name
to recompile one file.
- cd mk/kernel/<CONFIG>; odemake relink
Can be used after recompiling a few .o files. Does not check for any
out-of-date dependencies.
5. Configurations
Both the mach kernel and Unix server use a modified version of the BSD config
program to write Makefile.internal which is used to build the kernel/server.
There are three types of files that provide input to config: MASTER,
template.mk and files.
The MASTER files define the various individual configuration options and a
few macro configuration names that are combinations of individual options. For
each machine type the options from MASTER, MASTER.local, <traget_cpu>/MASTER
and <target_cpu>/MASTER.local are combined by the doconf script into a file in
the object directory with the name conf/<CONFIG>. Thus if you are building a
STD+WS configuration of the kernel, the file obj/@sys/mk/kernel/conf/STD+WS
will contain all the options selected for this configuration.
The files files simply list each file, conditionalized by the options that
will select it, that is to be used in the kernel or server. Again the files
and <target_cpu>/files are combined. The lines OPTIONS/foo cause a file foo.h
to be written into the object directory which contains a #define FOO 1|0
depending on whether the option foo was selected or not.
The template.mk and <target_cpu>/template.mk contain definitions and template
rules for config to use in writing Makefile.internal.
The Makeconf file defines the CONFIG variable which is used to chose the
configuration to build. This can be overridden by setting it on the command
line to odemake. For example the odemake command in the ux directory could be
odemake CONFIG=STDVICE+WS
which would cause the non-AFS/NFS configuration of the Unix server to be built.
It is also possible to select or remove specific options in the following
manner: for example in mk
odemake CONFIG=STD+WS-debug-ipc_debug
would disable the kernel debugging interfaces. Note: we do not expect that
most randomly chosen configurations would either build or work. There are
several drivers for various machines which are not usually built and are likely
to require some work before they will compile or run.
6. Building the uk collection
Building in the ux tree has some of the same complications as the mk tree.
Again you should start your make from the ux directory, to ensure that things
are done in the proper order. Here it is only important that the
include/Makefile installs the .h files before the emulator and server try to
use them for building.
The config program is used to write the Makefile.internal file that directs
the building of the Unix server just as it did for the kernel. Configurations
are again specified by the files in the ux/server/conf directory. Because of
license restrictions on the Unix server sources, you may not be able to build
the default configuration that we build at CMU. This configuration, STDAFS+WS,
requires sources for the kernel support for NFS and AFS. If you do not have
source liceses for these, you will need to change the CONFIG variable to
STDVICE+WS. CONFIG is defined in ux/Makeconf. It can either be changed there
or defined on the command line to odemake.
7. Special files
A release area contains several primary subdirectories. Most of these, bin,
lib, include, etc, man should be familiar to you. The special subdirectory is
where the following binaries are installed:
mach.boot.<version>.<config>
emulator.<version>
vmunix.<version>.<config>
where <version> is a string like MK69 or UX31, and <config> is a string like
STD+ANY or STDAFS+WS.
These files should be copied from the special directory when installing them
in / or /mach_servers. The files in the object directory are NOT stripped. For
all kernels MK68 and later, you should install and boot mach.boot, NOT
mach_kernel. mach.boot is produced from bootstrap and mach_kernel with the
makeboot program. What name you give mach.boot in / or /../.. is of course a
matter for you and your boot loader to decide. For more detailed information
on installing these programs see the document Setup for Mach 3.0.
8. Shadowing
The Makefiles also support shadowing. With shadowing, you can have a "system
source area" which contains most source files, and a "local source area" which
only contains files that you have changed. In the extreme, the only file you
need in your local source area is the top-level Makeconf. (Each collection
contains one Makeconf now, at top-level.) A shadow build searches your local
source area for files and directories first, and then checks the system source
area for files and directories. To do shadowing, you should call setvar.csh
with -masterbase option. For example, if your local area is
/usr/rvb/mymach3/src/mk and the system area is
/afs/cs/project/mach3/latest/src/mk then:
cd /usr/rvb/mymach3/src/mk/bootstrap
setvar -masterbase /afs/cs/project/mach3/latest i386_mach
odemake
does a shadow build of bootstrap in the mk collection. Any libraries or
include files that are not in your local release area will be found in the
system release area, /afs/cs/project/mach3/release/latest/@sys. The object,
export and release files you build will be placed respectivley in
/usr/rvb/mymach3/{obj,export,release}/@sys.
9. Other Topics
9.1. Supping
If you are not at CMU the standard way to get both the sources and the system
release area is to use our Software Upgrade Protocol program (SUP) to copy the
files over the Internet. There is a different collection for each source
subtree and one for the system release area. Different licenses are required to
get permission to sup the different collections. Your machine must be enabled
in our host tables to sup these collections. Information on all the details
can be found in /usr/mach/public/doc/notes/mach3_sup which can be FTP'ed from
mach.cs.cmu.edu as user anonymous.
9.2. m3tree
If you are at CMU and have read access to the mach3 archive area, you can get
a copy of the sources by using the m3tree script. Use of this script is
documented by calling it with the -help option and in
/afs/cs/project/mach/public/doc/notes/mach3_cmu.{ps.doc}.
9.3. How to run Mach 3.0
See the document Setup for Mach 3.0 which can be found in
/usr/mach/public/doc/mach3/mach3_setup.{ps,doc}
Table of Contents
1. Introduction 0
2. Bootstraping the ODE tools 0
3. Setting the environment for odemake 0
3.1. setvar 0
3.2. Environment variables 0
4. Building from a set of sources 1
4.1. Make variables 1
4.2. Makeconf 1
4.3. Search path variables 1
4.4. Building the mk tree 1
5. Configurations 2
6. Building the uk collection 2
7. Special files 2
8. Shadowing 2
9. Other Topics 2
9.1. Supping 2
9.2. m3tree 2
9.3. How to run Mach 3.0 2