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.19 by root, Fri Dec 10 15:25:24 2010 UTC vs.
Revision 1.25 by root, Tue Dec 21 12:59:29 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
141 147
142The command 148The command
143 149
144 staticperl install 150 staticperl install
145 151
146Is normally all you need: It installs the perl interpreter in 152is normally all you need: It installs the perl interpreter in
147F<~/.staticperl/perl>. It downloads, configures, builds and installs the 153F<~/.staticperl/perl>. It downloads, configures, builds and installs the
148perl interpreter if required. 154perl interpreter if required.
149 155
150Most of the following commands simply run one or more steps of this 156Most of the following F<staticperl> subcommands simply run one or more
151sequence. 157steps of this sequence.
158
159If it fails, then most commonly because the compiler options I selected
160are not supported by your compiler - either edit the F<staticperl> script
161yourself or create F<~/.staticperl> shell script where your set working
162C<PERL_CCFLAGS> etc. variables.
152 163
153To force recompilation or reinstallation, you need to run F<staticperl 164To force recompilation or reinstallation, you need to run F<staticperl
154distclean> first. 165distclean> first.
155 166
156=over 4 167=over 4
168
169=item F<staticperl version>
170
171Prints some info about the version of the F<staticperl> script you are using.
157 172
158=item F<staticperl fetch> 173=item F<staticperl fetch>
159 174
160Runs only the download and unpack phase, unless this has already happened. 175Runs only the download and unpack phase, unless this has already happened.
161 176
199 214
200=item F<staticperl clean> 215=item F<staticperl clean>
201 216
202Deletes the perl source directory (and potentially cleans up other 217Deletes the perl source directory (and potentially cleans up other
203intermediate files). This can be used to clean up files only needed for 218intermediate files). This can be used to clean up files only needed for
204building perl, without removing the installed perl interpreter, or to 219building perl, without removing the installed perl interpreter.
205force a re-build from scratch.
206 220
207At the moment, it doesn't delete downloaded tarballs. 221At the moment, it doesn't delete downloaded tarballs.
222
223The exact semantics of this command will probably change.
208 224
209=item F<staticperl distclean> 225=item F<staticperl distclean>
210 226
211This wipes your complete F<~/.staticperl> directory. Be careful with this, 227This wipes your complete F<~/.staticperl> directory. Be careful with this,
212it nukes your perl download, perl sources, perl distribution and any 228it nukes your perl download, perl sources, perl distribution and any
262 -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI::http 278 -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI::http
263 279
264 # run it 280 # run it
265 ./app 281 ./app
266 282
283Here are the three phase 2 commands:
284
285=over 4
286
287=item F<staticperl mkbundle> args...
288
289The "default" bundle command - it interprets the given bundle options and
290writes out F<bundle.h>, F<bundle.c>, F<bundle.ccopts> and F<bundle.ldopts>
291files, useful for embedding.
292
293=item F<staticperl mkperl> args...
294
295Creates a bundle just like F<staticperl mkbundle> (in fact, it's the same
296as invoking F<staticperl mkbundle --perl> args...), but then compiles and
297links a new perl interpreter that embeds the created bundle, then deletes
298all intermediate files.
299
300=item F<staticperl mkapp> filename args...
301
302Does the same as F<staticperl mkbundle> (in fact, it's the same as
303invoking F<staticperl mkbundle --app> filename args...), but then compiles
304and links a new standalone application that simply initialises the perl
305interpreter.
306
307The difference to F<staticperl mkperl> is that the standalone application
308does not act like a perl interpreter would - in fact, by default it would
309just do nothing and exit immediately, so you should specify some code to
310be executed via the F<--boot> option.
311
312=back
313
267=head3 OPTION PROCESSING 314=head3 OPTION PROCESSING
268 315
269All options can be given as arguments on the command line (typically 316All options can be given as arguments on the command line (typically
270using long (e.g. C<--verbose>) or short option (e.g. C<-v>) style). Since 317using long (e.g. C<--verbose>) or short option (e.g. C<-v>) style). Since
271specifying a lot of modules can make the command line very cumbersome, 318specifying a lot of modules can make the command line very cumbersome, you
272you can put all long options into a "bundle specification file" (with or 319can put all long options into a "bundle specification file" (one option
273without C<--> prefix) and specify this bundle file instead. 320per line, with or without C<--> prefix) and specify this bundle file
321instead.
274 322
275For example, the command given earlier could also look like this: 323For example, the command given earlier could also look like this:
276 324
277 staticperl mkperl httpd.bundle 325 staticperl mkperl httpd.bundle
278 326
283 use AnyEvent::HTTPD 331 use AnyEvent::HTTPD
284 use URI::http 332 use URI::http
285 add eg/httpd httpd.pm 333 add eg/httpd httpd.pm
286 334
287All options that specify modules or files to be added are processed in the 335All 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> 336order given on the command line.
289options at the moment).
290 337
291=head3 PACKAGE SELECTION WORKFLOW 338=head3 PACKAGE SELECTION WORKFLOW
292 339
293F<staticperl mkbundle> has a number of options to control package 340F<staticperl mkbundle> has a number of options to control package
294selection. This section describes how they interact with each other. Also, 341selection. This section describes how they interact with each other. Also,
311 358
312All this step does is potentially reduce the number of files already 359All this step does is potentially reduce the number of files already
313selected or found in phase 1. 360selected or found in phase 1.
314 361
315=item 3. find all modules (== F<.pm> files), gather their static archives 362=item 3. find all modules (== F<.pm> files), gather their static archives
316(F<.a>) and AutoLoader splitfiles (F<.ix> and F<.al> files) and find any 363(F<.a>) and AutoLoader splitfiles (F<.ix> and F<.al> files), find any
317extra libraries they need for linking (F<extralibs.ld>). 364extra libraries they need for linking (F<extralibs.ld>) and optionally
365evaluate any F<.packlist> files.
318 366
319This step is required to link against XS extensions and also adds files 367This step is required to link against XS extensions and also adds files
320required for L<AutoLoader> to do it's job. 368required for L<AutoLoader> to do it's job.
321 369
322=back 370=back
453(using a C<require>) before anything else when the new perl is 501(using a C<require>) before anything else when the new perl is
454initialised. This can be used to modify C<@INC> or anything else before 502initialised. This can be used to modify C<@INC> or anything else before
455the perl interpreter executes scripts given on the command line (or via 503the perl interpreter executes scripts given on the command line (or via
456C<-e>). This works even in an embedded interpreter. 504C<-e>). This works even in an embedded interpreter.
457 505
506=item --usepacklist
507
508Read F<.packlist> files for each distribution that happens to match a
509module name you specified. Sounds weird, and it is, so expect semantics to
510change somehow in the future.
511
512The idea is that most CPAN distributions have a F<.pm> file that matches
513the name of the distribution (which is rather reasonable after all).
514
515If this switch is enabled, then if any of the F<.pm> files that have been
516selected match an install distribution, then all F<.pm>, F<.pl>, F<.al>
517and F<.ix> files installed by this distribution are also included.
518
519For example, using this switch, when the L<URI> module is specified, then
520all L<URI> submodules that have been installed via the CPAN distribution
521are included as well, so you don't have to manually specify them.
522
458=item --incglob pattern 523=item --incglob pattern
459 524
460This goes through all library directories and tries to match any F<.pm> 525This goes through all library directories and tries to match any F<.pm>
461and F<.pl> files against the extended glob pattern (see below). If a file 526and F<.pl> files against the extended glob pattern (see below). If a file
462matches, it is added. This switch will automatically detect L<AutoLoader> 527matches, it is added. This switch will automatically detect L<AutoLoader>
589 654
590=back 655=back
591 656
592=head2 F<STATICPERL> CONFIGURATION AND HOOKS 657=head2 F<STATICPERL> CONFIGURATION AND HOOKS
593 658
594During (each) startup, F<staticperl> tries to source the following shell 659During (each) startup, F<staticperl> tries to source some shell files to
660allow you to fine-tune/override configuration settings.
661
662In them you can override shell variables, or define shell functions
663("hooks") to be called at specific phases during installation. For
664example, you could define a C<postinstall> hook to install additional
665modules from CPAN each time you start from scratch.
666
667If the env variable C<$STATICPERLRC> is set, then F<staticperl> will try
668to source the file named with it only. Otherwise, it tries the following
595files in order: 669shell files in order:
596 670
597 /etc/staticperlrc 671 /etc/staticperlrc
598 ~/.staticperlrc 672 ~/.staticperlrc
599 $STATICPERL/rc 673 $STATICPERL/rc
600
601They can be used to override shell variables, or define functions to be
602called at specific phases.
603 674
604Note that the last file is erased during F<staticperl distclean>, so 675Note that the last file is erased during F<staticperl distclean>, so
605generally should not be used. 676generally should not be used.
606 677
607=head3 CONFIGURATION VARIABLES 678=head3 CONFIGURATION VARIABLES
669 740
670More commonly, you would either activate 64 bit integer support 741More commonly, you would either activate 64 bit integer support
671(C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to 742(C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to
672reduce filesize further. 743reduce filesize further.
673 744
674=item C<PERL_CPPFLAGS>, C<PERL_OPTIMIZE>, C<PERL_LDFLAGS>, C<PERL_LIBS> 745=item C<PERL_CC>, C<PERL_CCFLAGS>, C<PERL_OPTIMIZE>, C<PERL_LDFLAGS>, C<PERL_LIBS>
675 746
676These flags are passed to perl's F<Configure> script, and are generally 747These flags are passed to perl's F<Configure> script, and are generally
677optimised for small size (at the cost of performance). Since they also 748optimised for small size (at the cost of performance). Since they also
678contain subtle workarounds around various build issues, changing these 749contain subtle workarounds around various build issues, changing these
679usually requires understanding their default values - best look at the top 750usually requires understanding their default values - best look at
680of the F<staticperl> script for more info on these. 751the top of the F<staticperl> script for more info on these, and use a
752F<~/.staticperlrc> to override them.
753
754Most of the variables override (or modify) the corresponding F<Configure>
755variable, except C<PERL_CCFLAGS>, which gets appended.
681 756
682=back 757=back
683 758
684=head4 Variables you probably I<do not want> to override 759=head4 Variables you probably I<do not want> to override
685 760
686=over 4 761=over 4
762
763=item C<MAKE>
764
765The make command to use - default is C<make>.
687 766
688=item C<MKBUNDLE> 767=item C<MKBUNDLE>
689 768
690Where F<staticperl> writes the C<mkbundle> command to 769Where F<staticperl> writes the C<mkbundle> command to
691(default: F<$STATICPERL/mkbundle>). 770(default: F<$STATICPERL/mkbundle>).
953 1032
954If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn 1033If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn
955functions), you also need to include C<"AnyEvent/Util/idna.pl"> and 1034functions), you also need to include C<"AnyEvent/Util/idna.pl"> and
956C<"AnyEvent/Util/uts46data.pl">. 1035C<"AnyEvent/Util/uts46data.pl">.
957 1036
1037Or you can use C<--usepacklist> and specify C<-MAnyEvent> to include
1038everything.
1039
958=item Carp 1040=item Carp
959 1041
960Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of 1042Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of
961perl 5.12.2 (maybe earlier), this dependency no longer exists. 1043perl 5.12.2 (maybe earlier), this dependency no longer exists.
962 1044
966turn might need L<"Config_heavy.pl">. Including the latter gives you 1048turn might need L<"Config_heavy.pl">. Including the latter gives you
967both. 1049both.
968 1050
969=item Term::ReadLine::Perl 1051=item Term::ReadLine::Perl
970 1052
971Also needs L<Term::ReadLine::readline>. 1053Also needs L<Term::ReadLine::readline>, or C<--usepacklist>.
972 1054
973=item URI 1055=item URI
974 1056
975URI implements schemes as separate modules - the generic URL scheme is 1057URI implements schemes as separate modules - the generic URL scheme is
976implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If 1058implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If
977you need to use any of these schemes, you should include these manually. 1059you need to use any of these schemes, you should include these manually,
1060or use C<--usepacklist>.
978 1061
979=back 1062=back
980 1063
981=head2 RECIPES 1064=head2 RECIPES
982 1065
1015 PERL_CONFIGURE="$PERL_CONFIGURE -U$sym" 1098 PERL_CONFIGURE="$PERL_CONFIGURE -U$sym"
1016 done 1099 done
1017 } 1100 }
1018 1101
1019This mostly gains space when linking staticaly, as the functions will 1102This mostly gains space when linking staticaly, as the functions will
1020liekly not be linked in. The gain for dynamically-linked binaries is 1103likely not be linked in. The gain for dynamically-linked binaries is
1021smaller. 1104smaller.
1022 1105
1023Also, this leaves C<gethostbyname> in - not only is it actually used 1106Also, this leaves C<gethostbyname> in - not only is it actually used
1024often, the L<Socket> module also exposes it, so leaving it out usually 1107often, the L<Socket> module also exposes it, so leaving it out usually
1025gains little. Why Socket exposes a C function that is in the core already 1108gains little. Why Socket exposes a C function that is in the core already

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines