2 .\" Copyright (c) 1994 University of Maryland
3 .\" All Rights Reserved.
5 .\" Permission to use, copy, modify, distribute, and sell this software and its
6 .\" documentation for any purpose is hereby granted without fee, provided that
7 .\" the above copyright notice appear in all copies and that both that
8 .\" copyright notice and this permission notice appear in supporting
9 .\" documentation, and that the name of U.M. not be used in advertising or
10 .\" publicity pertaining to distribution of the software without specific,
11 .\" written prior permission. U.M. makes no representations about the
12 .\" suitability of this software for any purpose. It is provided "as is"
13 .\" without express or implied warranty.
15 .\" U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
17 .\" BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
20 .\" IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 .\" Author: James da Silva, Systems Design and Analysis Group
23 .\" Computer Science Department
24 .\" University of Maryland at College Park
25 .\" $FreeBSD: src/usr.sbin/crunch/crunchgen/crunchgen.1,v 1.11.2.11 2003/03/12 22:08:13 trhodes Exp $
26 .\" $DragonFly: src/usr.sbin/crunch/crunchgen/crunchgen.1,v 1.3 2008/05/02 02:05:07 swildner Exp $
33 .Nd generates build environment for a crunched binary
38 .Op Fl h Ar makefile-header-name
39 .Op Fl m Ar makefile-name
40 .Op Fl p Ar obj-prefix
41 .Op Fl c Ar c-file-name
42 .Op Fl e Ar exec-file-name
46 A crunched binary is a program made up of many other programs linked
47 together into a single executable.
50 function determines which component program to run by the contents of
52 The main reason to crunch programs together is for fitting
53 as many programs as possible onto an installation or system recovery
58 utility reads in the specifications in
60 for a crunched binary, and generates a
63 top-level C source file that when built creates the crunched executable
64 file from the component programs.
65 For each component program,
67 can optionally attempt to determine the object (.o) files that make up
68 the program from its source directory
70 This information is cached between runs.
73 utility uses the companion program
75 to eliminate link-time conflicts between the component programs by
76 hiding all unnecessary symbols.
80 utility places specific requirements on package
82 which make it unsuitable for use with
87 must contain the target
89 and it must define all object files in the variable
91 In some cases, you can use a fake
95 in the source directory
100 in the current directory.
104 is run, the crunched binary can be built by running
105 .Dq Li make -f <conf-name>.mk .
106 The component programs' object files must already be built.
109 target, included in the output makefile, will
112 in each component program's source dir to build the object
114 This is not done automatically since in release
115 engineering circumstances it is generally not desirable to be
116 modifying objects in other directories.
118 The options are as follows:
119 .Bl -tag -width indent
120 .It Fl c Ar c-file-name
121 Set output C file name to
125 .It Fl e Ar exec-file-name
126 Set crunched binary executable file name to
132 Forces the recalculation of cached parameters.
135 Lists the names this binary will respond to.
136 .It Fl h Ar makefile-header-name
137 Set the name of a file to be included at the beginning of the
141 This is useful to define some make variables such as
143 or similar, which might affect the behaviour of
145 and are annoying to pass through environment variables.
146 .It Fl m Ar makefile-name
156 rules to each program make target.
157 .It Fl p Ar obj-prefix
158 Set the pathname to be prepended to the
162 If this option is not present, then the prefix used
163 is the content of the
165 environment variable, or
169 Status messages are suppressed.
171 .Sh CRUNCHGEN CONFIGURATION FILE COMMANDS
174 utility reads specifications from the
176 that describe the components of the crunched binary.
178 use, the component program names are merely listed along with the
179 top-level source directories in which their sources can be found.
182 utility then calculates (via the source makefiles) and caches the
183 list of object files and their locations.
185 situations, the user can specify by hand all the parameters that
191 commands are as follows:
192 .Bl -tag -width indent
193 .It Ic srcdirs Ar dirname ...
194 A list of source trees in which the source directories of the
195 component programs can be found.
196 These dirs are searched using the
198 .Dq Pa <source-dir>/<progname>/
202 lines can be specified.
203 The directories are searched in the order they are given.
204 .It Ic progs Ar progname ...
205 A list of programs that make up the crunched binary.
208 lines can be specified.
209 .It Ic libs Ar libspec ...
210 A list of library specifications to be included in the crunched binary link.
213 lines can be specified.
214 .It Ic buildopts Ar buildopts ...
215 A list of build options to be added to every make target.
216 .It Ic ln Ar progname linkname
217 Causes the crunched binary to invoke
223 This allows programs that change their behavior when
224 run under different names to operate correctly.
227 To handle specialized situations, such as when the source is not
228 available or not built via a conventional
232 commands can be used to set
234 parameters for a component program.
235 .Bl -tag -width indent
236 .It Ic special Ar progname Ic srcdir Ar pathname
237 Set the source directory for
239 This is normally calculated by searching the specified
241 for a directory named
243 .It Ic special Ar progname Ic objdir Ar pathname
250 directory is normally calculated by looking for a directory
251 whose name is that of the source directory prepended by
252 one of the following components, in order of priority:
255 argument passed to the command line; or,
258 environment variable, or
260 If the directory is not found, the
264 .It Ic special Ar progname Ic buildopts Ar buildopts
265 Define a set of build options that should be added to
267 targets in addition to those specified using
271 .It Ic special Ar progname Ic objs Ar object-file-name ...
272 Set the list of object files for program
274 This is normally calculated by constructing a temporary makefile that includes
275 .Dq Ic srcdir Ns / Ns Pa Makefile
276 and outputs the value of
278 .It Ic special Ar progname Ic objpaths Ar full-pathname-to-object-file ...
279 Sets the pathnames of the object files for program
281 This is normally calculated by prepending the
283 pathname to each file in the
286 .It Ic special Ar progname Ic objvar Ar variable_name
289 variable which holds the list of
290 object files for program
296 might like to use other conventions or
297 prepend the program's name to the variable, e.g.\&
299 .It Ic special Ar progname Ic lib Ar library-name ...
300 Specifies libraries to be linked with object files to produce
301 .Ar progname Ns Pa .lo .
302 This can be useful with libraries which redefine routines in
303 the standard libraries, or poorly written libraries which
304 reference symbols in the object files.
305 .It Ic special Ar progname Ic keep Ar symbol-name ...
306 Add specified list of symbols to the keep list for program
310 is prepended to each symbol and it becomes the argument to a
315 This option is to be used as a last resort as its use can cause a
316 symbol conflict, however in certain instances it may be the only way to
317 have a symbol resolve.
318 .It Ic special Ar progname Ic ident Ar identifier
320 .Pa Makefile Ns / Ns Tn C
323 This is normally generated from a
329 and ignoring all other non-identifier characters.
330 This leads to programs named
334 to map to the same identifier.
339 parameter is actually needed by
341 but it is calculated from
345 which are in turn calculated from
347 so is sometimes convenient to specify the earlier parameters and let
349 calculate forward from there if it can.
351 The makefile produced by
355 target that will build the object files for each component program by
358 inside that program's source directory.
363 parameters must also be valid.
364 If they are not valid for a particular program, that
365 program is skipped in the
371 input conf file, named
373 .Bd -literal -offset indent
374 srcdirs /usr/src/bin /usr/src/sbin
376 progs test cp echo sh fsck halt init mount umount myinstall
378 ln test [ # test can be invoked via [
379 ln sh -sh # init invokes the shell with "-sh" in argv[0]
381 special myprog objpaths /homes/leroy/src/myinstall.o # no sources
383 special anotherprog -DNO_FOO WITHOUT_BAR=YES
388 This conf file specifies a small crunched binary consisting of some
389 basic system utilities plus a homegrown install program
391 for which no source directory is specified, but its object file is
392 specified directly with the
398 is built the arguments
400 .Dl -DNO_FOO WITHOUT_BAR=YES
402 are added to all build targets.
406 can be built as follows:
407 .Bd -literal -offset indent
408 % crunchgen -m Makefile kcopy.conf # gen Makefile and kcopy.c
409 % make objs # build the component programs' .o files
410 % make # build the crunched binary kcopy
411 % kcopy sh # test that this invokes a sh shell
415 At this point the binary
417 can be copied onto an install floppy
418 and hard-linked to the names of the component programs.
425 takes care to eliminate link conflicts between the component programs
426 of a crunched binary, conflicts are still possible between the
427 libraries that are linked in.
428 Some shuffling in the order of
429 libraries may be required, and in some rare cases two libraries may
430 have an unresolvable conflict and thus cannot be crunched together.
434 build environment do not by default build the
435 intermediate object file for single-source file programs.
438 must then be used to get those object files built, or
439 some other arrangements made.
443 utility was written by
444 .An James da Silva Aq jds@cs.umd.edu .
446 Copyright (c) 1994 University of Maryland.