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

Comparing cvsroot/App-Staticperl/staticperl.pod (file contents):
Revision 1.17 by root, Thu Dec 9 08:55:52 2010 UTC vs.
Revision 1.18 by root, Fri Dec 10 02:35:54 2010 UTC

111Afterwards, you create a list of files and modules you want to include, 111Afterwards, you create a list of files and modules you want to include,
112and then either build a new perl binary (that acts just like a normal perl 112and then either build a new perl binary (that acts just like a normal perl
113except everything is compiled in), or you create bundle files (basically C 113except everything is compiled in), or you create bundle files (basically C
114sources you can use to embed all files into your project). 114sources you can use to embed all files into your project).
115 115
116This step is very fast (a few seconds if PPI is not used for stripping, 116This step is very fast (a few seconds if PPI is not used for stripping, or
117more seconds otherwise, as PPI is very slow), and can be tweaked and 117the stripped files are in the cache), and can be tweaked and repeated as
118repeated as often as necessary. 118often as necessary.
119 119
120=head1 THE F<STATICPERL> SCRIPT 120=head1 THE F<STATICPERL> SCRIPT
121 121
122This module installs a script called F<staticperl> into your perl 122This module installs a script called F<staticperl> into your perl
123binary directory. The script is fully self-contained, and can be used 123binary directory. The script is fully self-contained, and can be used
307 307
308The default is C<pod>, which uses the L<Pod::Strip> module to remove all 308The default is C<pod>, which uses the L<Pod::Strip> module to remove all
309pod documentation, which is very fast and reduces file size a lot. 309pod documentation, which is very fast and reduces file size a lot.
310 310
311The C<ppi> method uses L<PPI> to parse and condense the perl sources. This 311The C<ppi> method uses L<PPI> to parse and condense the perl sources. This
312saves a lot more than just L<Pod::Strip>, and is generally safer, but 312saves a lot more than just L<Pod::Strip>, and is generally safer,
313is also a lot slower, so is best used for production builds. Note that 313but is also a lot slower (some files take almost a minute to strip -
314this method doesn't optimise for raw file size, but for best compression 314F<staticperl> maintains a cache of stripped files to speed up subsequent
315(that means that the uncompressed file size is a bit larger, but the files 315runs for this reason). Note that this method doesn't optimise for raw file
316compress better, e.g. with F<upx>). 316size, but for best compression (that means that the uncompressed file size
317is a bit larger, but the files compress better, e.g. with F<upx>).
317 318
318Last not least, if you need accurate line numbers in error messages, 319Last not least, if you need accurate line numbers in error messages,
319or in the unlikely case where C<pod> is too slow, or some module gets 320or in the unlikely case where C<pod> is too slow, or some module gets
320mistreated, you can specify C<none> to not mangle included perl sources in 321mistreated, you can specify C<none> to not mangle included perl sources in
321any way. 322any way.
415(using a C<require>) before anything else when the new perl is 416(using a C<require>) before anything else when the new perl is
416initialised. This can be used to modify C<@INC> or anything else before 417initialised. This can be used to modify C<@INC> or anything else before
417the perl interpreter executes scripts given on the command line (or via 418the perl interpreter executes scripts given on the command line (or via
418C<-e>). This works even in an embedded interpreter. 419C<-e>). This works even in an embedded interpreter.
419 420
420=item --add "file" | --add "file alias" 421=item --incglob pattern
422
423This 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
425matches, it is added. This switch will automatically detect L<AutoLoader>
426files and the required link libraries for XS modules, but it will I<not>
427scan the file for dependencies (at the moment).
428
429This is mainly useful to include "everything":
430
431 --incglob '*'
432
433Or to include perl libraries, or trees of those, such as the unicode
434database files needed by many other modules:
435
436 --incglob '/unicore/**.pl'
437
438=item --add file | --add "file alias"
421 439
422Adds the given (perl) file into the bundle (and optionally call it 440Adds the given (perl) file into the bundle (and optionally call it
423"alias"). This is useful to include any custom files into the bundle. 441"alias"). This is useful to include any custom files into the bundle.
424 442
425Example: embed the file F<httpd> as F<httpd.pm> when creating the bundle. 443Example: embed the file F<httpd> as F<httpd.pm> when creating the bundle.
431 # specification file 449 # specification file
432 add file1 myfiles/file1 450 add file1 myfiles/file1
433 add file2 myfiles/file2 451 add file2 myfiles/file2
434 add file3 myfiles/file3 452 add file3 myfiles/file3
435 453
436=item --binadd "file" | --add "file alias" 454=item --binadd file | --add "file alias"
437 455
438Just like C<--add>, except that it treats the file as binary and adds it 456Just like C<--add>, except that it treats the file as binary and adds it
439without any processing. 457without any processing.
440 458
441You should probably add a C</> prefix to avoid clashing with embedded 459You should probably add a C</> prefix to avoid clashing with embedded
442perl files (whose paths do not start with C</>), and/or use a special 460perl files (whose paths do not start with C</>), and/or use a special
443directory, such as C</res/name>. 461directory, such as C</res/name>.
444 462
445You can later get a copy of these files by calling C<staticperl::find 463You can later get a copy of these files by calling C<staticperl::find
446"alias">. 464"alias">.
465
466=item --include pattern | -i pattern | --exclude pattern | -x pattern
467
468These two options define an include/exclude filter that is used after all
469files selected by the other options have been found. Each include/exclude
470is applied to all files found so far - an include makes sure that the
471given files will be part of the resulting file set, an exclude will
472exclude files. The patterns are "extended glob patterns" (see below).
473
474For example, to include everything, except C<Devel> modules, but still
475include F<Devel::PPPort>, you could use this:
476
477 --incglob '*' -i '/Devel/PPPort.pm' -x '/Devel/**'
447 478
448=item --static 479=item --static
449 480
450When C<--perl> is also given, link statically instead of dynamically. The 481When C<--perl> is also given, link statically instead of dynamically. The
451default is to link the new perl interpreter fully dynamic (that means all 482default is to link the new perl interpreter fully dynamic (that means all
456systems based on GNU libc don't really support it in a usable fashion 487systems based on GNU libc don't really support it in a usable fashion
457either. Try uClibc if you want to create fully statically linked 488either. Try uClibc if you want to create fully statically linked
458executables, or try the C<--staticlibs> option to link only some libraries 489executables, or try the C<--staticlibs> option to link only some libraries
459statically. 490statically.
460 491
492=item --staticlib libname
493
494When not linking fully statically, this option allows you to link specific
495libraries statically. What it does is simply replace all occurances of
496C<-llibname> with the GCC-specific C<-Wl,-Bstatic -llibname -Wl,-Bdynamic>
497option.
498
499This will have no effect unless the library is actually linked against,
500specifically, C<--staticlib> will not link against the named library
501unless it would be linked against anyway.
502
503Example: link libcrypt statically into the binary.
504
505 staticperl mkperl -MIO::AIO --staticlib crypt
506
507 # ldopts might nwo contain:
508 # -lm -Wl,-Bstatic -lcrypt -Wl,-Bdynamic -lpthread
509
461=item any other argument 510=item any other argument
462 511
463Any other argument is interpreted as a bundle specification file, which 512Any other argument is interpreted as a bundle specification file, which
464supports most long options (without extra quoting), one option per line. 513supports most long options (without extra quoting), one option per line.
514
515=back
516
517=head3 EXTENDED GLOB PATTERNS
518
519Some options of F<staticperl mkbundle> expect an I<extended glob
520pattern>. This is neither a normal shell glob nor a regex, but something
521in between. The idea has been copied from rsync, and there are the current
522matching rules:
523
524=over 4
525
526=item Patterns starting with F</> will be a anchored at the root of the library tree.
527
528That is, F</unicore> will match the F<unicore> directory in C<@INC>, but
529nothing inside, and neither any other file or directory called F<unicore>
530anywhere else in the hierarchy.
531
532=item Patterns not starting with F</> will be anchored at the end of the path.
533
534That is, F<idna.pl> will match any file called F<idna.pl> anywhere in the
535hierarchy, but not any directories of the same name.
536
537=item A F<*> matches any single component.
538
539That is, F</unicore/*.pl> would match all F<.pl> files directly inside
540C</unicore>, not any deeper level F<.pl> files. Or in other words, F<*>
541will not match slashes.
542
543=item A F<**> matches anything.
544
545That is, F</unicore/**.pl> would match all F<.pl> files under F</unicore>,
546no matter how deeply nested they are inside subdirectories.
547
548=item A F<?> matches a single character within a component.
549
550That is, F</Encode/??.pm> matches F</Encode/JP.pm>, but not the
551hypothetical F</Encode/J/.pm>, as F<?> does not match F</>.
465 552
466=back 553=back
467 554
468=head2 F<STATICPERL> CONFIGURATION AND HOOKS 555=head2 F<STATICPERL> CONFIGURATION AND HOOKS
469 556
801 888
802=item utf8 889=item utf8
803 890
804Some functionality in the utf8 module, such as swash handling (used 891Some functionality in the utf8 module, such as swash handling (used
805for unicode character ranges in regexes) is implemented in the 892for unicode character ranges in regexes) is implemented in the
806C<"utf8_heavy.pl"> library. 893C<"utf8_heavy.pl"> library:
894
895 -M'"utf8_heavy.pl"'
807 896
808Many Unicode properties in turn are defined in separate modules, 897Many Unicode properties in turn are defined in separate modules,
809such as C<"unicore/Heavy.pl"> and more specific data tables such as 898such as C<"unicore/Heavy.pl"> and more specific data tables such as
810C<"unicore/To/Digit.pl"> or C<"unicore/lib/Perl/Word.pl">. These 899C<"unicore/To/Digit.pl"> or C<"unicore/lib/Perl/Word.pl">. These tables
811tables are big (7MB uncompressed), so including them on demand by your 900are big (7MB uncompressed, although F<staticperl> contains special
901handling for those files), so including them on demand by your application
812applciation only might pay off. 902only might pay off.
813 903
814=item Carp 904To simply include the whole unicode database, use:
815 905
816Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of 906 --incglob '/unicore/*.pl'
817perl 5.12.2 (maybe earlier), this dependency no longer exists.
818
819=item Config
820
821The F<perl -V> switch (as well as many modules) needs L<Config>, which in
822turn might need L<"Config_heavy.pl">. Including the latter gives you
823both.
824 907
825=item AnyEvent 908=item AnyEvent
826 909
827AnyEvent needs a backend implementation that it will load in a delayed 910AnyEvent needs a backend implementation that it will load in a delayed
828fashion. The L<AnyEvent::Impl::Perl> backend is the default choice 911fashion. The L<AnyEvent::Impl::Perl> backend is the default choice
833 916
834If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn 917If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn
835functions), you also need to include C<"AnyEvent/Util/idna.pl"> and 918functions), you also need to include C<"AnyEvent/Util/idna.pl"> and
836C<"AnyEvent/Util/uts46data.pl">. 919C<"AnyEvent/Util/uts46data.pl">.
837 920
921=item Carp
922
923Carp 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.
925
926=item Config
927
928The F<perl -V> switch (as well as many modules) needs L<Config>, which in
929turn might need L<"Config_heavy.pl">. Including the latter gives you
930both.
931
932=item Term::ReadLine::Perl
933
934Also needs L<Term::ReadLine::readline>.
935
838=item URI 936=item URI
839 937
840URI implements schemes as separate modules - the generic URL scheme is 938URI implements schemes as separate modules - the generic URL scheme is
841implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If 939implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If
842you need to use any of these schemes, you should include these manually. 940you need to use any of these schemes, you should include these manually.
844=back 942=back
845 943
846=head2 RECIPES 944=head2 RECIPES
847 945
848=over 4 946=over 4
947
948=item Linking everything in
949
950To link just about everything installed in the perl library into a new
951perl, try this:
952
953 staticperl mkperl --strip ppi --incglob '*'
849 954
850=item Getting rid of netdb function 955=item Getting rid of netdb function
851 956
852The perl core has lots of netdb functions (C<getnetbyname>, C<getgrent> 957The perl core has lots of netdb functions (C<getnetbyname>, C<getgrent>
853and so on) that few applications use. You can avoid compiling them in by 958and so on) that few applications use. You can avoid compiling them in by

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines