)
function determines which component program to run by the contents of
argv[0].
The main reason to crunch programs together is for fitting as many
programs as possible onto an installation or system recovery floppy.
crunchgen reads in the specifications in conf-file for a crunched binary, and generates a Makefile and accompanying top-level C source file that when built create the crunched executable file from the component programs. For each component program, crunchgen can optionally attempt to determine the object (.o) files that make up the program from its source directory Makefile. This information is cached between runs. crunchgen uses the companion program crunchide to eliminate link-time conflicts between the component programs by hiding all unnecessary symbols.
After crunchgen is run, the crunched binary can be built by running ``make -f conf-name<.blm Pp.mk. >'' The component programs' object files must already be built. An ``objs'' target, included in the output makefile, will run make in each component program's source dir to build the object files for the user. This is not done automatically since in release engineering circumstances it is generally not desirable to be modifying objects in other directories.
The options are as follows:
The conf-file commands are as follows:
To handle specialized situations, such as when the source is not available or not built via a conventional Makefile, the following special commands can be used to set crunchgen parameters for a component program.
obj
''
under the
srcdir,
and if that is not found, the
srcdir
itself becomes the
objdir.
Makefile
''
and outputs the value of $(OBJS).
Multiple
objs
lines can be specified for given
progname.
Only the objpaths parameter is actually needed by crunchgen but it is calculated from objdir and objs, which are in turn calculated from srcdir, so is sometimes convenient to specify the earlier parameters and let crunchgen calculate forward from there if it can.
The makefile produced by crunchgen contains an optional objs target that will build the object files for each component program by running make inside that program's source directory. For this to work the srcdir and objs parameters must also be valid. If they are not valid for a particular program, that program is skipped in the objs target.
MAKEOBJDIRPREFIX
MAKEOBJDIRPREFIX
is set, the object directory will be prefixed with the path contained in this
environment variable.
MACHINE
MACHINE
is set, it is used as the name of the machine type, when accessing object
directories of the form obj.MACHINE.
If it is not set, it defaults to the machine type returned by
uname(3).
MAKE
MAKE
is set, it is used as the name of the
make(1)
executable to be called.
If this environment variable is not set,
crunchgen
defaults to
``make''.
kcopy.conf
'':
srcdirs /usr/src/bin /usr/src/sbin
progs test cp echo sh fsck halt init mount umount myinstall
ln test [ # test can be invoked via [
ln sh -sh # init invokes the shell with "-sh" in argv[0]
special myprog objpaths /homes/leroy/src/myinstall.o # no sources
libs -lutil -lcrypt
This conf file specifies a small crunched binary consisting of some basic system utilities plus a home-grown install program ``myinstall'', for which no source directory is specified, but its object file is specified directly with the special line.
The crunched binary ``kcopy'' can be built as follows:
% crunchgen -m Makefile kcopy.conf # gen Makefile and kcopy.c
% make objs # build the component programs' .o files
% make # build the crunched binary kcopy
% kcopy sh # test that this invokes a sh shell
$ # it works!
At this point the binary ``kcopy'' can be copied onto an install floppy and hard-linked to the names of the component programs.
Copyright (c) 1994 University of Maryland. All Rights Reserved.
Some versions of the BSD build environment do not by default build the intermediate object file for single-source file programs. The ``make objs'' target must then be used to get those object files built, or some other arrangements made.
If a program directory being searched for is found, but contains no objects, other directories are not searched. This causes the following directive to fail:
srcdirs /usr/src/usr.bin /usr/src/usr.bin/less
progs less gzip
as the
/usr/src/usr.bin/less
directory will be found with the
/usr/src/usr.bin
srcdirs
entry, and as it does not contain the require objects,
crunchgen
fails to find objects for the
less
program.
To avoid this problem, list specific srcdirs first, and
the more general ones later, for e.g.:
srcdirs /usr/src/usr.bin/less /usr/src/usr.bin
progs less gzip
will not have the above problem.