ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/README
Revision: 1.17
Committed: Mon Mar 5 07:14:32 2012 UTC (14 years, 6 months ago) by root
Branch: MAIN
CVS Tags: rel-1_42, rel-1_41
Changes since 1.16: +3 -3 lines
Log Message:
1.41

File Contents

# User Rev Content
1 root 1.1 NAME
2 root 1.17 staticperl - perl, libc, 100 modules, all in one standalone 500kb file
3 root 1.1
4     SYNOPSIS
5     staticperl help # print the embedded documentation
6     staticperl fetch # fetch and unpack perl sources
7     staticperl configure # fetch and then configure perl
8     staticperl build # configure and then build perl
9     staticperl install # build and then install perl
10     staticperl clean # clean most intermediate files (restart at configure)
11     staticperl distclean # delete everything installed by this script
12 root 1.14 staticperl perl ... # invoke the perlinterpreter
13 root 1.1 staticperl cpan # invoke CPAN shell
14 root 1.16 staticperl instsrc path... # install unpacked modules
15 root 1.1 staticperl instcpan modulename... # install modules from CPAN
16     staticperl mkbundle <bundle-args...> # see documentation
17     staticperl mkperl <bundle-args...> # see documentation
18 root 1.7 staticperl mkapp appname <bundle-args...> # see documentation
19 root 1.1
20     Typical Examples:
21    
22     staticperl install # fetch, configure, build and install perl
23     staticperl cpan # run interactive cpan shell
24 root 1.12 staticperl mkperl -MConfig_heavy.pl # build a perl that supports -V
25 root 1.1 staticperl mkperl -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI -MURI::http
26     # build a perl with the above modules linked in
27 root 1.7 staticperl mkapp myapp --boot mainprog mymodules
28     # build a binary "myapp" from mainprog and mymodules
29 root 1.1
30     DESCRIPTION
31 root 1.8 This script helps you to create single-file perl interpreters or
32     applications, or embedding a perl interpreter in your applications.
33     Single-file means that it is fully self-contained - no separate shared
34     objects, no autoload fragments, no .pm or .pl files are needed. And when
35     linking statically, you can create (or embed) a single file that
36     contains perl interpreter, libc, all the modules you need, all the
37     libraries you need and of course your actual program.
38 root 1.2
39     With uClibc and upx on x86, you can create a single 500kb binary that
40 root 1.5 contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, Coro
41 root 1.15 and so on. Or any other choice of modules (and some other size :).
42 root 1.2
43 root 1.8 To see how this turns out, you can try out smallperl and bigperl, two
44     pre-built static and compressed perl binaries with many and even more
45     modules: just follow the links at <http://staticperl.schmorp.de/>.
46    
47 root 1.2 The created files do not need write access to the file system (like PAR
48     does). In fact, since this script is in many ways similar to
49     PAR::Packer, here are the differences:
50    
51     * The generated executables are much smaller than PAR created ones.
52    
53     Shared objects and the perl binary contain a lot of extra info,
54     while the static nature of staticperl allows the linker to remove
55     all functionality and meta-info not required by the final
56     executable. Even extensions statically compiled into perl at build
57     time will only be present in the final executable when needed.
58    
59     In addition, staticperl can strip perl sources much more effectively
60     than PAR.
61    
62     * The generated executables start much faster.
63    
64     There is no need to unpack files, or even to parse Zip archives
65     (which is slow and memory-consuming business).
66    
67     * The generated executables don't need a writable filesystem.
68    
69     staticperl loads all required files directly from memory. There is
70     no need to unpack files into a temporary directory.
71    
72 root 1.8 * More control over included files, more burden.
73 root 1.2
74     PAR tries to be maintenance and hassle-free - it tries to include
75     more files than necessary to make sure everything works out of the
76 root 1.8 box. It mostly succeeds at this, but he extra files (such as the
77     unicode database) can take substantial amounts of memory and file
78     size.
79 root 1.2
80     With staticperl, the burden is mostly with the developer - only
81     direct compile-time dependencies and AutoLoader are handled
82     automatically. This means the modules to include often need to be
83     tweaked manually.
84    
85 root 1.8 All this does not preclude more permissive modes to be implemented
86 root 1.16 in the future, but right now, you have to resolve hidden
87 root 1.8 dependencies manually.
88    
89 root 1.2 * PAR works out of the box, staticperl does not.
90    
91     Maintaining your own custom perl build can be a pain in the ass, and
92     while staticperl tries to make this easy, it still requires a custom
93     perl build and possibly fiddling with some modules. PAR is likely to
94     produce results faster.
95    
96 root 1.6 Ok, PAR never has worked for me out of the box, and for some people,
97     staticperl does work out of the box, as they don't count "fiddling
98     with module use lists" against it, but nevertheless, staticperl is
99     certainly a bit more difficult to use.
100    
101 root 1.2 HOW DOES IT WORK?
102     Simple: staticperl downloads, compile and installs a perl version of
103     your choice in ~/.staticperl. You can add extra modules either by
104     letting staticperl install them for you automatically, or by using CPAN
105     and doing it interactively. This usually takes 5-10 minutes, depending
106     on the speed of your computer and your internet connection.
107    
108     It is possible to do program development at this stage, too.
109    
110     Afterwards, you create a list of files and modules you want to include,
111     and then either build a new perl binary (that acts just like a normal
112     perl except everything is compiled in), or you create bundle files
113     (basically C sources you can use to embed all files into your project).
114    
115     This step is very fast (a few seconds if PPI is not used for stripping,
116 root 1.8 or the stripped files are in the cache), and can be tweaked and repeated
117     as often as necessary.
118 root 1.2
119     THE STATICPERL SCRIPT
120     This module installs a script called staticperl into your perl binary
121     directory. The script is fully self-contained, and can be used without
122     perl (for example, in an uClibc chroot environment). In fact, it can be
123     extracted from the "App::Staticperl" distribution tarball as
124 root 1.9 bin/staticperl, without any installation. The newest (possibly alpha)
125     version can also be downloaded from
126     <http://staticperl.schmorp.de/staticperl>.
127 root 1.2
128     staticperl interprets the first argument as a command to execute,
129     optionally followed by any parameters.
130    
131     There are two command categories: the "phase 1" commands which deal with
132     installing perl and perl modules, and the "phase 2" commands, which deal
133     with creating binaries and bundle files.
134    
135     PHASE 1 COMMANDS: INSTALLING PERL
136     The most important command is install, which does basically everything.
137 root 1.12 The default is to download and install perl 5.12.3 and a few modules
138 root 1.2 required by staticperl itself, but all this can (and should) be changed
139     - see CONFIGURATION, below.
140    
141     The command
142    
143     staticperl install
144    
145 root 1.9 is normally all you need: It installs the perl interpreter in
146 root 1.2 ~/.staticperl/perl. It downloads, configures, builds and installs the
147     perl interpreter if required.
148    
149 root 1.9 Most of the following staticperl subcommands simply run one or more
150     steps of this sequence.
151    
152     If it fails, then most commonly because the compiler options I selected
153     are not supported by your compiler - either edit the staticperl script
154     yourself or create ~/.staticperl shell script where your set working
155     "PERL_CCFLAGS" etc. variables.
156 root 1.2
157     To force recompilation or reinstallation, you need to run staticperl
158     distclean first.
159    
160 root 1.8 staticperl version
161     Prints some info about the version of the staticperl script you are
162     using.
163    
164 root 1.2 staticperl fetch
165     Runs only the download and unpack phase, unless this has already
166     happened.
167    
168     staticperl configure
169     Configures the unpacked perl sources, potentially after downloading
170     them first.
171    
172     staticperl build
173     Builds the configured perl sources, potentially after automatically
174     configuring them.
175    
176     staticperl install
177     Wipes the perl installation directory (usually ~/.staticperl/perl)
178     and installs the perl distribution, potentially after building it
179     first.
180    
181 root 1.14 staticperl perl [args...]
182     Invokes the compiled perl interpreter with the given args. Basically
183     the same as starting perl directly (usually via
184     ~/.staticperl/bin/perl), but beats typing the path sometimes.
185    
186     Example: check that the Gtk2 module is installed and loadable.
187    
188     staticperl perl -MGtk2 -e0
189    
190 root 1.2 staticperl cpan [args...]
191     Starts an interactive CPAN shell that you can use to install further
192     modules. Installs the perl first if necessary, but apart from that,
193     no magic is involved: you could just as well run it manually via
194 root 1.16 ~/.staticperl/perl/bin/cpan, except that staticperl additionally
195     sets the environment variable $PERL to the path of the perl
196     interpreter, which is handy in subshells.
197 root 1.2
198     Any additional arguments are simply passed to the cpan command.
199    
200     staticperl instcpan module...
201     Tries to install all the modules given and their dependencies, using
202     CPAN.
203    
204     Example:
205    
206     staticperl instcpan EV AnyEvent::HTTPD Coro
207    
208     staticperl instsrc directory...
209     In the unlikely case that you have unpacked perl modules around and
210     want to install from these instead of from CPAN, you can do this
211     using this command by specifying all the directories with modules in
212     them that you want to have built.
213    
214     staticperl clean
215 root 1.6 Deletes the perl source directory (and potentially cleans up other
216     intermediate files). This can be used to clean up files only needed
217 root 1.9 for building perl, without removing the installed perl interpreter.
218 root 1.6
219     At the moment, it doesn't delete downloaded tarballs.
220 root 1.2
221 root 1.9 The exact semantics of this command will probably change.
222    
223 root 1.2 staticperl distclean
224     This wipes your complete ~/.staticperl directory. Be careful with
225     this, it nukes your perl download, perl sources, perl distribution
226     and any installed modules. It is useful if you wish to start over
227     "from scratch" or when you want to uninstall staticperl.
228    
229     PHASE 2 COMMANDS: BUILDING PERL BUNDLES
230     Building (linking) a new perl binary is handled by a separate script. To
231     make it easy to use staticperl from a chroot, the script is embedded
232     into staticperl, which will write it out and call for you with any
233     arguments you pass:
234    
235     staticperl mkbundle mkbundle-args...
236    
237     In the oh so unlikely case of something not working here, you can run
238     the script manually as well (by default it is written to
239     ~/.staticperl/mkbundle).
240    
241     mkbundle is a more conventional command and expect the argument syntax
242     commonly used on UNIX clones. For example, this command builds a new
243     perl binary and includes Config.pm (for perl -V), AnyEvent::HTTPD, URI
244     and a custom httpd script (from eg/httpd in this distribution):
245    
246     # first make sure we have perl and the required modules
247     staticperl instcpan AnyEvent::HTTPD
248    
249     # now build the perl
250 root 1.12 staticperl mkperl -MConfig_heavy.pl -MAnyEvent::Impl::Perl \
251 root 1.2 -MAnyEvent::HTTPD -MURI::http \
252     --add 'eg/httpd httpd.pm'
253    
254     # finally, invoke it
255     ./perl -Mhttpd
256    
257     As you can see, things are not quite as trivial: the Config module has a
258     hidden dependency which is not even a perl module (Config_heavy.pl),
259     AnyEvent needs at least one event loop backend that we have to specify
260     manually (here AnyEvent::Impl::Perl), and the URI module (required by
261     AnyEvent::HTTPD) implements various URI schemes as extra modules - since
262     AnyEvent::HTTPD only needs "http" URIs, we only need to include that
263     module. I found out about these dependencies by carefully watching any
264     error messages about missing modules...
265    
266 root 1.7 Instead of building a new perl binary, you can also build a standalone
267     application:
268    
269     # build the app
270     staticperl mkapp app --boot eg/httpd \
271     -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI::http
272    
273     # run it
274     ./app
275    
276 root 1.10 Here are the three phase 2 commands:
277    
278     staticperl mkbundle args...
279     The "default" bundle command - it interprets the given bundle
280     options and writes out bundle.h, bundle.c, bundle.ccopts and
281     bundle.ldopts files, useful for embedding.
282    
283     staticperl mkperl args...
284     Creates a bundle just like staticperl mkbundle (in fact, it's the
285     same as invoking staticperl mkbundle --perl args...), but then
286     compiles and links a new perl interpreter that embeds the created
287     bundle, then deletes all intermediate files.
288    
289     staticperl mkapp filename args...
290     Does the same as staticperl mkbundle (in fact, it's the same as
291     invoking staticperl mkbundle --app filename args...), but then
292     compiles and links a new standalone application that simply
293     initialises the perl interpreter.
294    
295     The difference to staticperl mkperl is that the standalone
296     application does not act like a perl interpreter would - in fact, by
297     default it would just do nothing and exit immediately, so you should
298     specify some code to be executed via the --boot option.
299    
300 root 1.2 OPTION PROCESSING
301     All options can be given as arguments on the command line (typically
302     using long (e.g. "--verbose") or short option (e.g. "-v") style). Since
303 root 1.10 specifying a lot of options can make the command line very long and
304     unwieldy, you can put all long options into a "bundle specification
305     file" (one option per line, with or without "--" prefix) and specify
306     this bundle file instead.
307 root 1.2
308 root 1.10 For example, the command given earlier to link a new perl could also
309     look like this:
310 root 1.2
311     staticperl mkperl httpd.bundle
312    
313 root 1.10 With all options stored in the httpd.bundle file (one option per line,
314     everything after the option is an argument):
315 root 1.2
316     use "Config_heavy.pl"
317     use AnyEvent::Impl::Perl
318     use AnyEvent::HTTPD
319     use URI::http
320     add eg/httpd httpd.pm
321    
322     All options that specify modules or files to be added are processed in
323 root 1.10 the order given on the command line.
324    
325 root 1.17 BUNDLE CREATION WORKFLOW / STATICPERL MKBUNDLE OPTIONS
326 root 1.10 staticperl mkbundle works by first assembling a list of candidate files
327     and modules to include, then filtering them by include/exclude patterns.
328     The remaining modules (together with their direct dependencies, such as
329     link libraries and AutoLoader files) are then converted into bundle
330     files suitable for embedding. staticperl mkbundle can then optionally
331     build a new perl interpreter or a standalone application.
332    
333     Step 0: Generic argument processing.
334     The following options influence staticperl mkbundle itself.
335    
336     "--verbose" | "-v"
337     Increases the verbosity level by one (the default is 1).
338    
339     "--quiet" | "-q"
340     Decreases the verbosity level by one.
341    
342     any other argument
343     Any other argument is interpreted as a bundle specification
344     file, which supports all options (without extra quoting), one
345     option per line, in the format "option" or "option argument".
346     They will effectively be expanded and processed as if they were
347     directly written on the command line, in place of the file name.
348    
349     Step 1: gather candidate files and modules
350     In this step, modules, perl libraries (.pl files) and other files
351     are selected for inclusion in the bundle. The relevant options are
352     executed in order (this makes a difference mostly for "--eval",
353     which can rely on earlier "--use" options to have been executed).
354    
355     "--use" module | "-M"module
356 root 1.12 Include the named module or perl library and trace direct
357     dependencies. This is done by loading the module in a subprocess
358     and tracing which other modules and files it actually loads.
359 root 1.10
360     Example: include AnyEvent and AnyEvent::Impl::Perl.
361    
362     staticperl mkbundle --use AnyEvent --use AnyEvent::Impl::Perl
363    
364     Sometimes you want to load old-style "perl libraries" (.pl
365 root 1.12 files), or maybe other weirdly named files. To support this, the
366     "--use" option actually tries to do what you mean, depending on
367     the string you specify:
368    
369     a possibly valid module name, e.g. common::sense, Carp,
370     Coro::Mysql.
371     If the string contains no quotes, no / and no ., then
372     "--use" assumes that it is a normal module name. It will
373     create a new package and evaluate a "use module" in it, i.e.
374     it will load the package and do a default import.
375    
376     The import step is done because many modules trigger more
377     dependencies when something is imported than without.
378    
379     anything that contains / or . characters, e.g. utf8_heavy.pl,
380     Module/private/data.pl.
381     The string will be quoted and passed to require, as if you
382     used "require $module". Nothing will be imported.
383    
384     "path" or 'path', e.g. "utf8_heavy.pl".
385     If you enclose the name into single or double quotes, then
386     the quotes will be removed and the resulting string will be
387     passed to require. This syntax is form compatibility with
388     older versions of staticperl and should not be used anymore.
389    
390     Example: "use" AnyEvent::Socket, once using "use" (importing the
391     symbols), and once via "require", not importing any symbols. The
392     first form is preferred as many modules load some extra
393     dependencies when asked to export symbols.
394    
395     staticperl mkbundle -MAnyEvent::Socket # use + import
396     staticperl mkbundle -MAnyEvent/Socket.pm # require only
397 root 1.10
398     Example: include the required files for perl -V to work in all
399 root 1.12 its glory (Config.pm is included automatically by the dependency
400     tracker).
401 root 1.10
402 root 1.12 # shell command
403     staticperl mkbundle -MConfig_heavy.pl
404 root 1.10
405     # bundle specification file
406 root 1.12 use Config_heavy.pl
407 root 1.10
408     The "-M"module syntax is included as a convenience that might be
409     easier to remember than "--use" - it's the same switch as perl
410     itself uses to load modules. Or maybe it confuses people. Time
411     will tell. Or maybe not. Sigh.
412    
413     "--eval" "perl code" | "-e" "perl code"
414     Sometimes it is easier (or necessary) to specify dependencies
415     using perl code, or maybe one of the modules you use need a
416     special use statement. In that case, you can use "--eval" to
417     execute some perl snippet or set some variables or whatever you
418     need. All files "require"'d or "use"'d while executing the
419     snippet are included in the final bundle.
420    
421 root 1.12 Keep in mind that mkbundle will not import any symbols from the
422     modules named by the "--use" option, so do not expect the
423     symbols from modules you "--use"'d earlier on the command line
424     to be available.
425 root 1.10
426     Example: force AnyEvent to detect a backend and therefore
427     include it in the final bundle.
428    
429     staticperl mkbundle --eval 'use AnyEvent; AnyEvent::detect'
430    
431     # or like this
432     staticperl mkbundle -MAnyEvent --eval 'AnyEvent::detect'
433    
434     Example: use a separate "bootstrap" script that "use"'s lots of
435     modules and also include this in the final bundle, to be
436     executed automatically when the interpreter is initialised.
437    
438     staticperl mkbundle --eval 'do "bootstrap"' --boot bootstrap
439    
440     "--boot" filename
441     Include the given file in the bundle and arrange for it to be
442     executed (using "require") before the main program when the new
443     perl is initialised. This can be used to modify @INC or do
444     similar modifications before the perl interpreter executes
445     scripts given on the command line (or via "-e"). This works even
446     in an embedded interpreter - the file will be executed during
447     interpreter initialisation in that case.
448    
449     "--incglob" pattern
450     This goes through all standard library directories and tries to
451     match any .pm and .pl files against the extended glob pattern
452     (see below). If a file matches, it is added. The pattern is
453     matched against the full path of the file (sans the library
454     directory prefix), e.g. Sys/Syslog.pm.
455    
456     This is very useful to include "everything":
457    
458     --incglob '*'
459    
460     It is also useful for including perl libraries, or trees of
461     those, such as the unicode database files needed by some perl
462     built-ins, the regex engine and other modules.
463    
464     --incglob '/unicore/**.pl'
465    
466     "--add" file | "--add" "file alias"
467     Adds the given (perl) file into the bundle (and optionally call
468     it "alias"). The file is either an absolute path or a path
469     relative to the current directory. If an alias is specified,
470     then this is the name it will use for @INC searches, otherwise
471 root 1.12 the path file will be used as the internal name.
472 root 1.10
473     This switch is used to include extra files into the bundle.
474    
475     Example: embed the file httpd in the current directory as
476     httpd.pm when creating the bundle.
477    
478     staticperl mkperl --add "httpd httpd.pm"
479    
480 root 1.12 # can be accessed via "use httpd"
481    
482     Example: add a file initcode from the current directory.
483    
484     staticperl mkperl --add 'initcode &initcode'
485    
486     # can be accessed via "do '&initcode'"
487    
488 root 1.10 Example: add local files as extra modules in the bundle.
489    
490     # specification file
491     add file1 myfiles/file1.pm
492     add file2 myfiles/file2.pm
493     add file3 myfiles/file3.pl
494    
495     # then later, in perl, use
496     use myfiles::file1;
497     require myfiles::file2;
498     my $res = do "myfiles/file3.pl";
499    
500     "--binadd" file | "--add" "file alias"
501     Just like "--add", except that it treats the file as binary and
502     adds it without any postprocessing (perl files might get
503     stripped to reduce their size).
504    
505 root 1.16 If you specify an alias you should probably add a "/" prefix to
506 root 1.12 avoid clashing with embedded perl files (whose paths never start
507 root 1.16 with "/"), and/or use a special directory prefix, such as
508     "/res/name".
509 root 1.10
510 root 1.16 You can later get a copy of these files by calling "static::find
511     "alias"".
512 root 1.10
513     An alternative way to embed binary files is to convert them to
514     perl and use "do" to get the contents - this method is a bit
515     cumbersome, but works both inside and outside of a staticperl
516 root 1.16 bundle, without extra ado:
517 root 1.10
518     # a "binary" file, call it "bindata.pl"
519     <<'SOME_MARKER'
520     binary data NOT containing SOME_MARKER
521     SOME_MARKER
522    
523     # load the binary
524     chomp (my $data = do "bindata.pl");
525    
526 root 1.16 "--allow-dynamic"
527     By default, when mkbundle hits a dynamic perl extension (e.g. a
528     .so or .dll file), it will stop with a fatal error.
529    
530     When this option is enabled, mkbundle packages the shared object
531     into the bundle instead, with a prefix of ! (e.g.
532     !auto/List/Util/Util.so). What you do with that is currently up
533     to you, staticperl has no special support for this at the
534     moment, apart from working around the lack of availability of
535     PerlIO::scalar while bootstrapping, at a speed cost.
536    
537     One way to deal with this is to write all files starting with !
538     into some directory and then "unshift" that path onto @INC.
539    
540     #TODO: example
541    
542 root 1.10 Step 2: filter all files using "--include" and "--exclude" options.
543     After all candidate files and modules are added, they are *filtered*
544     by a combination of "--include" and "--exclude" patterns (there is
545     an implicit "--include *" at the end, so if no filters are
546     specified, all files are included).
547    
548     All that this step does is potentially reduce the number of files
549     that are to be included - no new files are added during this step.
550    
551     "--include" pattern | "-i" pattern | "--exclude" pattern | "-x"
552     pattern
553     These specify an include or exclude pattern to be applied to the
554     candidate file list. An include makes sure that the given files
555     will be part of the resulting file set, an exclude will exclude
556     remaining files. The patterns are "extended glob patterns" (see
557     below).
558    
559     The patterns are applied "in order" - files included via earlier
560     "--include" specifications cannot be removed by any following
561     "--exclude", and likewise, and file excluded by an earlier
562     "--exclude" cannot be added by any following "--include".
563    
564     For example, to include everything except "Devel" modules, but
565     still include Devel::PPPort, you could use this:
566    
567     --incglob '*' -i '/Devel/PPPort.pm' -x '/Devel/**'
568    
569     Step 3: add any extra or "hidden" dependencies.
570     staticperl currently knows about three extra types of depdendencies
571     that are added automatically. Only one (.packlist files) is
572     currently optional and can be influenced, the others are always
573     included:
574    
575     "--usepacklists"
576     Read .packlist files for each distribution that happens to match
577     a module name you specified. Sounds weird, and it is, so expect
578     semantics to change somehow in the future.
579    
580     The idea is that most CPAN distributions have a .pm file that
581     matches the name of the distribution (which is rather reasonable
582     after all).
583    
584     If this switch is enabled, then if any of the .pm files that
585     have been selected match an install distribution, then all .pm,
586     .pl, .al and .ix files installed by this distribution are also
587     included.
588    
589     For example, using this switch, when the URI module is
590     specified, then all URI submodules that have been installed via
591     the CPAN distribution are included as well, so you don't have to
592     manually specify them.
593    
594     AutoLoader splitfiles
595     Some modules use AutoLoader - less commonly (hopefully) used
596     functions are split into separate .al files, and an index (.ix)
597     file contains the prototypes.
598    
599     Both .ix and .al files will be detected automatically and added
600     to the bundle.
601    
602     link libraries (.a files)
603     Modules using XS (or any other non-perl language extension
604     compiled at installation time) will have a static archive
605     (typically .a). These will automatically be added to the linker
606     options in bundle.ldopts.
607    
608     Should staticperl find a dynamic link library (typically .so) it
609     will warn about it - obviously this shouldn't happen unless you
610     use staticperl on the wrong perl, or one (probably wrongly)
611     configured to use dynamic loading.
612    
613     extra libraries (extralibs.ld)
614     Some modules need linking against external libraries - these are
615     found in extralibs.ld and added to bundle.ldopts.
616    
617     Step 4: write bundle files and optionally link a program
618     At this point, the select files will be read, processed (stripped)
619     and finally the bundle files get written to disk, and staticperl
620     mkbundle is normally finished. Optionally, it can go a step further
621     and either link a new perl binary with all selected modules and
622     files inside, or build a standalone application.
623    
624     Both the contents of the bundle files and any extra linking is
625     controlled by these options:
626    
627     "--strip" "none"|"pod"|"ppi"
628     Specify the stripping method applied to reduce the file of the
629     perl sources included.
630    
631     The default is "pod", which uses the Pod::Strip module to remove
632     all pod documentation, which is very fast and reduces file size
633     a lot.
634    
635     The "ppi" method uses PPI to parse and condense the perl
636     sources. This saves a lot more than just Pod::Strip, and is
637     generally safer, but is also a lot slower (some files take
638     almost a minute to strip - staticperl maintains a cache of
639     stripped files to speed up subsequent runs for this reason).
640     Note that this method doesn't optimise for raw file size, but
641     for best compression (that means that the uncompressed file size
642     is a bit larger, but the files compress better, e.g. with upx).
643    
644     Last not least, if you need accurate line numbers in error
645     messages, or in the unlikely case where "pod" is too slow, or
646     some module gets mistreated, you can specify "none" to not
647     mangle included perl sources in any way.
648    
649     "--perl"
650     After writing out the bundle files, try to link a new perl
651     interpreter. It will be called perl and will be left in the
652     current working directory. The bundle files will be removed.
653    
654     This switch is automatically used when staticperl is invoked
655     with the "mkperl" command instead of "mkbundle".
656    
657     Example: build a new ./perl binary with only common::sense
658     inside - it will be even smaller than the standard perl
659     interpreter as none of the modules of the base distribution
660     (such as Fcntl) will be included.
661    
662     staticperl mkperl -Mcommon::sense
663    
664     "--app" name
665     After writing out the bundle files, try to link a new standalone
666     program. It will be called "name", and the bundle files get
667     removed after linking it.
668    
669     This switch is automatically used when staticperl is invoked
670     with the "mkapp" command instead of "mkbundle".
671    
672     The difference to the (mutually exclusive) "--perl" option is
673     that the binary created by this option will not try to act as a
674     perl interpreter - instead it will simply initialise the perl
675     interpreter, clean it up and exit.
676    
677 root 1.12 This means that, by default, it will do nothing but burn a few
678 root 1.10 CPU cycles - for it to do something useful you *must* add some
679     boot code, e.g. with the "--boot" option.
680    
681     Example: create a standalone perl binary called ./myexe that
682     will execute appfile when it is started.
683    
684     staticperl mkbundle --app myexe --boot appfile
685    
686 root 1.12 "--ignore-env"
687     Generates extra code to unset some environment variables before
688     initialising/running perl. Perl supports a lot of environment
689     variables that might alter execution in ways that might be
690     undesirablre for standalone applications, and this option
691     removes those known to cause trouble.
692    
693     Specifically, these are removed:
694    
695     "PERL_HASH_SEED_DEBUG" and "PERL_DEBUG_MSTATS" can cause
696 root 1.17 undesirable output, "PERL5OPT", "PERL_DESTRUCT_LEVEL",
697 root 1.12 "PERL_HASH_SEED" and "PERL_SIGNALS" can alter execution
698     significantly, and "PERL_UNICODE", "PERLIO_DEBUG" and "PERLIO"
699     can affect input and output.
700    
701     The variables "PERL_LIB" and "PERL5_LIB" are always ignored
702     because the startup code used by staticperl overrides @INC in
703     all cases.
704    
705     This option will not make your program more secure (unless you
706     are running with elevated privileges), but it will reduce the
707     surprise effect when a user has these environment variables set
708     and doesn't expect your standalone program to act like a perl
709     interpreter.
710    
711 root 1.10 "--static"
712     Add "-static" to bundle.ldopts, which means a fully static (if
713     supported by the OS) executable will be created. This is not
714     immensely useful when just creating the bundle files, but is
715     most useful when linking a binary with the "--perl" or "--app"
716     options.
717    
718     The default is to link the new binary dynamically (that means
719     all perl modules are linked statically, but all external
720     libraries are still referenced dynamically).
721    
722     Keep in mind that Solaris doesn't support static linking at all,
723     and systems based on GNU libc don't really support it in a very
724     usable fashion either. Try uClibc if you want to create fully
725     statically linked executables, or try the "--staticlib" option
726     to link only some libraries statically.
727    
728     "--staticlib" libname
729     When not linking fully statically, this option allows you to
730     link specific libraries statically. What it does is simply
731     replace all occurrences of "-llibname" with the GCC-specific
732     "-Wl,-Bstatic -llibname -Wl,-Bdynamic" option.
733    
734     This will have no effect unless the library is actually linked
735     against, specifically, "--staticlib" will not link against the
736     named library unless it would be linked against anyway.
737    
738     Example: link libcrypt statically into the final binary.
739 root 1.2
740 root 1.10 staticperl mkperl -MIO::AIO --staticlib crypt
741    
742     # ldopts might now contain:
743     # -lm -Wl,-Bstatic -lcrypt -Wl,-Bdynamic -lpthread
744 root 1.2
745 root 1.8 EXTENDED GLOB PATTERNS
746     Some options of staticperl mkbundle expect an *extended glob pattern*.
747     This is neither a normal shell glob nor a regex, but something in
748     between. The idea has been copied from rsync, and there are the current
749     matching rules:
750    
751     Patterns starting with / will be a anchored at the root of the library
752     tree.
753     That is, /unicore will match the unicore directory in @INC, but
754     nothing inside, and neither any other file or directory called
755     unicore anywhere else in the hierarchy.
756    
757     Patterns not starting with / will be anchored at the end of the path.
758     That is, idna.pl will match any file called idna.pl anywhere in the
759     hierarchy, but not any directories of the same name.
760    
761 root 1.10 A * matches anything within a single path component.
762 root 1.8 That is, /unicore/*.pl would match all .pl files directly inside
763     "/unicore", not any deeper level .pl files. Or in other words, *
764     will not match slashes.
765    
766     A ** matches anything.
767     That is, /unicore/**.pl would match all .pl files under /unicore, no
768     matter how deeply nested they are inside subdirectories.
769    
770     A ? matches a single character within a component.
771     That is, /Encode/??.pm matches /Encode/JP.pm, but not the
772     hypothetical /Encode/J/.pm, as ? does not match /.
773    
774     STATICPERL CONFIGURATION AND HOOKS
775     During (each) startup, staticperl tries to source some shell files to
776     allow you to fine-tune/override configuration settings.
777    
778     In them you can override shell variables, or define shell functions
779     ("hooks") to be called at specific phases during installation. For
780     example, you could define a "postinstall" hook to install additional
781     modules from CPAN each time you start from scratch.
782    
783     If the env variable $STATICPERLRC is set, then staticperl will try to
784     source the file named with it only. Otherwise, it tries the following
785     shell files in order:
786 root 1.2
787     /etc/staticperlrc
788     ~/.staticperlrc
789     $STATICPERL/rc
790    
791     Note that the last file is erased during staticperl distclean, so
792     generally should not be used.
793    
794     CONFIGURATION VARIABLES
795     Variables you *should* override
796     "EMAIL"
797     The e-mail address of the person who built this binary. Has no good
798     default, so should be specified by you.
799    
800     "CPAN"
801     The URL of the CPAN mirror to use (e.g.
802     <http://mirror.netcologne.de/cpan/>).
803    
804 root 1.4 "EXTRA_MODULES"
805     Additional modules installed during staticperl install. Here you can
806     set which modules you want have to installed from CPAN.
807    
808 root 1.5 Example: I really really need EV, AnyEvent, Coro and AnyEvent::AIO.
809 root 1.2
810 root 1.5 EXTRA_MODULES="EV AnyEvent Coro AnyEvent::AIO"
811 root 1.2
812 root 1.4 Note that you can also use a "postinstall" hook to achieve this, and
813     more.
814 root 1.2
815 root 1.5 Variables you might *want* to override
816     "STATICPERL"
817     The directory where staticperl stores all its files (default:
818     ~/.staticperl).
819    
820 root 1.16 "DLCACHE"
821     The path to a directory (will be created if it doesn't exist) where
822     downloaded perl sources are being cached, to avoid downloading them
823     again. The default is empty, which means there is no cache.
824 root 1.2
825 root 1.5 "PERL_VERSION"
826 root 1.12 The perl version to install - default is currently 5.12.3, but 5.8.9
827     is also a good choice (5.8.9 is much smaller than 5.12.3, while
828     5.10.1 is about as big as 5.12.3).
829 root 1.2
830 root 1.16 "PERL_MM_USE_DEFAULT", "EV_EXTRA_DEFS", ...
831     Usually set to 1 to make modules "less inquisitive" during their
832     installation. You can set (and export!) any environment variable you
833     want - some modules (such as Coro or EV) use environment variables
834     for further tweaking.
835    
836 root 1.5 "PERL_PREFIX"
837 root 1.4 The prefix where perl gets installed (default: $STATICPERL/perl),
838     i.e. where the bin and lib subdirectories will end up.
839 root 1.2
840 root 1.5 "PERL_CONFIGURE"
841     Additional Configure options - these are simply passed to the perl
842     Configure script. For example, if you wanted to enable dynamic
843     loading, you could pass "-Dusedl". To enable ithreads (Why would you
844     want that insanity? Don't! Use forks instead!) you would pass
845     "-Duseithreads" and so on.
846    
847     More commonly, you would either activate 64 bit integer support
848     ("-Duse64bitint"), or disable large files support (-Uuselargefiles),
849     to reduce filesize further.
850    
851 root 1.9 "PERL_CC", "PERL_CCFLAGS", "PERL_OPTIMIZE", "PERL_LDFLAGS", "PERL_LIBS"
852 root 1.4 These flags are passed to perl's Configure script, and are generally
853     optimised for small size (at the cost of performance). Since they
854     also contain subtle workarounds around various build issues,
855     changing these usually requires understanding their default values -
856     best look at the top of the staticperl script for more info on
857 root 1.9 these, and use a ~/.staticperlrc to override them.
858    
859     Most of the variables override (or modify) the corresponding
860     Configure variable, except "PERL_CCFLAGS", which gets appended.
861 root 1.2
862 root 1.16 The default for "PERL_OPTIMIZE" is "-Os" (assuming gcc), and for
863     "PERL_LIBS" is "-lm -lcrypt", which should be good for most (but not
864     all) systems.
865    
866     For other compilers or more customised optimisation settings, you
867     need to adjust these, e.g. in your ~/.staticperlrc.
868    
869     With gcc on x86 and amd64, you can get more space-savings by using:
870    
871     -Os -ffunction-sections -fdata-sections -finline-limit=8 -mpush-args
872     -mno-inline-stringops-dynamically -mno-align-stringops
873    
874     And on x86 and pentium3 and newer (basically everything you might
875     ever want to run on), adding these is even better for space-savings
876     (use -mtune=core2 or something newer for much faster code, too):
877    
878     -fomit-frame-pointer -march=pentium3 -mtune=i386
879 root 1.14
880 root 1.3 Variables you probably *do not want* to override
881 root 1.9 "MAKE"
882     The make command to use - default is "make".
883    
884 root 1.2 "MKBUNDLE"
885     Where staticperl writes the "mkbundle" command to (default:
886     $STATICPERL/mkbundle).
887    
888     "STATICPERL_MODULES"
889     Additional modules needed by "mkbundle" - should therefore not be
890     changed unless you know what you are doing.
891    
892     OVERRIDABLE HOOKS
893     In addition to environment variables, it is possible to provide some
894     shell functions that are called at specific times. To provide your own
895     commands, just define the corresponding function.
896    
897 root 1.13 The actual order in which hooks are invoked during a full install from
898     scratch is "preconfigure", "patchconfig", "postconfigure", "postbuild",
899     "postinstall".
900    
901 root 1.2 Example: install extra modules from CPAN and from some directories at
902     staticperl install time.
903    
904     postinstall() {
905 root 1.3 rm -rf lib/threads* # weg mit Schaden
906 root 1.2 instcpan IO::AIO EV
907     instsrc ~/src/AnyEvent
908     instsrc ~/src/XML-Sablotron-1.0100001
909 root 1.3 instcpan Anyevent::AIO AnyEvent::HTTPD
910 root 1.2 }
911    
912 root 1.6 preconfigure
913 root 1.13 Called just before running ./Configure in the perl source directory.
914 root 1.6 Current working directory is the perl source directory.
915    
916     This can be used to set any "PERL_xxx" variables, which might be
917     costly to compute.
918    
919 root 1.13 patchconfig
920     Called after running ./Configure in the perl source directory to
921     create ./config.sh, but before running ./Configure -S to actually
922     apply the config. Current working directory is the perl source
923     directory.
924    
925     Can be used to tailor/patch config.sh or do any other modifications.
926    
927 root 1.2 postconfigure
928     Called after configuring, but before building perl. Current working
929     directory is the perl source directory.
930    
931     postbuild
932     Called after building, but before installing perl. Current working
933     directory is the perl source directory.
934    
935     I have no clue what this could be used for - tell me.
936    
937     postinstall
938     Called after perl and any extra modules have been installed in
939     $PREFIX, but before setting the "installation O.K." flag.
940    
941     The current working directory is $PREFIX, but maybe you should not
942     rely on that.
943    
944     This hook is most useful to customise the installation, by deleting
945     files, or installing extra modules using the "instcpan" or "instsrc"
946     functions.
947    
948     The script must return with a zero exit status, or the installation
949     will fail.
950    
951 root 1.5 ANATOMY OF A BUNDLE
952     When not building a new perl binary, "mkbundle" will leave a number of
953     files in the current working directory, which can be used to embed a
954     perl interpreter in your program.
955    
956     Intimate knowledge of perlembed and preferably some experience with
957     embedding perl is highly recommended.
958    
959     "mkperl" (or the "--perl" option) basically does this to link the new
960     interpreter (it also adds a main program to bundle.):
961    
962     $Config{cc} $(cat bundle.ccopts) -o perl bundle.c $(cat bundle.ldopts)
963    
964     bundle.h
965     A header file that contains the prototypes of the few symbols
966     "exported" by bundle.c, and also exposes the perl headers to the
967     application.
968    
969 root 1.12 staticperl_init (xs_init = 0)
970 root 1.5 Initialises the perl interpreter. You can use the normal perl
971     functions after calling this function, for example, to define
972     extra functions or to load a .pm file that contains some
973     initialisation code, or the main program function:
974    
975     XS (xsfunction)
976     {
977     dXSARGS;
978    
979     // now we have items, ST(i) etc.
980     }
981    
982     static void
983     run_myapp(void)
984     {
985 root 1.12 staticperl_init (0);
986 root 1.5 newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$");
987     eval_pv ("require myapp::main", 1); // executes "myapp/main.pm"
988     }
989    
990 root 1.12 When your bootcode already wants to access some XS functions at
991     compiletime, then you need to supply an "xs_init" function
992     pointer that is called as soon as perl is initialised enough to
993     define XS functions, but before the preamble code is executed:
994    
995     static void
996     xs_init (pTHX)
997     {
998     newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$");
999     }
1000    
1001     static void
1002     run_myapp(void)
1003     {
1004     staticperl_init (xs_init);
1005     }
1006    
1007     staticperl_cleanup ()
1008     In the unlikely case that you want to destroy the perl
1009     interpreter, here is the corresponding function.
1010    
1011 root 1.5 staticperl_xs_init (pTHX)
1012     Sometimes you need direct control over "perl_parse" and
1013     "perl_run", in which case you do not want to use
1014     "staticperl_init" but call them on your own.
1015    
1016     Then you need this function - either pass it directly as the
1017 root 1.12 "xs_init" function to "perl_parse", or call it as one of the
1018     first things from your own "xs_init" function.
1019 root 1.5
1020     PerlInterpreter *staticperl
1021     The perl interpreter pointer used by staticperl. Not normally so
1022     useful, but there it is.
1023    
1024     bundle.ccopts
1025     Contains the compiler options required to compile at least bundle.c
1026     and any file that includes bundle.h - you should probably use it in
1027     your "CFLAGS".
1028    
1029     bundle.ldopts
1030     The linker options needed to link the final program.
1031    
1032     RUNTIME FUNCTIONALITY
1033 root 1.16 Binaries created with "mkbundle"/"mkperl" contain extra functionality,
1034     mostly related to the extra files bundled in the binary (the virtual
1035     filesystem). All of this data is statically compiled into the binary,
1036     and accessing means copying it from a read-only section of your binary.
1037     Data pages in this way is usually freed by the operating system, as it
1038     isn't use more the onace.
1039    
1040     VIRTUAL FILESYSTEM
1041     Every bundle has a virtual filesystem. The only information stored in it
1042     is the path and contents of each file that was bundled.
1043    
1044     LAYOUT
1045     Any path starting with an ampersand (&) or exclamation mark (!) are
1046     reserved by staticperl. They must only be used as described in this
1047     section.
1048    
1049     ! All files that typically cannot be loaded from memory (such as
1050     dynamic objects or shared libraries), but have to reside in the
1051     filesystem, are prefixed with !. Typically these files get written
1052     out to some (semi-)temporary directory shortly after program
1053     startup, or before being used.
1054    
1055     !boot
1056     The bootstrap file, if specified during bundling.
1057    
1058     !auto/
1059     Shared objects or dlls corresponding to dynamically-linked perl
1060     extensions are stored with an !auto/ prefix.
1061    
1062     !lib/
1063     External shared libraries are stored in this directory.
1064    
1065     any letter
1066     Any path starting with a letter is a perl library file. For example,
1067     Coro/AIO.pm corresponds to the file loaded by "use Coro::AIO", and
1068     Coro/jit.pl corresponds to "require "Coro/jit.pl"".
1069 root 1.5
1070 root 1.16 Obviously, module names shouldn't start with any other characters
1071     than letters :)
1072 root 1.5
1073 root 1.16 FUNCTIONS
1074     $file = static::find $path
1075 root 1.5 Returns the data associated with the given $path (e.g.
1076 root 1.16 "Digest/MD5.pm", "auto/POSIX/autosplit.ix").
1077 root 1.5
1078     Returns "undef" if the file isn't embedded.
1079    
1080 root 1.16 @paths = static::list
1081 root 1.5 Returns the list of all paths embedded in this binary.
1082    
1083 root 1.16 EXTRA FEATURES
1084     In addition, for the embedded loading of perl files to work, staticperl
1085     overrides the @INC array.
1086    
1087 root 1.10 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT
1088 root 1.5 To make truly static (Linux-) libraries, you might want to have a look
1089     at buildroot (<http://buildroot.uclibc.org/>).
1090    
1091     Buildroot is primarily meant to set up a cross-compile environment
1092     (which is not so useful as perl doesn't quite like cross compiles), but
1093     it can also compile a chroot environment where you can use staticperl.
1094    
1095     To do so, download buildroot, and enable "Build options => development
1096     files in target filesystem" and optionally "Build options => gcc
1097     optimization level (optimize for size)". At the time of writing, I had
1098     good experiences with GCC 4.4.x but not GCC 4.5.
1099    
1100     To minimise code size, I used "-pipe -ffunction-sections -fdata-sections
1101     -finline-limit=8 -fno-builtin-strlen -mtune=i386". The "-mtune=i386"
1102     doesn't decrease codesize much, but it makes the file much more
1103 root 1.15 compressible (and the execution a lot slower...).
1104 root 1.5
1105     If you don't need Coro or threads, you can go with "linuxthreads.old"
1106     (or no thread support). For Coro, it is highly recommended to switch to
1107     a uClibc newer than 0.9.31 (at the time of this writing, I used the
1108     20101201 snapshot) and enable NPTL, otherwise Coro needs to be
1109     configured with the ultra-slow pthreads backend to work around
1110     linuxthreads bugs (it also uses twice the address space needed for
1111     stacks).
1112    
1113     If you use "linuxthreads.old", then you should also be aware that uClibc
1114     shares "errno" between all threads when statically linking. See
1115     <http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a
1116 root 1.16 workaround (and <https://bugs.uclibc.org/2089> for discussion).
1117 root 1.5
1118     "ccache" support is also recommended, especially if you want to play
1119     around with buildroot options. Enabling the "miniperl" package will
1120     probably enable all options required for a successful perl build.
1121     staticperl itself additionally needs either "wget" (recommended, for
1122     CPAN) or "curl".
1123    
1124     As for shells, busybox should provide all that is needed, but the
1125     default busybox configuration doesn't include comm which is needed by
1126     perl - either make a custom busybox config, or compile coreutils.
1127    
1128     For the latter route, you might find that bash has some bugs that keep
1129     it from working properly in a chroot - either use dash (and link it to
1130     /bin/sh inside the chroot) or link busybox to /bin/sh, using it's
1131     built-in ash shell.
1132    
1133     Finally, you need /dev/null inside the chroot for many scripts to work -
1134 root 1.16 either cp /dev/null output/target/dev or bind-mounting your /dev will
1135 root 1.5 provide this.
1136    
1137     After you have compiled and set up your buildroot target, you can copy
1138 root 1.16 staticperl from the "App::Staticperl" distribution or from your perl bin
1139     directory (if you installed it) into the output/target filesystem,
1140     chroot inside and run it.
1141 root 1.5
1142 root 1.8 RECIPES / SPECIFIC MODULES
1143     This section contains some common(?) recipes and information about
1144     problems with some common modules or perl constructs that require extra
1145     files to be included.
1146    
1147     MODULES
1148     utf8
1149     Some functionality in the utf8 module, such as swash handling (used
1150     for unicode character ranges in regexes) is implemented in the
1151     "utf8_heavy.pl" library:
1152    
1153 root 1.12 -Mutf8_heavy.pl
1154 root 1.8
1155     Many Unicode properties in turn are defined in separate modules,
1156     such as "unicore/Heavy.pl" and more specific data tables such as
1157     "unicore/To/Digit.pl" or "unicore/lib/Perl/Word.pl". These tables
1158     are big (7MB uncompressed, although staticperl contains special
1159     handling for those files), so including them on demand by your
1160     application only might pay off.
1161    
1162     To simply include the whole unicode database, use:
1163    
1164 root 1.11 --incglob '/unicore/**.pl'
1165 root 1.8
1166     AnyEvent
1167     AnyEvent needs a backend implementation that it will load in a
1168     delayed fashion. The AnyEvent::Impl::Perl backend is the default
1169     choice for AnyEvent if it can't find anything else, and is usually a
1170     safe fallback. If you plan to use e.g. EV (POE...), then you need to
1171     include the AnyEvent::Impl::EV (AnyEvent::Impl::POE...) backend as
1172     well.
1173    
1174     If you want to handle IRIs or IDNs (AnyEvent::Util punycode and idn
1175     functions), you also need to include "AnyEvent/Util/idna.pl" and
1176     "AnyEvent/Util/uts46data.pl".
1177    
1178 root 1.10 Or you can use "--usepacklists" and specify "-MAnyEvent" to include
1179 root 1.8 everything.
1180    
1181 root 1.14 Cairo
1182     See Glib, same problem, same solution.
1183    
1184 root 1.8 Carp
1185     Carp had (in older versions of perl) a dependency on Carp::Heavy. As
1186     of perl 5.12.2 (maybe earlier), this dependency no longer exists.
1187    
1188     Config
1189     The perl -V switch (as well as many modules) needs Config, which in
1190     turn might need "Config_heavy.pl". Including the latter gives you
1191     both.
1192    
1193 root 1.14 Glib
1194     Glib literally requires Glib to be installed already to build - it
1195     tries to fake this by running Glib out of the build directory before
1196     being built. staticperl tries to work around this by forcing
1197     "MAN1PODS" and "MAN3PODS" to be empty via the "PERL_MM_OPT"
1198     environment variable.
1199    
1200     Gtk2
1201     See Pango, same problems, same solution.
1202    
1203     Pango
1204     In addition to the "MAN3PODS" problem in Glib, Pango also routes
1205     around ExtUtils::MakeMaker by compiling its files on its own.
1206     staticperl tries to patch ExtUtils::MM_Unix to route around Pango.
1207    
1208 root 1.8 Term::ReadLine::Perl
1209 root 1.10 Also needs Term::ReadLine::readline, or "--usepacklists".
1210 root 1.8
1211     URI URI implements schemes as separate modules - the generic URL scheme
1212     is implemented in URI::_generic, HTTP is implemented in URI::http.
1213     If you need to use any of these schemes, you should include these
1214 root 1.10 manually, or use "--usepacklists".
1215 root 1.8
1216     RECIPES
1217 root 1.10 Just link everything in
1218 root 1.8 To link just about everything installed in the perl library into a
1219 root 1.10 new perl, try this (the first time this runs it will take a long
1220     time, as a lot of files need to be parsed):
1221    
1222     staticperl mkperl -v --strip ppi --incglob '*'
1223    
1224     If you don't mind the extra megabytes, this can be a very effective
1225     way of creating bundles without having to worry about forgetting any
1226     modules.
1227 root 1.8
1228 root 1.10 You get even more useful variants of this method by first selecting
1229     everything, and then excluding stuff you are reasonable sure not to
1230     need - bigperl <http://staticperl.schmorp.de/bigperl.html> uses this
1231     approach.
1232 root 1.8
1233 root 1.10 Getting rid of netdb functions
1234 root 1.8 The perl core has lots of netdb functions ("getnetbyname",
1235     "getgrent" and so on) that few applications use. You can avoid
1236     compiling them in by putting the following fragment into a
1237     "preconfigure" hook:
1238    
1239     preconfigure() {
1240     for sym in \
1241     d_getgrnam_r d_endgrent d_endgrent_r d_endhent \
1242     d_endhostent_r d_endnent d_endnetent_r d_endpent \
1243     d_endprotoent_r d_endpwent d_endpwent_r d_endsent \
1244     d_endservent_r d_getgrent d_getgrent_r d_getgrgid_r \
1245     d_getgrnam_r d_gethbyaddr d_gethent d_getsbyport \
1246     d_gethostbyaddr_r d_gethostbyname_r d_gethostent_r \
1247     d_getlogin_r d_getnbyaddr d_getnbyname d_getnent \
1248     d_getnetbyaddr_r d_getnetbyname_r d_getnetent_r \
1249     d_getpent d_getpbyname d_getpbynumber d_getprotobyname_r \
1250     d_getprotobynumber_r d_getprotoent_r d_getpwent \
1251     d_getpwent_r d_getpwnam_r d_getpwuid_r d_getsent \
1252     d_getservbyname_r d_getservbyport_r d_getservent_r \
1253     d_getspnam_r d_getsbyname
1254     # d_gethbyname
1255     do
1256     PERL_CONFIGURE="$PERL_CONFIGURE -U$sym"
1257     done
1258     }
1259    
1260 root 1.11 This mostly gains space when linking statically, as the functions
1261 root 1.9 will likely not be linked in. The gain for dynamically-linked
1262 root 1.8 binaries is smaller.
1263    
1264     Also, this leaves "gethostbyname" in - not only is it actually used
1265     often, the Socket module also exposes it, so leaving it out usually
1266     gains little. Why Socket exposes a C function that is in the core
1267     already is anybody's guess.
1268    
1269 root 1.1 AUTHOR
1270     Marc Lehmann <schmorp@schmorp.de>
1271     http://software.schmorp.de/pkg/staticperl.html
1272