MK(8) MK(8)
NAME
mk - remake the binary system and commands from source code
DESCRIPTION
All source code for the UNIX system is distributed in the
directory /usr/src. The directory tree rooted at /usr/src
includes source code for the operating system, libraries,
commands, miscellaneous data files necessary for the system
and procedures to transform this source code into an
executable system.
Within the /usr/src directory are the cmd, lib, uts, head,
and build directories, as well as commands to remake the
parts of the system found under each of these sub-
directories. These commands are named :mk and :mkdir where
dir is the name of the directory to be recreated. Each of
these :mkdir commands will rebuild all or part of the
directory it is responsible for. The :mk command will run
each of the other commands in order and thus, recreate the
whole system. The :mk command is distributed only to source
code licensees.
Each command, with its associated directory, is described
below.
:mklib
The lib directory contains the source code for the
system libraries. The most important of these is the C
library. Each library is in its own sub-directory. If
any arguments are specified on the :mklib command line
then only the given libraries will be rebuilt. The
argument \* will cause it to rebuild all libraries
found under the lib directory.
:mkhead
The head directory contains the source code versions of
the header files found in the /usr/include directory.
The :mkhead command will install the header files given
as arguments. The argument \* will cause it to install
all header files.
Page 1 May 1989
MK(8) MK(8)
:mkuts
The uts directory contains the source code for the UNIX
system. The :mkuts command takes no arguments and
invokes a series of makefiles that will recreate the
operating system.
Associated with the operating system is a set of header
files that describe the user interface to the operating
system. The source for these header files is found in
a sub-directory within the uts directory tree. The
user-accessible versions of these header files are
found in the /usr/include/sys directory. The
:mksyshead command will install these header files into
the /usr/include/sys directory of the target file
system specified by $ROOT.
:mkcmd
The cmd directory contains the source code for all the
commands available on the system. There are two types
of entries within the cmd directory: commands whose
source code consists of only one file with one of the
following suffixes: .l, .y, .c, .s, .sh, or a sub-
directory that contains the multiple source files that
comprise a particular command or subsystem. Each sub-
directory is assumed to have a makefile (see make(1))
with the name command.mk that will take care of
creating everything associated with that directory and
its sub-directories.
The :mkcmd command transforms source code into an
executable command based upon a set of predefined
rules. If the :mkcmd command encounters a sub-
directory within the cmd directory then it will run the
makefile found in that sub-directory. If no makefile
is found then an error will be reported. For single
file commands, the predefined rules are dependent on
the file's suffix. C programs (.c) are compiled by the
C compiler and loaded stripped with shared text.
Assembly language programs (.s) are assembled and
loaded stripped. Yacc programs (.y) and lex programs
Page 2 May 1989
MK(8) MK(8)
(.l) are processed by yacc(1) and lex(1) respectively,
before C compilation. Shell programs (.sh) are copied
to create the command. Each of these operations leaves
a command in the ./cmd directory which is then
installed into a user-accessible directory by using
/etc/install.
The arguments to :mkcmd are either command names or
subsystem names. The subsystems distributed with the
UNIX system are: acct, graf, sgs, sccs, and text.
Prefacing the :mkcmd command with an assignment to the
shell variable $ARGS will cause the indicated
components of the subsystem to be rebuilt.
For example, the entire sccs subsystem can be rebuilt
by:
/usr/src/:mkcmd sccs
while the delta component of sccs can be rebuilt by:
ARGS="delta" /usr/src/:mkcmd sccs
The log command, which is a part of the stat package,
which is itself a part of the graf package, can be
rebuilt by:
ARGS="stat log" /usr/src/:mkcmd graf
The argument \* will cause all commands and subsystems
to be rebuilt.
Makefiles throughout the system, and particularly in the cmd
directory, have a standard format. In particular, :mkcmd
depends on each makefile having target entries for install
and clobber. The install target should cause everything
over which the makefile has jurisdiction to be built and
installed by /etc/install. The clobber target should cause
a complete cleanup of all unnecessary files resulting from
the previous invocation.
Page 3 May 1989
MK(8) MK(8)
An effort has been made to separate the creation of a
command from source and its installation on the running
system. The command /etc/install is used by :mkcmd and most
makefiles to install commands in standard directories on the
system. The use of install allows maximum flexibility in
the administration of the system. The install command makes
very few assumptions about where a command is located, who
owns it, and what modes are in effect. All assumptions may
be overridden on invocation of the command, or more
permanently by redefining a few variables in install. The
purpose of install is to install a new version of a command
in the same place, with the same attributes as the prior
version.
In addition, the use of a separate command to perform
installation allows for the creation of test systems in
other than standard places, easy movement of commands to
balance load, and independent maintenance of makefiles.
In addition to the commands associated with the
abovementioned directories, the following commands also
reside in the usr/src directory:
:mkskeleton:
This command creates all the directories necessary for
the distribution, in the target root file system
($ROOT). This command is executed by the :mk command.
:mkroot:
This command builds the entire distribution by first
building the libraries, sgs, software generation and
extraction tools on the native machine and then
executing the :mk command. After the :mk command
completes successfully, the kernel libraries and
objects and sysgen-related files are copied to
usr/src/uts/mot/cf and usr/src/uts/mot/sysgen
directories of the target root file system ($ROOT).
Before executing this command, it is mandatory that the
variables ROOT and SRC be set in the environment.
``rootenv'' is a shell script that resides in the
Page 4 May 1989
MK(8) MK(8)
usr/src directory and contains the default settings for
these variables and certain others pertinent to
building a distribution. The functions and variables
defined in this file can be sourced into the current
file by executing ``../rootenv''.
:mkdevs:
This command creates all the special files in the dev
directory of hte the target root file system ($ROOT).
This command is executed by the :mk command.
:mktruth:
This command creates all the pertinent links to the
files bin/true and bin/false, depending on the target
machine for which the distribution is being built. For
example, if the machine is an MC68020, then bin/true is
linked to bin/m68k and the rest of the machine types
(m88k, u370, vax, etc.) are linked to bin/false. This
command is executed by the :mk command.
:mkboottape:
This command executes the makefile boot.mk in the
usr/src/build/tape directory to create a binary
distribution tape. This command must be invoked
explicitly if it is necessary to create a QIC
distribution tape.
SEE ALSO
install(1M).
lex(1), make(1), yacc(1) in the Programmer's Reference
Manual.
Page 5 May 1989