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