ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/README
Revision: 1.23
Committed: Sat Apr 4 15:26:25 2026 UTC (5 months, 1 week ago) by root
Branch: MAIN
CVS Tags: rel-1_5, HEAD
Changes since 1.22: +78 -36 lines
Log Message:
*** empty log message ***

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