.if n .pH scrn.chap1 @(#)chap1	40.9
.\" Copyright 1989 AT&T
.BK "Source Code Product Build Instructions"
.CH "Base OS and Compatibility Package Installation and Build Instructions" 1
.H 1 "The Source Code Product"
The System V Release 4.0 Source Code Product (SCP) is distributed within \f(CWcpio\fP archives
which can be ordered on either
6250 bpi nine-track tapes or
23-megabyte (MB) cartridge tapes.
The first archive, 
the Base Operating System (Base OS),
consists of UNIX System V Release 4.0 and C 
language compiler, user and system header files, library
routines, commands, and operating system source.
The second archive, the Compatibility Package, 
consists of the BSD and XENIX 
header file, library routine and command source code.
For further details of feature content refer to the
\fIProduct Overview and Master Index\fP,
the
\fIMigration Guide\fP ,
and the
\fIBSD/XENIX Compatibility Guide\fP.
.P
\*(a1 has a breakdown of the type and number of tapes provided for each 
SCP archives.
.FG "SCP Distribution Tapes" "" a1
.TS
center box;
c|| c | c
c|| c | c.
SCP	6250 bpi	23 MB
Tapes	nine-track	cartridge
	tape	tape
=
Base OS	1	2
_
Compatibility	1	1
.TE
.P
The 3B2 binaries, corresponding to the contents of the source code
product, are also contained in the SCP distribution.
For loading both the SCP binaries and source tapes on a 3B2
see "Dependency Notes" below.
.P
For information pertaining to the contents of the SCP tapes
refer to Appendix A.
.H 2 "Binary Distribution"
In addition to source tapes the SCP distribution includes the
UNIX System V Release 4.0 binaries
for the 3B2/310 and
3B2/400 processors.
These binaries are distributed on six floppy diskettes and
two, 23-megabyte cartridge tapes.
An additional floppy diskette is provided with the domestic version
of the System V Release 4.0 SCP containing the Security Administration Utilities.
Figure 1-2 lists the packages contained in the binary distribution.
.P
All binaries are provided in a new transparent
object file format, the Extensible and Linking Format (ELF).
.AB N
ELF objects are only supported on System V Release 4.0 systems.
Therefore these executables cannot be run on 3B2 systems
running previous releases.
.AC
.bp
.FG "Packages Contained in the Binary Distribution" 
.nr Or 0 1
.TS
box center;
nr c l.
\\n+(Or		BSD Compatibility Package
\\n+(Or		Basic Networking Utilities
\\n+(Or		C Programming Language Utilities
\\n+(Or		Directory and File Management Utilities
\\n+(Or		Distributed File Systems Utilities
\\n+(Or		Editing Utilities
\\n+(Or		Encryption Utilities (CRYPT)
\\n+(Or		Essential Utilities
\\n+(Or	\(rh	Ethernet Media Driver Utilities
\\n+(Or		Extended Software Generation System Utilities
\\n+(Or		Framed Access Command Environment (FACE) Utilities
\\n+(Or		InterProcess Communication (IPC) Utilities
\\n+(Or	\(rh	Internet Utilities
\\n+(Or		Line Printer Spooling Utilities
\\n+(Or		Network File System Utilities
\\n+(Or		Networking Support Utilities
\\n+(Or		Remote File System Utilities
\\n+(Or		Remote Procedure Call Utilities
\\n+(Or		Spell Utilities
\\n+(Or		System Administration Utilities
\\n+(Or		System Header Files Utilities
\\n+(Or		System Performance Analysis Utilities (SPAU)
\\n+(Or		Terminal Information Utilities
\\n+(Or		UNIX File System Utilities
\\n+(Or		User Environment Utilities
\\n+(Or		Windowing Utilities
\\n+(Or		XENIX Compatibility Package
_
.T&
c s s
c s s.
\(rh  This package will reside within the directory 
\f4/var/spool/pkg/\fP\f2pkgname\fP in OA&M-installable format.
.TE
.H 1 "Dependency Notes"
.H 2 "Hardware Dependencies"
.H 3 "Hardware Options for Binary Installation" 
To install the System V Release 4.0 binaries, you must have a 3B2/310
and 3B2/400 with at least one, 72-megabyte disk drive, 
one cartridge tape controller and unit,
and 4 megabytes of memory.
If the 3B2 is to be used for storing the source code product,
an additional 72-megabyte disk is required.
.AB W
If your computer is an AT&T 3B2/300, it will need to be upgraded
to a 3B2/310 in order to install and execute System V Release 4.0. 
For more
information, contact your AT&T Account Executive or
Data Sales Executive, or call 1-800-247-1212.
.AC
.P
The binaries for the 3B2 are distributed on:
.BL
.LI
six floppy diskettes and,
.LI
two, 23-megabyte cartridge tapes.
.LE
.AB N
Not all 3B2/310s come equipped with cartridge tape units, however,
they can be upgraded using an expansion module (3B2 computer XM)
with a cartridge tape controller.
For more
information, contact your AT&T Account Executive or
Data Sales Executive, or call 1-800-247-1212.
.AC
.H 3 "Space Requirements"
To store the source code product on your
3B2 computer you must have at least two, 72-megabyte disks.
The primary disk will be used for loading the System V Release 4.0
binary packages, while the secondary disk will be used for
storing the contents of the source code product tapes.
.P
The space requirements table (\*(a2) shows the 512-byte blocks
and inodes
needed for each of the System V Release 4.0 SCP tapes.
Also displayed is the space requirements for storing
the files resulting from a SCP build.
.AB N
Additional space will be required for those customers
using a cross environment.
Since cross-compilers are specific to machine
architecture, calculating the space needed is best judged
by the customer.
.AC
.P
.FG "Space Requirements for SCP Tapes and System Build" "" a2
.TS
center box;
c|| c | c || c | c || c s
c|| c | c || c | c || c s
c|| c | c || c | c || c | c 
c|| c | c || c | c || c | c 
c|| c | c || c | c || c | c.
Tape	Blocks	Inodes	Blocks	Inodes	Total
					_
	Required	Required	Required	Required
	for	for	for	for	Blocks	Inodes
	Source	Source	Build	Build
_
Base OS	86000	11000	114000	9000	200000	20000
Compat.	8000	1100	4000	500	12000	1600
=
Total	94000	12100	118000	9500	212000	21600
.TE
.bp
.P
.H 2 "Software Dependencies"
.H 3 "Operating System Requirements"
.H 3 "Cross-Compiler Requirements"
Note that a cross-compiler is not part of the source code product
and that code generated in a cross environment on any configuration other
than an AT&T 3B2 computer running UNIX System V Release 4.0
is not supported.
.P
The instructions provided in this chapter for building on machines
other than the AT&T 3B2 computer are based on the assumption that you have
a cross-compiler in place on the machine on which you intend to build System V Release 4.0
and that your cross-compiler is capable of generating
code for the machine on which you intend to run System V Release 4.0.
.P
The source code product should build on
a non-3B2 computer only if your cross-compiler
is functionally equivalent to C Software Development System (CSDS) Issue 5.
Important features of the CSDS Issue 5
are
.BL
.LI
draft-proposed ANSI C compatibility
.LI
Extensible and Linking Format (ELF)
.LI
dynamic linking
.LE
.P
The commands displayed in \*(c1 must be available in your
cross-compile environment.
.FG "Commands Required for a System V Release 4.0 Cross-Compile Environment" "" c1
.TS
center;
c s s
c l l
r lw(2i) lw(2i).
CSDS Issue 5 Compilation Commands
_
Command	Description	Source Location
_
\f4cc	cc\fP command	\f4/usr/src/cmd/sgs/cmd\fP
\f4acomp\fP	compiler	\f4/usr/src/cmd/sgs/acomp\fP
\f4as\fP	assembler	\f4/usr/src/cmd/sgs/as\fP
\f4ld\fP	link editor	\f4/usr/src/cmd/sgs/ld\fP
=
.bp
.T&
c s s
c l l
r lw(2i) lw(2i).
Code Processor/Generator Commands
_
Command	Description	Source Location
_
\f4lex\fP	program generator	\f4/usr/src/cmd/sgs/lex\fP
\f4m4\fP	macro processor	\f4/usr/src/cmd/sgs/m4\fP
\f4yacc\fP	code converter	\f4/usr/src/cmd/sgs/yacc\fP
=
.T&
c s s
c l l
r l l.
Auxiliary Build Commands
_
Command	Description	Source Location
_
\f4nm\fP	name list	\f4/usr/src/cmd/sgs/nm\fP
\f4ar\fP	archiver	\f4/usr/src/cmd/sgs/ar\fP
\f4tsort\fP	topological sorter	\f4/usr/src/cmd/sgs/tsort\fP
\f4lorder\fP	object file orderer	\f4/usr/src/cmd/sgs/lorder\fP
\f4lint\fP	C program checker	\f4/usr/src/cmd/sgs/lint\fP
\f4install\fP	file installer	\f4/usr/src/cmd/install\fP
\f4make\fP	command regenerator	\f4/usr/src/cmd/make\fP
\f4strip\fP	symbol/line number stripper	\f4/usr/src/cmd/sgs/strip\fP
\f4mkboot\fP	object file converter	\f4/usr/src/cmd/mkboot\fP
.TE
.H 3 "Permissions Requirements"
Unless you are building the source code product in a
native environment on a 3B2 computer,
it is strongly recommended that you not be logged
in as \f4root\f1 while you are building the system.
If you are logged in as \f4root\f1, slight, and even inadvertent,
deviations from the procedures outlined in this document can
significantly damage the currently running system.
.H 1 "Binary Installation Instructions"
The 3B2 SCP binary distribution comprises the following:
.BL
.LI
the \f1Essential Boot Utilities\fP (three floppy diskettes)
.LI
the \f1Extended Boot Utilities\fP (three floppy diskettes)
.LI
the \f1UNIX System V Release 4.0 binary tape\fP (two, 23-megabyte cartridge tapes)
.LI
the \f1Security Administration Utilities\fP (one floppy diskette)
.LE
.P
The \f1Security Administration Utilities\fP is only distributed with the
domestic version of the release.
.AB W
The following installation procedures will erase everything on the
primary hard disk.
If data is to be saved from this disk make arrangements to do so
before proceeding.
.AC
The entire installation of the 3B2 SCP binaries will take
from 2 to 3 hours.
To begin the installation of the 3B2 SCP binaries, 
the system must be in firmware mode.
When in that mode, enter the firmware password, 
\f4mcp\fP by default.
If Debug Monitor firmware is installed, you must
type \f4boot\fP at the > prompt to continue.
.P
The first of the three floppy diskettes, labelled
\f1Essential Boot Utilities\fP,
must be inserted into the primary floppy drive
before entering \f40\fP to the \f(CWEnter Load Device Option Number\fP 
prompt (See \*(i1).
.P
After responding to that prompt, firmware will
load in the contents of the first floppy,
at which time the system will prompt for the 
second and third floppies.
When all three floppies have been read, 
the system will be booted from the In-Core file system
in memory.
.FG "Installing the Essential Boot Utilities" "" i1
.SS
Enter name of program to execute [  ]: \c
.UI unix \c
.HK RETURN
	Possible load devices are:

Option Number    Slot     Name
---------------------------------------
       0          0     FD5       
       1          0     HD72      
       2          0     HD72      
       3          2               
       4          4     CTC       

Enter Load Device Option Number [1 (HD72)]: \c
.UI 0 \c
.HK RETURN

Loading Essential Boot Utilities. Please wait...

Please insert the Essential Boot Utilities floppy number 2.
Type "go" when ready [ go quit ] \c
.UI go \c
.HK RETURN

Please insert the Essential Boot Utilities floppy number 3.
Type "go" when ready [ go quit ] \c
.UI go \c
.HK RETURN

UNIX(R) System V Release 4.0 AT&T 3B2 Version 2
Total real memory  = 2328576
Available memory   = 1521664

***********************************************************************

Copyright (c) 1984, 1986, 1987, 1988, 1989  AT&T - All Rights Reserved

THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T INC.
The copyright notice above does not evidence any actual or
intended publication of such source code.

***********************************************************************
.SE
.P
After the system has been booted, you will be prompted with
the \f4Full Restore\fP choice for installation.
Enter \f41\fP and press
.HK RETURN .
.P
Next, the choice for \f4Full Restore From CTC Tape\fP should
be chosen.
Enter \f42\fP and press
.HK RETURN 
(See \*(i2).
.FG "Choices for the Binary Product Installation Procedure" "" i2
.SS
3B2 Release 4.0 Installation

        1)  Full Restore

When responding to a question, you may use the "backspace" key
eo erase the last character  typed or the "@" key to erase the
the entire line. Enter "help" for additional information.

Selection? [ 1 quit help ] \c
.UI 1 \c
.HK RETURN

        1)  Full Restore From Floppies
        2)  Full Restore From CTC Tapes

Selection? [ 1 2 quit help ] \c
.UI 2 \c
.HK RETURN


-- Full Restore --

You have two hard disks connected.  You can choose to leave your second disk alone
and do installation on 1st disk only.  If your first disk is less than 
72-megabyte, installation will be aborted.

Do you want to use your second disk? [ y n ] \c
.UI n \c
.HK RETURN

Use the default hard disk partitioning? [ y n quit help ] \c
.UI y \c
.HK RETURN

Setting up the initial system with default partition sizes; this should
take no more than twenty-five minutes.
2078 blocks
.SE
.P
If your machine contains a second hard disk,
the installation procedure will ask if you want to use that second
hard disk.
If you intend to load the source tapes onto your 3B2 you should enter
\f4n\fP, so that only the first 72-megabyte disk is used for the
installation
(See "Installing Source on the 3B2" for more details).
.P
Next, enter \f4y\fP for \f4Use the default hard disk partitioning\fP
prompt.
This will set up your hard disk with default partition sizes along with
the default
2K file system type.
.P
The installation will then prompt for the first of the three
Extended Boot Utilities floppies.
To install, follow the steps shown in \*(i3.
.FG "Installation of the Extended Boot Utilities" "" i3
.SS
Please insert the Extended Boot Utilities floppy number 1.

Type "go" when ready [ go quit help ] \c
.UI go \c
.HK RETURN

Installing additional Essential Boot Utilities system files.
This should take no more than ten minutes.
1322 blocks

Please insert the Extended Boot Utilities floppy number 2.

Type "go" when ready [ go quit help ] \c
.UI go \c
.HK RETURN

Installing additional Essential Boot Utilities system files.
This should take no more than ten minutes.
1270 blocks

Please insert the Extended Boot Utilities floppy number 3.

Type "go" when ready [ go quit help ] \c
.UI go \c
.HK RETURN

Installing additional Essential Boot Utilities system files.
This should take no more than ten minutes.
295 blocks

You may now remove the last Extended Boot Utilities floppy.
The system is restarting itself from the hard disk. This should
take no more than five minutes. The installation procedure will
then continue automatically.
.SE
.P
After the Extended Boot Utility floppies have been installed,
the system will reboot to the hard disk at which time you will
be prompted for the Binary Tape (See \*(i4).
Insert the tape and press
.HK RETURN .
.AB N
It take approximately 40 minutes to install each of the cartridge tapes.
.AC
The system will reboot \f2twice\fP from the primary hard disk automatically
after installing all the Extended Boot Utilities floppy diskettes.
Then you will be prompted for the Binary Packages Tapes 
as shown in Figure 1-8. Insert the specified tape into the
tape drive and press
.HK RETURN
to start and continue the installation
from tape.
.FG "Install The UNIX System V Release 4.0 Binary Packages Tapes and Specify Nodename" "" i4
.SS
Please insert the UNIX System V Release 4.0 Binary Packages tape number 1.

Press RETURN key when ready [ quit RETURN ] (default RETURN) \c
.HK RETURN
End of medium on "input".

Please insert the UNIX System V Release 4.0 Binary Packages tape number 2.

Press RETURN key when ready [ RETURN ] (default RETURN)
.HK RETURN
79608 blocks
You may now remove the last UNIX System V Release 4.0 Binary Packages tape.

Give  nodename to be used to identify your system: 
[ (alphanumeric string) help ] \c
.UI \fInodename\fP \c
.HK RETURN
.SE
.P
Before the installation is complete,
you must specify a \fInodename\fP for your system (See \*(i4).
The installation will then create a new \f4unix\fP
and reboot from the hard disk.
.P
The installation of the 3B2 SCP Binary Packages is completed when
the
\f4Console Login:\fP prompt
appears on the terminal.
.FG "Using \f4pkgadd\fP(1) to Install Hardware-Dependent Packages" "" i5
.SS
# pkgadd -d /var/spool/pkg

The following packages are available:
  1  emd      EMD Utilities
              (3b2) 2.0
  2  inet     internet utilities
              (3B2) 1.0

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: \c
.HK RETURN
.SE
.P
There are two hardware-dependent packages,
the Ethernet Media Utilities and the Internet Utilities,
that reside in the directory \f4/var/spool/pkg\fP.
These packages are in OA&M-installable format.
If your system has the required hardware,
these packages can be installed using the \f4pkgadd\fP command 
displayed in \*(i5.
You may choose to install either one of the packages by
typing the corresponding number or both by entering 
.HK RETURN .
.P
For domestic customers, 
to install the Security Administration Utilities,
insert the disk into the primary floppy drive and execute
the following:
.DS UI
    \f4	# pkgadd -d /dev/diskette\fP
.DE
The prompts displayed by \f4pkgadd\fP will be similar to those
shown in \*(i5.
.H 1 "Source Installation Instructions"
.H 2 "Installing Source on the 3B2 (Cartridge Tape)"
Before installing source on your 3B2 you should have
installed the 3B2 System V Release 4.0 SCP binaries.
If not, see the "Binary Installation Instructions" section
before proceeding.
.P
The second 72-megabyte disk drive on your system will be used
for storing the contents of the SCP tapes.
Before attempting to install the source tapes, the disk drive must
be formatted and have a file system created on it.
To do so, follow the command sequence displayed in \*(s1.
.AB W
The commands displayed in \*(s1 will remove the contents of
your second 72-megabyte disk. If data is on that disk make arrangements
to have it saved before proceeding.
.AC
.FG "Formatting and Creating a File System on the 3B2 Second 72-Megabyte Disk" "" s1
.SS UI
	# fmthard /dev/rdsk/c1d1s0
.CO
	fmthard:  New volume table of contents now in place
.UI
	# prtvtoc /dev/rdsk/c1d1s0
.CO
	* /dev/rdsk/c1d1s0 partition map
	*
	* Dimensions:
	*     512 bytes/sector
	*      18 sectors/track
	*       9 tracks/cylinder
	*     162 sectors/cylinder
	*     925 cylinders
	*     923 accessible cylinders
	*
	* Flags:
	*   1: unmountable
	*  10: read-only
	*
	*                          First     Sector    Last
	* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       	       6      5    01          0    149526    149525
       	       7      1    01          0       162       161
       	       a      0    00        162    149364    149525
.UI
	# mkfs -F s5 /dev/rdsk/c1d1sa 149364:30000 9 162
.CO
	Mkfs: /dev/rdsk/c1d1sa? 
	(DEL if wrong)
	bytes per logical block = 1024
	total logical blocks = 74682
	total inodes = 30000
	gap (physical blocks) = 9
	cylinder size (physical blocks) = 162 
	mkfs: Available blocks = 72803
.UI
	# labelit -F s5 /dev/rdsk/c1d1sa scp 4.0
.CO
	Current fsname: , Current volname: , Blocks: 149364, Inodes: 30000
	FS Units: 1Kb, Date last modified: Fri Sep 15 14:34:54 1989
	NEW fsname = scp, NEW volname = 4.0 -- DEL if wrong!!
.UI
	# mkdir /scp
	# mount -F s5 /dev/dsk/c1d1sa /scp
.SE
After the file system has been created and mounted,
the source tapes can be read in.
First, insert the Base OS cartridge tape number 1 into
the CTC tape unit and follow the steps displayed in Figure 1-11. 
The Base OS source spans two cartridge tapes, therefore \f(CWcpio\fP will
prompt you for the second tape after having completed the first.
At that point insert Base OS cartridge tape number 2 and press
.HK RETURN .
.P
If the Compatibility source is to be installed,
insert the tape and repeat the \f(CWcpio\fP command line
used for installing the Base OS.
.FG "Installing Source from Cartridge Tape"
.SS UI
	# cd /scp
	# cpio -idumv -H odc -I /dev/rSA/ctape1
	  (\fIYou will be prompted for the second Base OS tape.\fP)
.SE
.H 2 "Installing Source on Non-3B2 (Nine-Track Tape)"
To install source from nine-track tape on a non-3B2 processor,
first ensure there are enough free blocks and inodes in the
target file system (refer back to the "Space Requirements"
subsection), 
then follow the commands displayed in \*(s2.
If building the source is a consideration, take into account that
the directory chosen to store the source should also be the \fItarget-root\fP
directory used for storing the files resulting from a build
(see the "Performing a Build in a Cross Environment" for more details).
.AB N
If the source is to be read in by a user other than
\f4root\fP leave the \f(CW-m\fP option off the \f(CWcpio\fP 
command line.
This will ensure that the 
files and directories have the current used id.
.AC
.FG "Installing Source from Nine-Track Tape" ""s2
.SS UI
	# cd \fItarget-root\fP
	# cpio -icdBumv < /dev/rmt/\fI6250-tape-device\fP
.SE
The command lines displayed in \*(s2 can be used for reading 
in the Base OS or Compatibility source tapes.
.H 1 "Building the Source Code Product"
.H 2 "UNIX Source Structure"
All source contained in the System V Release 4.0 tapes can
be built using 
scripts distributed with that source.
These scripts, which depend on \f4make\fP(1) and the CSDS commands,
will build and install all files into their appropriate directories.
.P
The entire System V Release 4.0 release is contained within directories
under \f4usr/src\fP.
Figure \*(f1 displays these directories, describes
their contents, and points out which build script corresponds
to that directory.
.SK
.FG "System V Release 4.0 Source Structure and Build Scripts" "" f1
.TS
center doublebox;
c|c|c|c
lpf4|lw(1i)|lp-1|c.
Source Directory	Content Description	Build Script	Source Tape
_
/usr/src	T{
\f4:mk\fP commands
T}	\f4:mk\fP	Base OS
/usr/src/head	T{
User header files
T}	\f4:mkhead\fP	Base OS
/usr/src/uts/\f2machine\fP/\f2dir\fP	T{
System header files
T}	\f4:mksyshead\fP	Base OS
/usr/src/lib	T{
UNIX library source
T}	\f4:mklib\fP	Base OS
/usr/src/cmd	T{
UNIX command source
T}	\f4:mkcmd\fP	Base OS
/usr/src/uts	T{
UNIX kernel source
T}	\f4:mkuts\fP	Base OS
/usr/src/scripts	T{
3B2 Packaging scripts
T}	---	Base OS
/usr/src/pkg	T{
OA&M Add-On Packaging scripts
T}	---	Base OS
_
_
/usr/src	T{
\f4:mkucb\fP commands
T}	\f4:mkucb\fP	Compatibility
/usr/src/ucbhead	T{
BSD user header files
T}	\f4:mkucblib\fP	Compatibility
/usr/src/ucblib	T{
BSD library source
T}	\f4:mkucbhead\fP	Compatibility
/usr/src/ucbcmd	T{
BSD command source
T}	\f4:mkucbcmd\fP	Compatibility
_
/usr/src	T{
\f4:mkxcp\fP commands
T}	\f4:mkxcp\fP	Compatibility
/usr/src/xcplib	T{
XENIX library source
T}	\f4:mkxcplib\fP	Compatibility
/usr/src/xcpcmd	T{
XENIX command source
T}	\f4:mkxcpcmd\fP	Compatibility
.TE
.H 2 "Base OS Build Commands"
As shown in \*(f1 each directory under 
\f4usr/src\fP
has an associated command by the name of \f4:mk\fP\f2dir\fP which
determines how the content of that directory is to be built.
These commands will build and install all of the source under
their respective directories.
.P
The directories \f4usr/src/scripts\fP and \f4usr/src/pkg\fP are used solely 
for packaging the files resulting from a build.
Although these directories do not
use
corresponding \f4:mk\fP\f2dir\fP commands,
an overview will be given on how to use their contents.
.P
The following sections will describe the methods used by 
each of the commands for building the contents of their respective
directories.
The order in which these sections appear corresponds to the
the order for building the entire system (that is, the order 
in which they are called by \f4:mk\fP).
.H 3 "\f4:mktarget\fP"
The \f4:mktarget\fP command
will create the directories needed to install the files resulting
from the following \f4:mk\fP\f2dir\fP commands.
In System V Release 4.0 a new directory layout has been introduced 
which differs significantly from previous System V directory structures
(See "The Directory Layout" section of the the \fIMigration
Guide\fP for more details).
In order to ease the migration towards this new layout, 
the previous directory structure is maintained using symbolic links
on both a file and directory level.
\f4:mktarget\fP establishes the needed directory symbolic
links through the use of the \f4SYMLINK="ln -s"\fP variable.
.AB N
If the host machine used to build System V Release 4.0 does not support symbolic links,
this action can be disabled by
setting and exporting \f4SYMLINK=":"\fP before running \f4:mktarget\fP.
.AC
Following is an example of how \f4:mktarget\fP establishes the symbolic
link for the \f4/bin\fP directory for both a native and 
cross environment build.
For the native environment build, when the \f4ROOT\fP variable is not
set, the symbolic link will be as follows:
.DS UI
	\f4ln -s /usr/bin /bin\fP
.DE
The file \f4/bin\fP is the symbolic link containing the path \f4/usr/bin\fP.
.P
For a cross environment build, when \f4ROOT\fP is set to \f4/myroot\fP,
the symbolic link will be:
.DS UI
	\f4ln -s /usr/bin /myroot/bin\fP
.DE
The file \f4/myroot/bin\fP is the symbolic link  containing the path \f4/usr/bin\fP.
Note the absolute path is still being used for the target 
since the intention is that all files and directories under \f4$ROOT\fP
will eventually become the native directory tree,
at which time this symbolic link will be correct.
.AB C
For cross environment builds, until the contents of the
target root directory are transferred to a native system,
symbolically linked directories will be pointing to 
absolute native paths.
Therefore, a copy of a file to the symbolic link \f4$ROOT/bin\fP
will result in a file being copied to \f4/usr/bin\fP.
.AC
.H 3 "\f4:mkhead\fP"
The \f4:mkhead\fP command,
when called with no arguments,
will copy all user header files from \f4/usr/src/head\fP into the 
\f4/usr/include\fP directory.
Names of files can be passed to \f4:mkhead\fP and only those files will 
be installed.
.H 3 "\f4:mksyshead\fP"
The \f4:mksyshead\fP command will install system header files from
\f4/usr/src/uts/\fP\f2machine\fP/\f2dir\fP into \f4/usr/include/\fP\f2dir\fP.
\f4:mksyshead\fP uses a combination of \f4find\fP(1) and \f4cpio\fP(1) 
to transfer files to \f4/usr/include\fP since some \f2dir\fPs contain
subdirectories.
.H 3 "\f4:mklib\fP"
The \f4:mklib\fP command builds all of the C and UNIX system libraries.
Arguments passed to \f4:mklib\fP are directory names found under
\f4usr/src/lib\fP.
Under each of these directories \f4:mklib\fP assumes to find a makefile
named \f2directory\fP\f4.mk\fP.
It will then use this makefile 
to build and install the contents of that directory using the command:
.DS UI
	\f4make -b -f\fP \f2directory\fP\f4.mk install\fP
.DE
Upon completion, a second call to \f4make\fP is made to remove all
intermediate files created during the
first make:
.DS UI
	\f4make -b -f\fP \f2directory\fP\f4.mk clobber\fP
.DE
.AB N
Removing these intermediate files ensures that source will 
always be recompiled
on subsequent calls to \f4make\fP.
If not removed, these intermediate files could impede recompilation.
.AC
.P
\f4:mk\fP will call \f4:mklib\fP with the argument \\*  which will build
the contents of all directories found under \f4/usr/src/lib\fP.
.H 3 "\f4:mkcmd\fP"
The \f4:mkcmd\fP command
behaves similarly to \f4:mklib\fP
in that it takes arguments
which are directories found under \f4/usr/src/cmd\fP.
It expects to find \f2directory\fP.\f4mk\fP makefiles
under those directories which it will pass along to \f4make\fP.
.P
New options may be used with the CSDS Issue 5 compiler 
to specify whether or not to use dynamic shared libraries, \f4-d{y|n}\fP.
\f4:mkcmd\fP assigns these options to the following variables
which subsequently get passed down by \f4make\fP to 
the individual makefiles:
.DS UI
	\f4SHLIBS=
	NOSHLIBS="-dn"
	PERFLIBS="-dn"
	ROOTLIBS="-dn"\fP
.DE
The options \f4-dy\fP need not be explicitly set since linking
dynamic libraries is the default action of the link editor.
Each of these variables can be overridden by setting and exporting
the variable before executing \f4:mkcmd\fP.
.P
Similar to \f4:mktarget\fP, \f4:mkcmd\fP sets the
variable \f4SYMLINK="ln -s"\fP, which it passes to those
makefiles that need to establish symbolic links
between new and old locations (see \f4:mktarget\fP
for specific information).
.AB C
For cross environment builds, until the contents of the target root
directory are transferred to a native system, symbolically linked
directories will be pointing to absolute native paths.
.AC
As shown below, the \f4make\fP command is called twice by \f4:mkcmd\fP,
first to build and install files, then to clean up intermediate
files created within the source directory:
.DS UI
	\f4make -b -f\fP \f2directory\fP\f4.mk ARGS="" SYMLINK='ln -s' \e
		SHLIBS='' NOSHLIBS='-dn' PERFLIBS='-dn' \e
		ROOTLIBS='-dn' IFLAG="" FFLAG="" \e
		install

	make -b -f\fP \f2directory\fP\f4.mk clobber\fP
.DE
\f4:mk\fP will call \f4:mkcmd\fP with the \\* argument to find and build
all subdirectories within \f4usr/src/cmd\fP.
.H 3 "\f4:mkuts\fP"
The \f4:mkuts\fP command will build the kernel, drivers, and boot source 
found under \f4/usr/src/uts\fP.
Along with using the \f4make\fP and CSDS commands,
\f4:mkuts\fP uses \f4mkboot\fP(1M) to produce the individual
boot modules.
The command determines the processor type, (for example, \f2machine\fP), 
which it then uses to complete the source directory path,
(for example, \f4usr/src/uts/\fP\f2machine\fP).
.P
The \f4make\fP command line used to build the kernel source varies 
depending on the \f2machine\fP type.
For the \f43b2\fP the source directory will be 
\f4/usr/src/uts/3b2\fP, and the command executed will be
.DS UI
	\f4make -f unix.mk install SYS=unix\fP
.DE
This will build all source, leaving the boot modules under 
the source directory.
Since the final binaries are left under the source directory 
a subsequent call to \f4make\fP, 
to remove these files,
is not performed.
.H 3 "\f4/usr/src/scripts\fP"
The Essential Boot Utilities floppies contain the image of 
the In-Core Disk (ICD), which includes a boot partition and an S5
file system. The swap partition for the ICD will be allocated according
to the VTOC when the ICD image is loaded into memory.
.P
In the boot partition, there are \f4mboot\fP, \f4flboot\fP, and a VTOC
for the ICD. When booting the system, the firmware loads \f4mboot\fP
into memory from the first block of the first floppy,
the \f4mboot\fP then reads VTOC and loads \f4flboot\fP into memory.
The \f4flboot\fP is responsible for loading the whole ICD image from floppies
into memory to produce the ICD, then loading the kernel from
the ICD and giving control to the kernel.
.P
After the kernel is successfully booted, the installation scripts
under the directory \f4/usr/src/cmd/cmd-3b2/inst/etc\fP will be executed
to partition the hard disk and to install the the packages
to the hard disk.
.P
The first installation script get executed is \f4instf\fP, 
which will invoke the following scripts at the beginning:
\f4asktype\fP to get the type of restore the user requested,
\f4define\fP to define all the common variables for installation,
and
\f4do_setup\fP to create the necessary links in the
ICD which will eventually get copied to the hard disk.
Next, \f4instf\fP will partition the hard disk(s) and make file
systems on each partition according to user's choices.
Then the script \f4instth\fP is invoked.
.P
The \f4instth\fP will mount all the file systems on hard disk(s)
and copy everything in the ICD to hard disk(s).
If the user chose to install from CTC tapes,
the script \f4instl\fP will be executed to install
the Extended Boot Utilities,
to reboot the system from hard disk,
and to execute the scripts \f4instht\fP and \f4instt\fP 
to continue installing the rest of the packages.
Otherwise, the \f4instth\fP will reboot the system from hard disk and execute
\f4insth\fP to install the Essential System Utilities.
.H 3 "\f4/usr/src/pkg\fP"
This directory contains the OA&M packaging scripts used
to create each of the 
binary packages contained in System V Release 4.0.
Although there is no \f4:mk\fP build script to process these files,
the command \f4pkgmk\fP(1) can be used to produce each of
the packages:
.DS UI
	\f4# cd /usr/src/pkg/\fP\f2pkgdir\fP
	\f4# pkgmk -f prototype -o -r / -d /var/spool/pkg\fP
.DE
The \f4pkgmk\fP command will gather those files specified in the
prototype file and transfer them into \f4/var/spool/pkg/\fP\f2pkgname\fP
directory.
.AB N
In the above example, \f4pkgmk\fP stores a duplicate copy of 
the files to be packaged in the directory \f4/var/spool/pkg/\fP\f2pkgname\fP.
Therefore, adequate space is a consideration when producing 
packages.
Also, the \f4a.out\fP and archive files resulting from a build
have additional information stored in \f4.comment\fP sections
averaging on the amount of 12K bytes.
Using \f4mcs\fP(1) to either replace or remove this data
is a considerable space-saving alternative.
Removing or replacing the contents of \f4.comment\fP sections
should be done before packaging since \f4pkgmk\fP stores
the size and checksums of all files it packages.
.AC
.H 2 "Compatibility Package Build Commands"
.H 3 "\f4:mkucb\fP"
The \f4:mkucb\fP scripts are used to install the BSD Compatibility
Package headers, and build the BSD libraries and commands.
\f4:mkucb\fP will ensure that the needed target directory structure
is in place before calling: 
.DS UI
	\f4:mkucbhead\fP	to install BSD User header files
	\f4:mkucblib\fP	to build and install BSD libraries
	\f4:mkucbcmd\fP	to build and install BSD commands
.DE
The behavior of these commands is identical to their Base OS counterparts.
.AB N
Building the BSD Compatibility source is dependent on the Base OS
source being installed and built.
.AC
The OA&M packaging scripts for the BSD Compatibility
Package are located under \f4/usr/src/pkg/compat\fP.
.H 3 "\f4:mkxcp\fP"
The \f4:mkxcp\fP scripts are used to build 
the XENIX Compatibility libraries and commands.
\f4:mkxcp\fP will execute:
.DS UI
	\f4:mkxcplib\fP	to build and install XENIX libraries
	\f4:mkxcpcmd\fP	to build and install XENIX commands
.DE
.AB N
Building the XENIX Compatibility source is dependent on the Base OS
source being installed and built.
.AC
The behavior of these commands is identical to their Base OS counterparts.
.P
The OA&M packaging scripts for the XENIX Compatibility
Package are located under \f4/usr/src/pkg/xcp\fP.
.H 2 "Building in a \f4chroot\fP(1M) Environment"
If the 3B2/310 or 3B2/400 is to be used for building the System V Release 4.0 SCP
it must have both the 3B2 SCP Binaries and SCP tapes installed
(see both the "Binary Installation Instructions" and "Source Installation Instructions"
sections).
Also, adequate disk space must be available
to store the files resulting from a build (see the "Space Requirements"
subsection for the build space requirements).
.H 3 "Preliminary Software Setup"
The following sections describe procedures that must 
be followed before attempting to build any source natively 
on the 3B2.
.H 4 "Increasing s5 File System INODES"
Building the C library source requires that
the maximum number of inodes for the s5 file system type 
be increased to 500.
To increase this number the \f4NINODE\fP tunable parameter must be modified,
and the system must be rebooted.
To accomplish this, follow the steps displayed in \*(b1.
.FG "Increasing the Amount of Inodes for the s5 File System" "" b1
.SS
	# ed /etc/master.d/s5
	/^NINODE/s/=.*/= 500
	w
	q
	# mkboot /boot/S5
	# cunix -o /stand/unix
	# cd /
	# shutdown -i6 -g0 -y
.SE
.H 4 "Creating an i386 False Script"
An additional false script must be created for the \f4i386\fP 
processor type.
Following is the link command line to establish it:
.DS UI
\f4# ln /usr/bin/false /usr/bin/i386\fP
.DE
.H 4 "LP User and Group ID"
User and group IDs for \f4lp\fP must be added to the
\f4passwd\fP and \f4group\fP source files before attempting
a system build.
The \f4lp\fP entries from the online \f4/etc/passwd\fP, \f4/etc/shadow\fP
and \f4/etc/group\fP files, must be added to their source file
counterparts in \f4/usr/src/cmd/.adm/u3b2/passwd\fP,
\f4/usr/src/cmd/.adm/u3b2/shadow\fP, and \f4/usr/src/cmd/.adm/group\fP
respectively.
.H 4 "Changing C Preprocessor for SDB"
The default path for the C Preprocessor in an sdb \f4sh\fP(1)
script must be changed to its new C Issue 5 location.
To do so, edit the file \f4/usr/src/cmd/sdb/cfront/xCC\fP and
change the default setting of the \f4cppC\fP variable to 
\f4/usr/ccs/lib/cpp\fP.
.H 4 "Establishing a \f4chroot\fP(1M) Environment"
It is recommended that native builds be performed in 
a \f4chroot\fP(1M) environment.
This type of environment is one which simulates a native
environment without overwriting online files. 
A true native build will overwrite online system files
which could produce unpredictable results during system execution.
.P
To create a \f4chroot\fP environment copy sections of the
online system to the directory
to be used for storing the source files and the files resulting
from the build,
\fIbasedir\fP. 
.AB N
Besides the following files to be copied,
this base directory must also contain the \fIbasedir\fP\f4/usr/src\fP 
source tree which had been copied from tape.
.AC
.FG "Creating a \f4chroot\fP(1M) Environment" "" b2
.SS UI
	# find /usr/bin   /usr/ccs   /dev/null \e
	       /dev/tty   /dev/zero   /etc/group \e
	       /etc/passwd   /sbin/sh   /usr/lib/libc.so.1 \e
	       /usr/sbin/install   /usr/sbin/mkboot \e
	       -print | cpio -pd \fIbasedir\fP
.SE
Enter this environment by executing:
.DS
	\f4# chroot\fP \f2basedir\fP \f4/usr/bin/sh\fP
.DE
Exit the environment via
.HK CTRL-D .
.H 3 "\f4$PATH\fP Precaution"
Before attempting to build in a \f4chroot\fP you must ensure
that the directory \f4/usr/ccs/bin\fP is located within your \f4$PATH\fP. 
It is required that \f4chroot\fP builds be performed by super-user.
If super-user is obtained via the \f4su\fP(1) commands, with no arguments,
the \f4/usr/ccs/bin\fP directory will be removed from your \f4$PATH\fP.
To prevent this from happening either log in directly as \f4root\fP or
use the \f4su\fP command with the \f4-\fP option.
.H 3 "Output File Size Restrictions"
If an entire build is attempted using \f4:mk\fP,
and the output is directed to a temporary file,
the size of the temporary file created could exceed the system 
imposed ulimit of 2048, 512-byte blocks.
To avoid this, reset the ulimit after entering the \f4chroot\fP
environment by executing:
.DS UI
	\f4# ulimit unlimited\fP
.DE
.H 2 "Performing a Build in the \f4chroot\fP Environment"
To perform a build in the \f4chroot\fP environment, first ensure
the steps provided above in the "Preliminary Software Setup" section
have been followed.
After entering the environment, change directory to \f4/usr/src\fP
and follow the commands outlined in Figure 1-16
for building each of the major functional areas of the source.
In \*(b3, each of the command lines displayed is dependent
on the preceding lines completion.
Therefore, if asynchronous processing is performed, wait on the processes
completion before proceeding with the next.
.P
Also, the commands displayed in \*(b3, used to build the 
BSD and XENIX Compatibility source,
can only be executed if that source tape has been installed.
.FG "Overview of a Full System Build Using the \f4chroot\fP Environment" "" b3
.TS
center;
c c
lf4 lw(3i).
Command line	Explanation
_
chroot \fIbasedir\fP /usr/bin/sh	Change your root directory 
cd /usr/src	T{
Change your current directory 
T}
\./:mktarget	T{
Create the needed target directory structure
T}
\./:mkhead	T{
Install user header files into \f4/usr/include \fP
T}
\./:mksyshead	T{
Install system header files into \f4/usr/include\fP
T}
\./:mklib libc	T{
Build and install the C library
T}
\./:mkcmd sgs	T{
Build and install the C compilation commands along
with the \f4libld.a\fP and \f4libelf.a\fP libraries.
T}
\./:mklib \e*	T{
Build and install all libraries
T}
\./:mkcmd .adm	T{
Build and install the administrative files
T}
\./:mkcmd \e*	T{
Build and install all commands
T}
\./:mkuts	T{
Build the UNIX kernel and drivers
T}
_
\./:mkucb	T{
Build and install the BSD headers, libraries, and commands
T}
\./:mkxcp	T{
Build and install the XENIX headers, libraries, and commands
T}
.TE
.P
.AB N
The commands outlined above will reproduce an entire Base OS
and BSD/XENIX Compatibility binary system.
However, areas not covered by the steps above are the machine-
specific file generation (that is, creating \f4/unix\fP, creating
devices in \f4/dev\fP, and so on.).
These functions are performed by the binary packaging at the time
of processing and installation
(see \f4/usr/src/scripts\fP and \f4/usr/src/pkg\fP sections
for more details).
A comparison between the online 3B2 system and the area used
for the \f4chroot\fP build will also highlight those areas
that are used during binary package creation/installation.
.AC
.H 2 "Building in a Cross Environment"
If a non-3B2 is to be used for building the System V Release 4.0 SCP it
must meet the "Cross-Compiler Requirements"
specified in the "Software Dependencies" section.
Also, adequate disk space must be available
to store the cross-compile environment in addition to the
files resulting from a build (see the "Space Requirements"
subsection for the build space requirements).
.H 3 "Native vs. Cross-Compiler Naming Conventions"
When setting up a cross-compiler, 
the name chosen for the front-end command must 
be something other that \f4cc\fP.
.P
In System V Release 4.0 the location of the compiler has been 
changed from \f4/bin\fP to 
\f4/usr/ccs/bin\fP.
This change in location has subsequently changed the way 
System V Release 4.0 makefiles force the use of the native compiler.
.P
Before System V Release 4.0, if a makefile needed to use the native compiler
it would specify \f4/bin/cc\fP.
If the makfile wanted to use the default compiler,
it would use the \f4$(CC)\fP macro.
\f4$(CC)\fP would default to the \f4make\fP built-in
or would be overridden externally to some other name.
In this scenario, a cross-compiler could be called
\f4cc\fP, since the \f4$PATH\fP could be altered to search a \fIcross-bin\fP
before searching \fI/bin\fP.
.P
Now that 
the native compiler has been moved to \f4/usr/ccs/bin\fP
in System V Release 4.0, 
makefiles can no longer hardcode an absolute native compiler
path, since the native compiler differs between System V Release 4.0 and pre-System V Release 4.0
systems.
The solution was to reference the native compiler by
a relative name, \f4cc\fP, rather than absolute one.
The \f4$PATH\fP search would then determine where to
find the native compiler.
However, this solution prohibits cross compilers from being called \f4cc\fP,
since a \f4$PATH\fP search will only find one \f4cc\fP command.
.H 3 "Required Environment Variables"
A number of \f4sh\fP(1) variables must be set before attempting
to build source in a cross environment.
\*(x1 lists variable names and required settings along with a
description of the purposes they serve.
.SK
.FG "Required Environment Variable Settings" "" x1
.TS
center box;
c | l | l
rf4 | lf4 | lw(2.375i).
Variable	Setting	Function
=
ROOT	\fItarget-root\fP	T{
Location specified for storing files
resulting from the cross build.
T}
_
INC	$(ROOT)/usr/include	T{
The location of the user header files.
T}
_
INCSYS	$(ROOT)/usr/include	T{
The location of the system header files.
T}
_
PATH	\fIcross-bin\fP:\f4$PATH\fP	T{
Force the search of the
\fIcross-bin\fP directory containing the \f4${PFX}\fP\fIcmds\fP.
T}
_
SYMLINK	:	T{
(Optional) Disable action of performing
symbolic links.
T}
_
CCSTYPE	ELF	T{
Compiler type.
T}
_
PFX	\fIprefix\fP	T{
A prefix (typically machine-name) which is
used for cross-compiler and associated commands.
T}
_
CH	#	T{
Prevents the execution of the commands 
\f4chmod\fP, \f4chown\fP, or \f4chgrp\fP 
performed within makefiles.
T}
.TE
.H 3 "Creating a \f4make\fP Front-End"
In order to pass the variables displayed in the previous
section
down to subsequent commands and makefiles,
the front-end \f4make\fP command shown in Figure 1-18 must be created.
.AB N
The following example is based on the assumption that the cross-
compiler is named \f4${PFX}cc\fP and resides in
the directory \fIcross-lib\fP.
Also, the remaining compilation passes and auxiliary commands,
\f4${PFX}acomp\fP,
\f4${PFX}as\fP, 
\f4${PFX}ld\fP,
\f4${PFX}ar\fP,
\f4${PFX}strip\fP,
\f4${PFX}lorder\fP,
\f4${PFX}tsort\fP,
and
\f4${PFX}make\fP,
reside in the directory
\fIcross-bin\fP.
.AC
.FG "Content of the Front-End \f4make\fP Command" "" x2
.SS UI
MAKECMD=\fIcross-bin\fP/\f4${PFX}make\fP

MAKEOPTS="MAKE=make AS=${PFX}as CC=${PFX}cc LD=${PFX}ld TESTDIR=. \e
	OL=$ROOT/ SL=$ROOT/usr/src/cmd \e
	ROOT=$ROOT INCSYS=$INCSYS INC=$INC \e
	SIZE=${PFX}size LORDER=${PFX}lorder STRIP=${PFX}strip PFX=${PFX} \e
	NM=${PFX}nm AR=${PFX}ar TSORT=${PFX}tsort"

echo ${PFX}-make
if [ $# = 0 ]
then
	exec $MAKECMD $MAKEOPTS YACC="${PFX}yacc -p \e
		\fIcross-lib\fP/yaccpar" \e
		LEX="${PFX}lex -l \fIcross-lib\fP/ncform"
else
	exec $MAKECMD "$@" $MAKEOPTS YACC="${PFX}yacc -p \e
		\fIcross-lib\fP/yaccpar" \e
		LEX="${PFX}lex -l \fIcross-lib\fP/ncform"
fi
.SE
This front-end \f4make\fP would reside in the directory \fIcross-bin\fP.
.H 3 "\f4Makefile\fP Modification"
The default user and group permissions for the CSDS \f4makefile\fP
must be changed before attempting to build the source within a cross
environment.
The file \f4usr/src/cmd/sgs/xenv/m32/makefile\fP has the macro
setting
.DS UI
\f4OWN=bin
GRP=bin\fP
.DE
These should be changed to the user and group ID of the login
being used to perform the build.
.H 2 "Performing a Build in a Cross Environment"
To perform a build in the cross environment first ensure
the steps provided above in the "Required Environment Variables" and
"Creating a \f4make\fP Front-End" sections
have been followed.
After doing so, change directory to \fItarget-root\fP\f4/usr/src\fP
and follow the commands outlined below
for building each of the major functional areas of the source.
The commands displayed in \*(x3, used to build the 
BSD and XENIX Compatibility source,
can only be executed if that source tape has been installed.
.FG "Overview of a Full System Build Using a Cross Environment" "" x3
.TS
center;
c c
lf4 lw(3.25i).
Command line	Explanation
_
cd \fItarget-root\fP/usr/src	T{
Change your current directory 
T}
\./:mktarget	T{
Create the needed target directory structure
T}
\./:mkhead	T{
Install user header files into \f4/usr/include\fP
T}
\./:mksyshead	T{
Install system header files into \f4/usr/include\fP
T}
\./:mklib \e*	T{
Build and install all libraries
T}
\./:mkcmd .adm	T{
Build and install the administrative files
T}
\./:mkcmd \e*	T{
Build and install all commands
T}
\./:mkuts	T{
Build the UNIX kernel and drivers
T}
_
\./:mkucb	T{
Build and install the BSD headers, libraries, and commands
T}
\./:mkxcp	T{
Build and install the XENIX headers, libraries, and commands
T}
.TE
.P
.AB N
The commands outlined above will reproduce an entire Base OS
and BSD/XENIX Compatibility binary system.
However, areas not covered by the steps above are the machine-
specific file generation (that is, creating \f4/unix\fP, creating
devices in \f4/dev\fP).
Also, the permissions of all files will be that of the user
performing the build.
These functions are performed by the binary packaging at the
time of processing and installation
(see \f4/usr/src/scripts\fP and \f4/usr/src/pkg\fP sections
for more details).
.AC
.H 2 "Building with a non-ANSI Compiler"
It is possible to build the System V Release 4.0 SCP
using a non-ANSI conforming compiler, for example, using C Issues 4.2 (CI4.2).
However, some source contained in the release 
is dependent on the new technology
provided by CSDS Issue 5, and therefore will not be compilable using CI4.2
(See \*(n1).
.P
Other source, besides being dependent on the new CSDS Issue 5 technology,
is runtime-dependent and is only of use when processing executables
on systems supporting Dynamic Linking in addition to being
produced by CSDS Issue 5 (ELF \f4a.outs\fP):
.TS
center;
l l
l l.
Feature	Source Path
_
Run Time Loader	\f4/usr/src/lib/rtld\fP
Dynamic Linker	\f4/usr/src/lib/libdl\fP
Name to Address Mapping	\f4/usr/src/lib/nametoaddr\fP
.TE
.sp
.FG "Source Dependent on New CSDS Issue 5 Functionality" "" n1
.TS
center;
c  c  r
lp9  lp9  lp9.
Description	Source Path	Feature Dependency
_
Networking Library	\f4/usr/src/lib/libnsl\fP	Dynamic Linking
Sockets Library	\f4/usr/src/lib/libsocket\fP	Dynamic Linking	
Symbolic Debugger	\f4/usr/src/cmd/sdb\fP	ANSI Function Prototypes
.T&
c s s
lp9  lp9 s
lp9  lp9 s.
=
Commands Dependent on the Networking Library \f4libnsl\fP
_
Command	Source Path
_
Internet	\f4/usr/src/cmd/cmd-inet\fP
NFS	\f4/usr/src/cmd/fs.d/nfs\fP
RFS	\f4/usr/src/cmd/fs.d/rfs\fP
	\f4/usr/src/cmd/rfsetup\fP
Remote Procedure Call	\f4/usr/src/cmd/keyserv\fP
	\f4/usr/src/cmd/rpcbind\fP
	\f4/usr/src/cmd/rpcinfo\fP
	\f4/usr/src/cmd/rpcsvc\fP
Network Service 	\f4/usr/src/cmd/listen\fP
Basic Networking Utilites	\f4/usr/src/cmd/bnu\fP
System Message Log	\f4/usr/src/cmd/syslogd\fP
Service Access Facility	\f4/usr/src/cmd/saf\fP
Terminal Port Monitor	\f4/usr/src/cmd/ttymon\fP
Line Printer Utilities	\f4/usr/src/cmd/lp\fP
Mail Services	\f4/usr/src/cmd/mail
	/usr/src/cmd/mailx\fP
.TE
.H 3 "Source Modifications for non-ANSI Build"
Some source modifications are required
before attempting to build the SCP using a non-ANSI
compiler.
Each of the following subsections will describe the area effected,
along with \f4ed(1)\fP command lines needed to make the change.
.H 4 "\f4libc\fP"
These changes are required to ensure consistant use of symbol names.
.SS UI
$ ed - /usr/src/lib/libc/port/gen/getsetitimer.c <<!
188,189c
		_hrtnewres(&(REG_CMD.hrtc_int), HZ, HRT_RNDUP);
		_hrtnewres(&(REG_CMD.hrtc_int), MICROSEC, HRT_RNDUP);
\\.
136,139c
		_hrtnewres(&(INT_CMD.hrtc_int), HZ, HRT_RNDUP);
		_hrtnewres(&(INT_CMD.hrtc_int), MICROSEC, HRT_RNDUP);
		_hrtnewres(&(INT_CMD.hrtc_tod), HZ, HRT_RNDUP);
		_hrtnewres(&(INT_CMD.hrtc_tod), MICROSEC, HRT_RNDUP);
\\.
33c
extern int _hrtnewres();
\\.
8c
#ident	"@(#)libc-port:gen/getsetitimer.c	1.1CHANGED"
\\.
w
!

$ ed - /usr/src/lib/libc/port/gen/hrtcftime.c <<!
54c
	return(_hrtstrftime(buf, LONG_MAX, format, tm, rem, res));
\\.
38c
	return(_hrtascftime(bufp, fmtp, tmp, tdp->hrt_rem, tdp->hrt_res));
\\.
8c
#ident	"@(#)libc-port:gen/hrtcftime.c	1.3CHANGED"
\\.
w
!

$ ed - /usr/src/lib/libc/port/gen/hrtctime.c <<!
38c
	return(_hrtasctime(tmp, tdp->hrt_rem, tdp->hrt_res));
\\.
27c
	char			*_hrtasctime();
\\.
8c
#ident	"@(#)libc-port:gen/hrtctime.c	1.3CHANGED"
\\.
w
!

$ ed - /usr/src/lib/libc/port/gen/hrtstrftime.c <<!
227c
		if ((n = _hrtstrftime(s, maxsize-size, p, tm, rem, res)) == 0)
\\.
12c
#ident	"@(#)libc-port:gen/hrtstrftime.c	1.4CHANGED"
\\.
w
!
.SE
.H 4 "\f4libmalloc\fP"
Following changes are for exposing hidden symbols for non-ANSI
compilation mode only.
.SS UI
$ ed - /usr/src/lib/libmalloc/malloc.c <<!
682c
mallinfo()
\\.
632c
mallopt(cmd, value)
\\.
371c
				if (sbrk(nget) == (char *)-1)  {
\\.
348c
				if(sbrk(nget) == (char *)-1)  {
\\.
320c
				if ((struct header *)sbrk(nget) ==
\\.
303c
			if ((newblk = (struct header *)sbrk(0)) != 
\\.
127c
	extern char *sbrk();
\\.
14a
#define sbrk _sbrk
\\.
8c
#ident	"@(#)libmalloc:malloc.c	1.12.2.2CHANGED"
\\.
w
!
.SE
.H 4 "\f4libcurses\fP"
Changes needed for averting the use of \f4#\fP substitution
within macros.
Also, makefile changes that will prevent lint from being called
for non-ANSI build only.
.SS UI
$ ed - /usr/src/lib/xlibcurses/screen/setupterm.c <<!
19c
#ifdef  __STDC__
#define _TERMPATH(file) "/usr/lib/terminfo/" #file
#else   /* __STDC__ */
#define _TERMPATH(file) "/usr/lib/terminfo/file"
#endif  /* __STDC__ */
\\.
16,17c
#ifdef  SIGSTOP /* SVR4.0 and beyond */
#ifdef  __STDC__
#define _TERMPATH(file) "/usr/share/lib/terminfo/" #file
#else   /* __STDC__ */
#define _TERMPATH(file) "/usr/share/lib/terminfo/file"
#endif  /* __STDC__ */

\\.
8c
#ident	"@(#)curses:screen/setupterm.c	1.53CHANGED"
\\.
w
!

$ ed - /usr/src/lib/xlibcurses/screen/makefile <<!
443c
	#cp llib-lcurses llib-lcurses.ln $(CCSLIB)
\\.
427c
	#$(LINT) -DNOMACROS -o curses -vx $(INCLUDE) llib-lcurses
\\.
393c
	#-$(LINT) -vxu $(CPPDEFS) -DNOMACROS $(CFILES) llib.c >> lint.out
\\.
8c
#ident	"@(#)curses:screen/makefile	1.40.1.18CHANGED"
\\.
w
!
.SE
.H 4 "\f4sgs\fP"
Changes required to disable the use of new C Issue 5 compiler
options for dynamic linking, to prevent lint from being called
for non-ANSI build only and to disable hardware dependent source
compilation.
.SS UI
$ ed - /usr/src/cmd/sgs/xenv/m32/makefile <<!
105c
LINK_MODE=
\\.
139,145s/^/#/
178,184s/^/#/
8c
#ident	"@(#)xenv:m32/template.mk	1.83CHANGED"
\\.
w
!

$ ed - /usr/src/cmd/sgs/alint/m32/makefile <<!
158c
install:	ins 
\\.
8c
#ident	"@(#)alint:m32/makefile	1.5.3.18CHANGED"
\\.
w
!
.SE
.H 4 "\f4cscope\fP"
Reordering of \f4#include\fPs within source files to prevent
typedef clashes.
.SS UI
$ ed - /usr/src/cmd/cscope/common/command.c <<!
16d
13a
#include <fcntl.h>	/* O_RDONLY */
\\.
8c
#ident	"@(#)cscope:common/command.c	1.3CHANGED"
\\.
w
!

$ ed - /usr/src/cmd/cscope/common/display.c <<!
20d
13a
#include <curses.h>	/* LINES, COLS */
\\.
8c
#ident	"@(#)cscope:common/display.c	1.6CHANGED"
\\.
w
!

$ ed - /usr/src/cmd/cscope/common/help.c <<!
15a
#include "global.h"
\\.
14d
8c
#ident	"@(#)cscope:common/help.c	1.2CHANGED"
\\.
w
!

$ ed - /usr/src/cmd/cscope/common/input.c <<!
15a
#include "global.h"
\\.
14d
8c
#ident	"@(#)cscope:common/input.c	1.4CHANGED"
\\.
w
!

$ ed - /usr/src/cmd/cscope/common/main.c <<!
18d
13a
#include <sys/types.h>	/* needed by stat.h */
\\.
8c
#ident	"@(#)cscope:common/main.c	1.8CHANGED"
\\.
w
!
.SE
.H 4 "\f4oampkg\fP"
Add \f4#include\fP to prevent typedef clashes and also 
remove unsupported use of a white space character
preceeding a \f4#define\fP statement.
.SS UI
$ ed - /usr/src/cmd/oampkg/pkgadd/presvr4.c <<!
11a
#include <sys/types.h>
\\.
8c
#ident	"@(#)oampkg:pkgadd/presvr4.c		1.9.1.1CHANGED"
\\.
w
!

$ ed - /usr/src/cmd/oampkg/pkgadd/msgdefs.h <<!
22c
#define  MSG_SUSPEND \e\e
\\.
8c
#ident	"@(#)oampkg:pkgadd/msgdefs.h		1.1.1.1CHANGED"
\\.
w
!
.SE
.H 4 "\f4oamuser\fP"
Remove unsupported use of backslash within an if statement.
.SS UI
$ ed - /usr/src/cmd/oamuser/user/isbusy.c <<!
36c
		if( !strncmp( login, utptr->ut_user, MAXID ) && 
\\.
8c
#ident	"@(#)oamuser:user/isbusy.c	1.3CHANGED"
\\.
w
!
.SE

.H 3 "Performing a Build in a non-ANSI Environment"
Attempting to build the System V Release 4.0 system with a non-ANSI compiler,
CI4.2, requires using
the CI4.2 compilation passes in combination with
the System V Release 4.0 headers and libraries.
.P
Figure 1-21 displays an example of a \f4sh\fP(1) which can be used
to build a C library, create a front-end make and the \f4cc\fP command,
and then build the entire system.
.FG "Steps for Creating a Non-ANSI Cross-Compilation Environment"
.SS
	# Set ROOT variable and
	# Setup a front end CC shell script which at this point will
	# look into $ROOT/usr/include for header files.
ROOT={target-root} ; export ROOT
inc=${ROOT}/usr/include ; export inc 
incsys=${ROOT}/usr/include ; export incsys
ccslib=${ROOT}/usr/ccs/lib ; export ccslib
usrlib=${ROOT}/usr/lib ; export usrlib
	# Get the hostbin directory setup with commands needed for
	# a cross/nonANSI build environment
mkdir ${ROOT}/hostbin
	# The make will be called host make w/a front-end scripts used
	# to pass along essential macros
cd ${ROOT}/usr/src/cmd/make
make -f make.mk
cp make ${ROOT}/hostbin/hostmake
make -f make.mk clobber
	# Create a front-end make script
echo "${ROOT}/hostbin/hostmake AS=\e${PFX}as LD=\e${PFX}ld INC=\e${inc} \e
    CC=\e${PFX}cc PFX=\e${PFX} ROOT=\e${ROOT} \e"\e$@\e"" > $ROOT/hostbin/make
chmod 755 ${ROOT}/hostbin/make
	# Also needed is the lorder command for archiving purposes
cd ${ROOT}/usr/src/cmd/sgs/lorder/m32
make SGS= INSDIR=${ROOT}/hostbin install clobber
	# Setup the PATH to point to this directory first,
	# and then to the directory containing the CI4.2 compiler
PATH=${ROOT}/hostbin:${ROOT}/crossbin:$PATH ; export PATH
	# Create a front-end cc shell script for the CI4.2 compiler 
cat > ${ROOT}/hostbin/m32cc <<!
${ROOT}/crossbin/m32cc -I${inc} $*
!
chmod 775 ${ROOT}/hostbin/m32cc
echo "exit 0" > ${ROOT}/hostbin/u3b2 ; chmod 775 ${ROOT}/hostbin/u3b2
INC=${ROOT}/usr/include ; export INC
	# Install user and system header files into desired location
cd ${ROOT}/usr/src
SYMLINK=: ./:mktarget
\\./:mkhead
\\./:mksyshead
	# Build the C-library
cd ${ROOT}/usr/src/lib/libc
make -f libc.mk PROF="@#" archive
	# Install the startup routines and the C-library.
mkdir ${ROOT}/usr/ccs ${ROOT}/usr/ccs/lib
make -f libc.mk PROF="@#" ROOT=${ROOT} SGS=${PFX} move_archive
	# Now additional modifications need to be done to the front-end
	# CC script to pass the CI5 start-up routines to the CI4.2
	# link-editor.
cat > ${ROOT}/hostbin/m32cc <<!
${ROOT}/crossbin/m32cc \e
	-Y S,${ccslib} \e
	${ccslib}/${PFX}crti.o \e
	-Wp,-Y${inc} \e
	-Wl,${ccslib}/${PFX}crtn.o \e
	${ccslib}/${PFX}values-Xt.o \e
	-L${ccslib} \e
	-L${usrlib} \e
	$*
!
make -f libc.mk clobber
chmod 755 ${ROOT}/hostbin/m32cc

	# Make additional libraries
cd ${ROOT}/usr/src
\\./:mklib `cd ./lib;ls|egrep -v "^libc$"`
	# Make the libld.a and libelf.a libraries
cd ${ROOT}/usr/src/cmd/sgs/xenv/m32
make CCSLIB=$ccslib libclobber libinstall libclobber
	# To build commands that only need libc, set and export the following
	# variables, also modify the :mkcmd scripts for CC, AS and LD setting.
CCSTYPE=COFF	; export CCSTYPE
SHLIBS="-lc"	; export SHLIBS
CH=#		; export CH
	# If no support for symbolic links on the host
	# the set the following
SYMLINK=':'	; export SYMLINK
cd ${ROOT}/usr/src
\\./:mkcmd \e*
	# Before attempting to port the mkboot command
	# command create one that will satisfy the execution at 
	# time the kernel is built.
echo "exit 0" > ${ROOT}/hostbin/mkboot; chmod 755 ${ROOT}/hostbin/mkboot
\\./:mkuts
.SE



