ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.pod
(Generate patch)

Comparing App-Staticperl/staticperl.pod (file contents):
Revision 1.18 by root, Fri Dec 10 02:35:54 2010 UTC vs.
Revision 1.23 by root, Mon Dec 13 18:08:01 2010 UTC

40 40
41With F<uClibc> and F<upx> on x86, you can create a single 500kb binary 41With F<uClibc> and F<upx> on x86, you can create a single 500kb binary
42that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, 42that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO,
43Coro and so on. Or any other choice of modules. 43Coro and so on. Or any other choice of modules.
44 44
45To see how this turns out, you can try out smallperl and bigperl, two
46pre-built static and compressed perl binaries with many and even more
47modules: just follow the links at L<http://staticperl.schmorp.de/>.
48
45The created files do not need write access to the file system (like PAR 49The created files do not need write access to the file system (like PAR
46does). In fact, since this script is in many ways similar to PAR::Packer, 50does). In fact, since this script is in many ways similar to PAR::Packer,
47here are the differences: 51here are the differences:
48 52
49=over 4 53=over 4
118often as necessary. 122often as necessary.
119 123
120=head1 THE F<STATICPERL> SCRIPT 124=head1 THE F<STATICPERL> SCRIPT
121 125
122This module installs a script called F<staticperl> into your perl 126This module installs a script called F<staticperl> into your perl
123binary directory. The script is fully self-contained, and can be used 127binary directory. The script is fully self-contained, and can be
124without perl (for example, in an uClibc chroot environment). In fact, 128used without perl (for example, in an uClibc chroot environment). In
125it can be extracted from the C<App::Staticperl> distribution tarball as 129fact, it can be extracted from the C<App::Staticperl> distribution
126F<bin/staticperl>, without any installation. 130tarball as F<bin/staticperl>, without any installation. The
131newest (possibly alpha) version can also be downloaded from
132L<http://staticperl.schmorp.de/staticperl>.
127 133
128F<staticperl> interprets the first argument as a command to execute, 134F<staticperl> interprets the first argument as a command to execute,
129optionally followed by any parameters. 135optionally followed by any parameters.
130 136
131There are two command categories: the "phase 1" commands which deal with 137There are two command categories: the "phase 1" commands which deal with
152 158
153To force recompilation or reinstallation, you need to run F<staticperl 159To force recompilation or reinstallation, you need to run F<staticperl
154distclean> first. 160distclean> first.
155 161
156=over 4 162=over 4
163
164=item F<staticperl version>
165
166Prints some info about the version of the F<staticperl> script you are using.
157 167
158=item F<staticperl fetch> 168=item F<staticperl fetch>
159 169
160Runs only the download and unpack phase, unless this has already happened. 170Runs only the download and unpack phase, unless this has already happened.
161 171
286 296
287All options that specify modules or files to be added are processed in the 297All options that specify modules or files to be added are processed in the
288order given on the command line (that affects the C<--use> and C<--eval> 298order given on the command line (that affects the C<--use> and C<--eval>
289options at the moment). 299options at the moment).
290 300
301=head3 PACKAGE SELECTION WORKFLOW
302
303F<staticperl mkbundle> has a number of options to control package
304selection. This section describes how they interact with each other. Also,
305since I am still a newbie w.r.t. these issues, maybe future versions of
306F<staticperl> will change this, so watch out :)
307
308The idiom "in order" means "in order that they are specified on the
309commandline". If you use a bundle specification file, then the options
310will be processed as if they were given in place of the bundle file name.
311
312=over 4
313
314=item 1. apply all C<--use>, C<--eval>, C<--add>, C<--addbin> and
315C<--incglob> options, in order.
316
317In addition, C<--use> and C<--eval> dependencies will be added when the
318options are processed.
319
320=item 2. apply all C<--include> and C<--exclude> options, in order.
321
322All this step does is potentially reduce the number of files already
323selected or found in phase 1.
324
325=item 3. find all modules (== F<.pm> files), gather their static archives
326(F<.a>) and AutoLoader splitfiles (F<.ix> and F<.al> files), find any
327extra libraries they need for linking (F<extralibs.ld>) and optionally
328evaluate any F<.packlist> files.
329
330This step is required to link against XS extensions and also adds files
331required for L<AutoLoader> to do it's job.
332
333=back
334
335After this, all the files selected for bundling will be read and processed
336(stripped), the bundle files will be written, and optionally a new F<perl>
337or application binary will be linked.
338
291=head3 MKBUNDLE OPTIONS 339=head3 MKBUNDLE OPTIONS
292 340
293=over 4 341=over 4
294 342
295=item --verbose | -v 343=item --verbose | -v
416(using a C<require>) before anything else when the new perl is 464(using a C<require>) before anything else when the new perl is
417initialised. This can be used to modify C<@INC> or anything else before 465initialised. This can be used to modify C<@INC> or anything else before
418the perl interpreter executes scripts given on the command line (or via 466the perl interpreter executes scripts given on the command line (or via
419C<-e>). This works even in an embedded interpreter. 467C<-e>). This works even in an embedded interpreter.
420 468
469=item --usepacklist
470
471Read F<.packlist> files for each distribution that happens to match a
472module name you specified. Sounds weird, and it is, so expect semantics to
473change somehow in the future.
474
475The idea is that most CPAN distributions have a F<.pm> file that matches
476the name of the distribution (which is rather reasonable after all).
477
478If this switch is enabled, then if any of the F<.pm> files that have been
479selected match an install distribution, then all F<.pm>, F<.pl>, F<.al>
480and F<.ix> files installed by this distribution are also included.
481
482For example, using this switch, when the L<URI> module is specified, then
483all L<URI> submodules that have been installed via the CPAN distribution
484are included as well, so you don't have to manually specify them.
485
421=item --incglob pattern 486=item --incglob pattern
422 487
423This goes through all library directories and tries to match any F<.pm> 488This goes through all library directories and tries to match any F<.pm>
424and F<.pl> files against the extended glob pattern (see below). If a file 489and F<.pl> files against the extended glob pattern (see below). If a file
425matches, it is added. This switch will automatically detect L<AutoLoader> 490matches, it is added. This switch will automatically detect L<AutoLoader>
552 617
553=back 618=back
554 619
555=head2 F<STATICPERL> CONFIGURATION AND HOOKS 620=head2 F<STATICPERL> CONFIGURATION AND HOOKS
556 621
557During (each) startup, F<staticperl> tries to source the following shell 622During (each) startup, F<staticperl> tries to source some shell files to
623allow you to fine-tune/override configuration settings.
624
625In them you can override shell variables, or define shell functions
626("hooks") to be called at specific phases during installation. For
627example, you could define a C<postinstall> hook to install additional
628modules from CPAN each time you start from scratch.
629
630If the env variable C<$STATICPERLRC> is set, then F<staticperl> will try
631to source the file named with it only. Otherwise, it tries the following
558files in order: 632shell files in order:
559 633
560 /etc/staticperlrc 634 /etc/staticperlrc
561 ~/.staticperlrc 635 ~/.staticperlrc
562 $STATICPERL/rc 636 $STATICPERL/rc
563
564They can be used to override shell variables, or define functions to be
565called at specific phases.
566 637
567Note that the last file is erased during F<staticperl distclean>, so 638Note that the last file is erased during F<staticperl distclean>, so
568generally should not be used. 639generally should not be used.
569 640
570=head3 CONFIGURATION VARIABLES 641=head3 CONFIGURATION VARIABLES
632 703
633More commonly, you would either activate 64 bit integer support 704More commonly, you would either activate 64 bit integer support
634(C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to 705(C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to
635reduce filesize further. 706reduce filesize further.
636 707
637=item C<PERL_CPPFLAGS>, C<PERL_OPTIMIZE>, C<PERL_LDFLAGS>, C<PERL_LIBS> 708=item C<PERL_CC>, C<PERL_CPPFLAGS>, C<PERL_OPTIMIZE>, C<PERL_LDFLAGS>, C<PERL_LIBS>
638 709
639These flags are passed to perl's F<Configure> script, and are generally 710These flags are passed to perl's F<Configure> script, and are generally
640optimised for small size (at the cost of performance). Since they also 711optimised for small size (at the cost of performance). Since they also
641contain subtle workarounds around various build issues, changing these 712contain subtle workarounds around various build issues, changing these
642usually requires understanding their default values - best look at the top 713usually requires understanding their default values - best look at the top
645=back 716=back
646 717
647=head4 Variables you probably I<do not want> to override 718=head4 Variables you probably I<do not want> to override
648 719
649=over 4 720=over 4
721
722=item C<MAKE>
723
724The make command to use - default is C<make>.
650 725
651=item C<MKBUNDLE> 726=item C<MKBUNDLE>
652 727
653Where F<staticperl> writes the C<mkbundle> command to 728Where F<staticperl> writes the C<mkbundle> command to
654(default: F<$STATICPERL/mkbundle>). 729(default: F<$STATICPERL/mkbundle>).
916 991
917If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn 992If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn
918functions), you also need to include C<"AnyEvent/Util/idna.pl"> and 993functions), you also need to include C<"AnyEvent/Util/idna.pl"> and
919C<"AnyEvent/Util/uts46data.pl">. 994C<"AnyEvent/Util/uts46data.pl">.
920 995
996Or you can use C<--usepacklist> and specify C<-MAnyEvent> to include
997everything.
998
921=item Carp 999=item Carp
922 1000
923Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of 1001Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of
924perl 5.12.2 (maybe earlier), this dependency no longer exists. 1002perl 5.12.2 (maybe earlier), this dependency no longer exists.
925 1003
929turn might need L<"Config_heavy.pl">. Including the latter gives you 1007turn might need L<"Config_heavy.pl">. Including the latter gives you
930both. 1008both.
931 1009
932=item Term::ReadLine::Perl 1010=item Term::ReadLine::Perl
933 1011
934Also needs L<Term::ReadLine::readline>. 1012Also needs L<Term::ReadLine::readline>, or C<--usepacklist>.
935 1013
936=item URI 1014=item URI
937 1015
938URI implements schemes as separate modules - the generic URL scheme is 1016URI implements schemes as separate modules - the generic URL scheme is
939implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If 1017implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If
940you need to use any of these schemes, you should include these manually. 1018you need to use any of these schemes, you should include these manually,
1019or use C<--usepacklist>.
941 1020
942=back 1021=back
943 1022
944=head2 RECIPES 1023=head2 RECIPES
945 1024
978 PERL_CONFIGURE="$PERL_CONFIGURE -U$sym" 1057 PERL_CONFIGURE="$PERL_CONFIGURE -U$sym"
979 done 1058 done
980 } 1059 }
981 1060
982This mostly gains space when linking staticaly, as the functions will 1061This mostly gains space when linking staticaly, as the functions will
983liekly not be linked in. The gain for dynamically-linked binaries is 1062likely not be linked in. The gain for dynamically-linked binaries is
984smaller. 1063smaller.
985 1064
986Also, this leaves C<gethostbyname> in - not only is it actually used 1065Also, this leaves C<gethostbyname> in - not only is it actually used
987often, the L<Socket> module also exposes it, so leaving it out usually 1066often, the L<Socket> module also exposes it, so leaving it out usually
988gains little. Why Socket exposes a C function that is in the core already 1067gains little. Why Socket exposes a C function that is in the core already

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines