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
32 .Nd generates build environment for a crunched binary
37 .Op Fl h Ar makefile-header-name
38 .Op Fl m Ar makefile-name
39 .Op Fl p Ar obj-prefix
40 .Op Fl c Ar c-file-name
41 .Op Fl e Ar exec-file-name
45 A crunched binary is a program made up of many other programs linked
46 together into a single executable.
49 function determines which component program to run by the contents of
51 The main reason to crunch programs together is for fitting
52 as many programs as possible onto an installation or system recovery
57 utility reads in the specifications in
59 for a crunched binary, and generates a
62 top-level C source file that when built creates the crunched executable
63 file from the component programs.
64 For each component program,
66 can optionally attempt to determine the object (.o) files that make up
67 the program from its source directory
69 This information is cached between runs.
72 utility uses the companion program
74 to eliminate link-time conflicts between the component programs by
75 hiding all unnecessary symbols.
79 utility places specific requirements on package
81 which make it unsuitable for use with
86 must contain the target
88 and it must define all object files in the variable
90 In some cases, you can use a fake
94 in the source directory
99 in the current directory.
103 is run, the crunched binary can be built by running
104 .Dq Li make -f <conf-name>.mk .
105 The component programs' object files must already be built.
108 target, included in the output makefile, will
111 in each component program's source dir to build the object
113 This is not done automatically since in release
114 engineering circumstances it is generally not desirable to be
115 modifying objects in other directories.
117 The options are as follows:
118 .Bl -tag -width indent
119 .It Fl c Ar c-file-name
120 Set output C file name to
124 .It Fl e Ar exec-file-name
125 Set crunched binary executable file name to
131 Forces the recalculation of cached parameters.
134 Lists the names this binary will respond to.
135 .It Fl h Ar makefile-header-name
136 Set the name of a file to be included at the beginning of the
140 This is useful to define some make variables such as
142 or similar, which might affect the behavior of
144 and are annoying to pass through environment variables.
145 .It Fl m Ar makefile-name
155 rules to each program make target.
156 .It Fl p Ar obj-prefix
157 Set the pathname to be prepended to the
161 If this option is not present, then the prefix used
162 is the content of the
164 environment variable, or
168 Status messages are suppressed.
170 .Sh CRUNCHGEN CONFIGURATION FILE COMMANDS
173 utility reads specifications from the
175 that describe the components of the crunched binary.
177 use, the component program names are merely listed along with the
178 top-level source directories in which their sources can be found.
181 utility then calculates (via the source makefiles) and caches the
182 list of object files and their locations.
184 situations, the user can specify by hand all the parameters that
190 commands are as follows:
191 .Bl -tag -width indent
192 .It Ic srcdirs Ar dirname ...
193 A list of source trees in which the source directories of the
194 component programs can be found.
195 These dirs are searched using the
197 .Dq Pa <source-dir>/<progname>/
201 lines can be specified.
202 The directories are searched in the order they are given.
203 .It Ic progs Ar progname ...
204 A list of programs that make up the crunched binary.
207 lines can be specified.
208 .It Ic libs Ar libspec ...
209 A list of library specifications to be included in the crunched binary link.
212 lines can be specified.
213 .It Ic libs_so Ar libspec ...
214 A list of library specifications to be dynamically linked in the
216 These libraries will need to be made available via the run-time link-editor
218 when the component program that requires them is executed from
222 lines can be specified.
225 directive overrides a library specified gratuitously on a
228 .It Ic buildopts Ar buildopts ...
229 A list of build options to be added to every make target.
230 .It Ic ln Ar progname linkname
231 Causes the crunched binary to invoke
237 This allows programs that change their behavior when
238 run under different names to operate correctly.
241 To handle specialized situations, such as when the source is not
242 available or not built via a conventional
246 commands can be used to set
248 parameters for a component program.
249 .Bl -tag -width indent
250 .It Ic special Ar progname Ic srcdir Ar pathname
251 Set the source directory for
253 This is normally calculated by searching the specified
255 for a directory named
257 .It Ic special Ar progname Ic objdir Ar pathname
264 directory is normally calculated by looking for a directory
265 whose name is that of the source directory prepended by
266 one of the following components, in order of priority:
269 argument passed to the command line; or,
272 environment variable, or
274 If the directory is not found, the
278 .It Ic special Ar progname Ic buildopts Ar buildopts
279 Define a set of build options that should be added to
281 targets in addition to those specified using
285 .It Ic special Ar progname Ic objs Ar object-file-name ...
286 Set the list of object files for program
288 This is normally calculated by constructing a temporary makefile that includes
289 .Dq Ic srcdir Ns / Ns Pa Makefile
290 and outputs the value of
292 .It Ic special Ar progname Ic objpaths Ar full-pathname-to-object-file ...
293 Sets the pathnames of the object files for program
295 This is normally calculated by prepending the
297 pathname to each file in the
300 .It Ic special Ar progname Ic objvar Ar variable_name
303 variable which holds the list of
304 object files for program
310 might like to use other conventions or
311 prepend the program's name to the variable, e.g.\&
313 .It Ic special Ar progname Ic lib Ar library-name ...
314 Specifies libraries to be linked with object files to produce
315 .Ar progname Ns Pa .lo .
316 This can be useful with libraries which redefine routines in
317 the standard libraries, or poorly written libraries which
318 reference symbols in the object files.
319 .It Ic special Ar progname Ic keep Ar symbol-name ...
320 Add specified list of symbols to the keep list for program
324 is prepended to each symbol and it becomes the argument to a
329 This option is to be used as a last resort as its use can cause a
330 symbol conflict, however in certain instances it may be the only way to
331 have a symbol resolve.
332 .It Ic special Ar progname Ic ident Ar identifier
334 .Pa Makefile Ns / Ns Tn C
337 This is normally generated from a
343 and ignoring all other non-identifier characters.
344 This leads to programs named
348 to map to the same identifier.
353 parameter is actually needed by
355 but it is calculated from
359 which are in turn calculated from
361 so is sometimes convenient to specify the earlier parameters and let
363 calculate forward from there if it can.
365 The makefile produced by
369 target that will build the object files for each component program by
372 inside that program's source directory.
377 parameters must also be valid.
378 If they are not valid for a particular program, that
379 program is skipped in the
385 input conf file, named
387 .Bd -literal -offset indent
388 srcdirs /usr/src/bin /usr/src/sbin
390 progs test cp echo sh fsck halt init mount umount myinstall
392 ln test [ # test can be invoked via [
393 ln sh -sh # init invokes the shell with "-sh" in argv[0]
395 special myprog objpaths /homes/leroy/src/myinstall.o # no sources
397 special anotherprog -DNO_FOO WITHOUT_BAR=YES
402 This conf file specifies a small crunched binary consisting of some
403 basic system utilities plus a homegrown install program
405 for which no source directory is specified, but its object file is
406 specified directly with the
412 is built the arguments
414 .Dl -DNO_FOO WITHOUT_BAR=YES
416 are added to all build targets.
420 can be built as follows:
421 .Bd -literal -offset indent
422 % crunchgen -m Makefile kcopy.conf # gen Makefile and kcopy.c
423 % make objs # build the component programs' .o files
424 % make # build the crunched binary kcopy
425 % kcopy sh # test that this invokes a sh shell
429 At this point the binary
431 can be copied onto an install floppy
432 and hard-linked to the names of the component programs.
436 command had been used, copies of the libraries so named
437 would also need to be copied to the install floppy.
446 utility was written by
447 .An James da Silva Aq jds@cs.umd.edu .
449 Copyright (c) 1994 University of Maryland.
454 keyword was added in 2005 by
455 .An Adrian Steinmann Aq ast@marabu.ch
457 .An Ceri Davies Aq ceri@FreeBSD.org .
461 takes care to eliminate link conflicts between the component programs
462 of a crunched binary, conflicts are still possible between the
463 libraries that are linked in.
464 Some shuffling in the order of
465 libraries may be required, and in some rare cases two libraries may
466 have an unresolvable conflict and thus cannot be crunched together.
470 build environment do not by default build the
471 intermediate object file for single-source file programs.
474 must then be used to get those object files built, or
475 some other arrangements made.