xref: /freebsd/usr.sbin/crunch/crunchgen/crunchgen.1 (revision 08826cadb29ee4ddb7d3917236a1778b49efdd8b)
1de566360SJordan K. Hubbard.\"
2de566360SJordan K. Hubbard.\" Copyright (c) 1994 University of Maryland
3de566360SJordan K. Hubbard.\" All Rights Reserved.
4de566360SJordan K. Hubbard.\"
5de566360SJordan K. Hubbard.\" Permission to use, copy, modify, distribute, and sell this software and its
6de566360SJordan K. Hubbard.\" documentation for any purpose is hereby granted without fee, provided that
7de566360SJordan K. Hubbard.\" the above copyright notice appear in all copies and that both that
8de566360SJordan K. Hubbard.\" copyright notice and this permission notice appear in supporting
9de566360SJordan K. Hubbard.\" documentation, and that the name of U.M. not be used in advertising or
10de566360SJordan K. Hubbard.\" publicity pertaining to distribution of the software without specific,
11de566360SJordan K. Hubbard.\" written prior permission.  U.M. makes no representations about the
12de566360SJordan K. Hubbard.\" suitability of this software for any purpose.  It is provided "as is"
13de566360SJordan K. Hubbard.\" without express or implied warranty.
14de566360SJordan K. Hubbard.\"
15de566360SJordan K. Hubbard.\" U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16de566360SJordan K. Hubbard.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
17de566360SJordan K. Hubbard.\" BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18de566360SJordan K. Hubbard.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19de566360SJordan K. Hubbard.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
20de566360SJordan K. Hubbard.\" IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21de566360SJordan K. Hubbard.\"
22de566360SJordan K. Hubbard.\" Author: James da Silva, Systems Design and Analysis Group
23de566360SJordan K. Hubbard.\"			   Computer Science Department
24de566360SJordan K. Hubbard.\"			   University of Maryland at College Park
2597d92980SPeter Wemm.\" $FreeBSD$
26de566360SJordan K. Hubbard.\"
2742ac3bf1SJoerg Wunsch.Dd September 29, 1997
28de566360SJordan K. Hubbard.Dt CRUNCHGEN 1
29de566360SJordan K. Hubbard.Os BSD 4
30de566360SJordan K. Hubbard.Sh NAME
31de566360SJordan K. Hubbard.Nm \&crunchgen
32de566360SJordan K. Hubbard.Nd generates build environment for a crunched binary
33de566360SJordan K. Hubbard.Sh SYNOPSIS
34de566360SJordan K. Hubbard.Nm \&crunchgen
35fb7f926eSPoul-Henning Kamp.Op Fl fql
3608826cadSLuigi Rizzo.Op Fl h Ar makefile-header-name
37de566360SJordan K. Hubbard.Op Fl m Ar makefile-name
38de566360SJordan K. Hubbard.Op Fl c Ar c-file-name
39de566360SJordan K. Hubbard.Op Fl e Ar exec-file-name
40de566360SJordan K. Hubbard.Op Ar conf-file
41de566360SJordan K. Hubbard.Sh DESCRIPTION
42de566360SJordan K. Hubbard
43de566360SJordan K. HubbardA crunched binary is a program made up of many other programs linked
44de566360SJordan K. Hubbardtogether into a single executable.  The crunched binary main()
45de566360SJordan K. Hubbardfunction determines which component program to run by the contents of
46de566360SJordan K. Hubbardargv[0].  The main reason to crunch programs together is for fitting
47de566360SJordan K. Hubbardas many programs as possible onto an installation or system recovery
48de566360SJordan K. Hubbardfloppy.
49de566360SJordan K. Hubbard
50de566360SJordan K. Hubbard.Pp
51de566360SJordan K. Hubbard.Nm Crunchgen
52de566360SJordan K. Hubbardreads in the specifications in
53de566360SJordan K. Hubbard.Ar conf-file
54de566360SJordan K. Hubbardfor a crunched binary, and generates a Makefile and accompanying
55de566360SJordan K. Hubbardtop-level C source file that when built create the crunched executable
56de566360SJordan K. Hubbardfile from the component programs.  For each component program,
57de566360SJordan K. Hubbard.Nm crunchgen
58de566360SJordan K. Hubbardcan optionally attempt to determine the object (.o) files that make up
59de566360SJordan K. Hubbardthe program from its source directory Makefile.  This information is
60de566360SJordan K. Hubbardcached between runs.
61de566360SJordan K. Hubbard.Nm Crunchgen
62de566360SJordan K. Hubbarduses the companion program
63de566360SJordan K. Hubbard.Nm crunchide
64de566360SJordan K. Hubbardto eliminate link-time conflicts between the component programs by
65de566360SJordan K. Hubbardhiding all unnecessary symbols.
66de566360SJordan K. Hubbard
67de566360SJordan K. Hubbard.Pp
68de566360SJordan K. HubbardAfter
69b17e90a9SPhilippe Charnier.Nm
70de566360SJordan K. Hubbardis run, the crunched binary can be built by running ``make -f
71de566360SJordan K. Hubbard<conf-name>.mk''.  The component programs' object files must already
72de566360SJordan K. Hubbardbe built.  A ``objs'' target, included in the output makefile, will
73de566360SJordan K. Hubbardrun make in each component program's source dir to build the object
74de566360SJordan K. Hubbardfiles for the user.  This is not done automatically since in release
750966c02dSJohn-Mark Gurneyengineering circumstances it is generally not desirable to be
76de566360SJordan K. Hubbardmodifying objects in other directories.
77de566360SJordan K. Hubbard
78de566360SJordan K. Hubbard.Pp
79de566360SJordan K. HubbardThe options are as follows:
80de566360SJordan K. Hubbard.Bl -tag -width indent
81de566360SJordan K. Hubbard.It Fl c Ar c-file-name
82de566360SJordan K. HubbardSet output C file name to
83de566360SJordan K. Hubbard.Ar c-file-name .
84de566360SJordan K. HubbardThe default name is ``<conf-name>.c''.
85de566360SJordan K. Hubbard.It Fl e Ar exec-file-name
86de566360SJordan K. HubbardSet crunched binary executable file name to
87de566360SJordan K. Hubbard.Ar exec-file-name .
88de566360SJordan K. HubbardThe default name is ``<conf-name>''.
89de566360SJordan K. Hubbard.It Fl f
90de566360SJordan K. HubbardFlush cache.  Forces the recalculation of cached parameters.
91fb7f926eSPoul-Henning Kamp.It Fl l
92fb7f926eSPoul-Henning KampList names.  Lists the names this binary will respond to.
9308826cadSLuigi Rizzo.It Fl h Ar makefile-header-name
9408826cadSLuigi RizzoSet the name of a file to be included at the beginning of the
9508826cadSLuigi RizzoMakefiles generated by
9608826cadSLuigi Rizzo.Nm crunchgen .
9708826cadSLuigi RizzoThis is useful to define some make variables such as
9808826cadSLuigi Rizzo.Ar RELEASE_CRUNCH
9908826cadSLuigi Rizzoor similar, which might affect the behaviour of make and
10008826cadSLuigi Rizzoare annoying to pass through environment variables.
101de566360SJordan K. Hubbard.It Fl m Ar makefile-name
102de566360SJordan K. HubbardSet output Makefile name to
103de566360SJordan K. Hubbard.Ar makefile-name .
104de566360SJordan K. HubbardThe default name is ``<conf-name>.mk''.
105de566360SJordan K. Hubbard.It Fl q
106de566360SJordan K. HubbardQuiet operation.  Status messages are suppressed.
107de566360SJordan K. Hubbard.El
108de566360SJordan K. Hubbard.Sh CRUNCHGEN CONFIGURATION FILE COMMANDS
109de566360SJordan K. Hubbard
110de566360SJordan K. Hubbard.Nm Crunchgen
111de566360SJordan K. Hubbardreads specifications from the
112de566360SJordan K. Hubbard.Ar conf-file
113de566360SJordan K. Hubbardthat describe the components of the crunched binary.  In its simplest
114de566360SJordan K. Hubbarduse, the component program names are merely listed along with the
115de566360SJordan K. Hubbardtop-level source directories in which their sources can be found.
116de566360SJordan K. Hubbard.Nm Crunchgen
117de566360SJordan K. Hubbardthen calculates (via the source makefiles) and caches the
118de566360SJordan K. Hubbardlist of object files and their locations.  For more specialized
119de566360SJordan K. Hubbardsituations, the user can specify by hand all the parameters that
120b17e90a9SPhilippe Charnier.Nm
121de566360SJordan K. Hubbardneeds.
122de566360SJordan K. Hubbard.Pp
123de566360SJordan K. HubbardThe
124de566360SJordan K. Hubbard.Ar conf-file
125de566360SJordan K. Hubbardcommands are as follows:
126de566360SJordan K. Hubbard.Bl -tag -width indent
127de566360SJordan K. Hubbard.It Nm srcdirs Ar dirname ...
128de566360SJordan K. HubbardA list of source trees in which the source directories of the
129de566360SJordan K. Hubbardcomponent programs can be found.  These dirs are searched using the
130de566360SJordan K. HubbardBSD ``<source-dir>/<progname>/'' convention.  Multiple
131de566360SJordan K. Hubbard.Nm srcdirs
132de566360SJordan K. Hubbardlines can be specified.  The directories are searched in the order
133de566360SJordan K. Hubbardthey are given.
134de566360SJordan K. Hubbard.It Nm progs Ar progname ...
135de566360SJordan K. HubbardA list of programs that make up the crunched binary.  Multiple
136de566360SJordan K. Hubbard.Nm progs
137de566360SJordan K. Hubbardlines can be specified.
138de566360SJordan K. Hubbard.It Nm libs Ar libspec ...
139de566360SJordan K. HubbardA list of library specifications to be included in the crunched binary link.
140de566360SJordan K. HubbardMultiple
141de566360SJordan K. Hubbard.Nm libs
142de566360SJordan K. Hubbardlines can be specified.
143de566360SJordan K. Hubbard.It Nm ln Ar progname linkname
144de566360SJordan K. HubbardCauses the crunched binary to invoke
145de566360SJordan K. Hubbard.Ar progname
146de566360SJordan K. Hubbardwhenever
147de566360SJordan K. Hubbard.Ar linkname
148de566360SJordan K. Hubbardappears in argv[0].  This allows programs that change their behavior when
149de566360SJordan K. Hubbardrun under different names to operate correctly.
150de566360SJordan K. Hubbard.El
151de566360SJordan K. Hubbard
152de566360SJordan K. HubbardTo handle specialized situations, such as when the source is not
153de566360SJordan K. Hubbardavailable or not built via a conventional Makefile, the following
154de566360SJordan K. Hubbard.Nm special
155de566360SJordan K. Hubbardcommands can be used to set
156b17e90a9SPhilippe Charnier.Nm
157de566360SJordan K. Hubbardparameters for a component program.
158de566360SJordan K. Hubbard.Bl -tag -width indent
159de566360SJordan K. Hubbard.It Nm special Ar progname Nm srcdir Ar pathname
160de566360SJordan K. HubbardSet the source directory for
161de566360SJordan K. Hubbard.Ar progname .
162de566360SJordan K. HubbardThis is normally calculated by searching the specified
163de566360SJordan K. Hubbard.Nm srcdirs
164de566360SJordan K. Hubbardfor a directory named
165de566360SJordan K. Hubbard.Ar progname .
166de566360SJordan K. Hubbard.It Nm special Ar progname Nm objdir Ar pathname
167de566360SJordan K. HubbardSet the obj directory for
168de566360SJordan K. Hubbard.Ar progname .
169de566360SJordan K. HubbardThis is normally calculated by looking for a directory named
170de566360SJordan K. Hubbard.Dq Pa obj
171de566360SJordan K. Hubbardunder the
172de566360SJordan K. Hubbard.Ar srcdir ,
173de566360SJordan K. Hubbardand if that is not found, the
174de566360SJordan K. Hubbard.Ar srcdir
175de566360SJordan K. Hubbarditself becomes the
176de566360SJordan K. Hubbard.Ar objdir .
177de566360SJordan K. Hubbard.It Nm special Ar progname Nm objs Ar object-file-name ...
178de566360SJordan K. HubbardSet the list of object files for program
179de566360SJordan K. Hubbard.Ar progname .
180de566360SJordan K. HubbardThis is normally calculated by constructing a temporary makefile that includes
181de566360SJordan K. Hubbard.Dq Nm srcdir / Pa Makefile
182de566360SJordan K. Hubbardand outputs the value of $(OBJS).
183de566360SJordan K. Hubbard.It Nm special Ar progname Nm objpaths Ar full-pathname-to-object-file ...
184de566360SJordan K. HubbardSets the pathnames of the object files for program
185de566360SJordan K. Hubbard.Ar progname .
186de566360SJordan K. HubbardThis is normally calculated by prepending the
187de566360SJordan K. Hubbard.Nm objdir
188de566360SJordan K. Hubbardpathname to each file in the
189de566360SJordan K. Hubbard.Nm objs
190de566360SJordan K. Hubbardlist.
19108826cadSLuigi Rizzo.It Nm special Ar progname Nm objvar Ar variable_name
19208826cadSLuigi RizzoSets the name of the Make variable which holds the list of
19308826cadSLuigi Rizzoobject files for program
19408826cadSLuigi Rizzo.Ar progname .
19508826cadSLuigi RizzoThis is normally
19608826cadSLuigi Rizzo.Nm OBJS
19708826cadSLuigi Rizzobut some Makefiles might like to use other conventions or
19808826cadSLuigi Rizzoprepend the program's name to the variable, e.g.
19908826cadSLuigi Rizzo.Nm SSHD_OBJS .
20042ac3bf1SJoerg Wunsch.It Nm special Ar progname Nm keep Ar symbol-name ...
20142ac3bf1SJoerg WunschAdd specified list of symbols to the keep list for program
20242ac3bf1SJoerg Wunsch.Ar progname .
20342ac3bf1SJoerg WunschAn underscore is prepended to each symbol and it becomes the argument to a
20442ac3bf1SJoerg Wunsch.Fl k
20542ac3bf1SJoerg Wunschoption for the
20642ac3bf1SJoerg Wunsch.Xr crunchide 1
20742ac3bf1SJoerg Wunschphase. This option is to be used as a last resort as its use can cause a
20842ac3bf1SJoerg Wunschsymbol conflict, however in certain instances it may be the only way to
20942ac3bf1SJoerg Wunschhave a symbol resolve.
210de566360SJordan K. Hubbard.El
211de566360SJordan K. Hubbard
212de566360SJordan K. Hubbard.Pp
213de566360SJordan K. HubbardOnly the
214de566360SJordan K. Hubbard.Nm objpaths
215de566360SJordan K. Hubbardparameter is actually needed by
216de566360SJordan K. Hubbard.Nm crunchgen ,
217de566360SJordan K. Hubbardbut it is calculated from
218de566360SJordan K. Hubbard.Nm objdir
219de566360SJordan K. Hubbardand
220de566360SJordan K. Hubbard.Nm objs ,
221de566360SJordan K. Hubbardwhich are in turn calculated from
222de566360SJordan K. Hubbard.Nm srcdir ,
223de566360SJordan K. Hubbardso is sometimes convenient to specify the earlier parameters and let
224b17e90a9SPhilippe Charnier.Nm
225de566360SJordan K. Hubbardcalculate forward from there if it can.
226de566360SJordan K. Hubbard
227de566360SJordan K. Hubbard.Pp
228de566360SJordan K. HubbardThe makefile produced by
229b17e90a9SPhilippe Charnier.Nm
230de566360SJordan K. Hubbardcontains an optional
231de566360SJordan K. Hubbard.Ar objs
232de566360SJordan K. Hubbardtarget that will build the object files for each component program by
233de566360SJordan K. Hubbardrunning make inside that program's source directory.  For this to work the
234de566360SJordan K. Hubbard.Nm srcdir
235de566360SJordan K. Hubbardand
236de566360SJordan K. Hubbard.Nm objs
237de566360SJordan K. Hubbardparameters must also be valid.  If they are not valid for a particular program, that
238de566360SJordan K. Hubbardprogram is skipped in the
239de566360SJordan K. Hubbard.Ar objs
240de566360SJordan K. Hubbardtarget.
241de566360SJordan K. Hubbard.Sh EXAMPLE
242de566360SJordan K. HubbardHere is an example
243b17e90a9SPhilippe Charnier.Nm
244de566360SJordan K. Hubbardinput conf file, named
245de566360SJordan K. Hubbard.Dq Pa kcopy.conf :
246de566360SJordan K. Hubbard.Pp
247de566360SJordan K. Hubbard.nf
248de566360SJordan K. Hubbard	srcdirs /usr/src/bin /usr/src/sbin
249de566360SJordan K. Hubbard
250de566360SJordan K. Hubbard	progs test cp echo sh fsck halt init mount umount myinstall
251de566360SJordan K. Hubbard	ln test [       # test can be invoked via [
252de566360SJordan K. Hubbard	ln sh -sh       # init invokes the shell with "-sh" in argv[0]
253de566360SJordan K. Hubbard
254de566360SJordan K. Hubbard	special myprog objpaths /homes/leroy/src/myinstall.o # no sources
255de566360SJordan K. Hubbard
256de566360SJordan K. Hubbard	libs -lutil -lcrypt
257de566360SJordan K. Hubbard.fi
258de566360SJordan K. Hubbard.Pp
259de566360SJordan K. HubbardThis conf file specifies a small crunched binary consisting of some
260de566360SJordan K. Hubbardbasic system utilities plus a homegrown install program ``myinstall'',
261de566360SJordan K. Hubbardfor which no source directory is specified, but its object file is
262de566360SJordan K. Hubbardspecified directly with the
263de566360SJordan K. Hubbard.Nm special
264de566360SJordan K. Hubbardline.
265de566360SJordan K. Hubbard.Pp
266de566360SJordan K. HubbardThe crunched binary ``kcopy'' can be built as follows:
267de566360SJordan K. Hubbard.Pp
268de566360SJordan K. Hubbard.nf
269de566360SJordan K. Hubbard	% crunchgen -m Makefile kcopy.conf    # gen Makefile and kcopy.c
270f6b31571SWolfram Schneider	% make objs             # build the component programs' .o files
271de566360SJordan K. Hubbard	% make                  # build the crunched binary kcopy
272de566360SJordan K. Hubbard	% kcopy sh              # test that this invokes a sh shell
273de566360SJordan K. Hubbard	$			# it works!
274de566360SJordan K. Hubbard.fi
275de566360SJordan K. Hubbard.Pp
276de566360SJordan K. HubbardAt this point the binary ``kcopy'' can be copied onto an install floppy
277de566360SJordan K. Hubbardand hard-linked to the names of the component programs.
278de566360SJordan K. Hubbard.Sh SEE ALSO
279de566360SJordan K. Hubbard.Xr crunchide 1
280de566360SJordan K. Hubbard.Sh CAVEATS
281de566360SJordan K. HubbardWhile
282de566360SJordan K. Hubbard.Nm crunch
283de566360SJordan K. Hubbardtakes care to eliminate link conflicts between the component programs
284de566360SJordan K. Hubbardof a crunched binary, conflicts are still possible between the
285de566360SJordan K. Hubbardlibraries that are linked in.  Some shuffling in the order of
286de566360SJordan K. Hubbardlibraries may be required, and in some rare cases two libraries may
287f6b31571SWolfram Schneiderhave an unresolvable conflict and thus cannot be crunched together.
288de566360SJordan K. Hubbard.Pp
289de566360SJordan K. HubbardSome versions of the BSD build environment do not by default build the
290de566360SJordan K. Hubbardintermediate object file for single-source file programs.  The ``make
291de566360SJordan K. Hubbardobjs'' target must then be used to get those object files built, or
292de566360SJordan K. Hubbardsome other arrangements made.
293f12a1471SPhilippe Charnier.Sh AUTHORS
294de566360SJordan K. Hubbard.Nm Crunch
295f12a1471SPhilippe Charnierwas written by
296f12a1471SPhilippe Charnier.An James da Silva Aq jds@cs.umd.edu .
297de566360SJordan K. HubbardCopyright (c) 1994 University of Maryland.  All Rights Reserved.
298