… | |
… | |
40 | |
40 | |
41 | With F<uClibc> and F<upx> on x86, you can create a single 500kb binary |
41 | With F<uClibc> and F<upx> on x86, you can create a single 500kb binary |
42 | that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, |
42 | that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, |
43 | Coro and so on. Or any other choice of modules. |
43 | Coro and so on. Or any other choice of modules. |
44 | |
44 | |
|
|
45 | 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 L<http://staticperl.schmorp.de/>. |
|
|
48 | |
45 | The created files do not need write access to the file system (like PAR |
49 | The created files do not need write access to the file system (like PAR |
46 | does). In fact, since this script is in many ways similar to PAR::Packer, |
50 | does). In fact, since this script is in many ways similar to PAR::Packer, |
47 | here are the differences: |
51 | here are the differences: |
48 | |
52 | |
49 | =over 4 |
53 | =over 4 |
… | |
… | |
118 | often as necessary. |
122 | often as necessary. |
119 | |
123 | |
120 | =head1 THE F<STATICPERL> SCRIPT |
124 | =head1 THE F<STATICPERL> SCRIPT |
121 | |
125 | |
122 | This module installs a script called F<staticperl> into your perl |
126 | This module installs a script called F<staticperl> into your perl |
123 | binary directory. The script is fully self-contained, and can be used |
127 | binary directory. The script is fully self-contained, and can be |
124 | without perl (for example, in an uClibc chroot environment). In fact, |
128 | used without perl (for example, in an uClibc chroot environment). In |
125 | it can be extracted from the C<App::Staticperl> distribution tarball as |
129 | fact, it can be extracted from the C<App::Staticperl> distribution |
126 | F<bin/staticperl>, without any installation. |
130 | tarball as F<bin/staticperl>, without any installation. The |
|
|
131 | newest (possibly alpha) version can also be downloaded from |
|
|
132 | L<http://staticperl.schmorp.de/staticperl>. |
127 | |
133 | |
128 | F<staticperl> interprets the first argument as a command to execute, |
134 | F<staticperl> interprets the first argument as a command to execute, |
129 | optionally followed by any parameters. |
135 | optionally followed by any parameters. |
130 | |
136 | |
131 | There are two command categories: the "phase 1" commands which deal with |
137 | There are two command categories: the "phase 1" commands which deal with |
… | |
… | |
152 | |
158 | |
153 | To force recompilation or reinstallation, you need to run F<staticperl |
159 | To force recompilation or reinstallation, you need to run F<staticperl |
154 | distclean> first. |
160 | distclean> first. |
155 | |
161 | |
156 | =over 4 |
162 | =over 4 |
|
|
163 | |
|
|
164 | =item F<staticperl version> |
|
|
165 | |
|
|
166 | Prints 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 | |
160 | Runs only the download and unpack phase, unless this has already happened. |
170 | Runs only the download and unpack phase, unless this has already happened. |
161 | |
171 | |
… | |
… | |
311 | |
321 | |
312 | All this step does is potentially reduce the number of files already |
322 | All this step does is potentially reduce the number of files already |
313 | selected or found in phase 1. |
323 | selected or found in phase 1. |
314 | |
324 | |
315 | =item 3. find all modules (== F<.pm> files), gather their static archives |
325 | =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 |
326 | (F<.a>) and AutoLoader splitfiles (F<.ix> and F<.al> files), find any |
317 | extra libraries they need for linking (F<extralibs.ld>). |
327 | extra libraries they need for linking (F<extralibs.ld>) and optionally |
|
|
328 | evaluate any F<.packlist> files. |
318 | |
329 | |
319 | This step is required to link against XS extensions and also adds files |
330 | This step is required to link against XS extensions and also adds files |
320 | required for L<AutoLoader> to do it's job. |
331 | required for L<AutoLoader> to do it's job. |
321 | |
332 | |
322 | =back |
333 | =back |
… | |
… | |
453 | (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 |
454 | initialised. This can be used to modify C<@INC> or anything else before |
465 | initialised. This can be used to modify C<@INC> or anything else before |
455 | the perl interpreter executes scripts given on the command line (or via |
466 | the perl interpreter executes scripts given on the command line (or via |
456 | C<-e>). This works even in an embedded interpreter. |
467 | C<-e>). This works even in an embedded interpreter. |
457 | |
468 | |
|
|
469 | =item --usepacklist |
|
|
470 | |
|
|
471 | Read F<.packlist> files for each distribution that happens to match a |
|
|
472 | module name you specified. Sounds weird, and it is, so expect semantics to |
|
|
473 | change somehow in the future. |
|
|
474 | |
|
|
475 | The idea is that most CPAN distributions have a F<.pm> file that matches |
|
|
476 | the name of the distribution (which is rather reasonable after all). |
|
|
477 | |
|
|
478 | If this switch is enabled, then if any of the F<.pm> files that have been |
|
|
479 | selected match an install distribution, then all F<.pm>, F<.pl>, F<.al> |
|
|
480 | and F<.ix> files installed by this distribution are also included. |
|
|
481 | |
|
|
482 | For example, using this switch, when the L<URI> module is specified, then |
|
|
483 | all L<URI> submodules that have been installed via the CPAN distribution |
|
|
484 | are included as well, so you don't have to manually specify them. |
|
|
485 | |
458 | =item --incglob pattern |
486 | =item --incglob pattern |
459 | |
487 | |
460 | This goes through all library directories and tries to match any F<.pm> |
488 | This goes through all library directories and tries to match any F<.pm> |
461 | and F<.pl> files against the extended glob pattern (see below). If a file |
489 | and F<.pl> files against the extended glob pattern (see below). If a file |
462 | matches, it is added. This switch will automatically detect L<AutoLoader> |
490 | matches, it is added. This switch will automatically detect L<AutoLoader> |
… | |
… | |
589 | |
617 | |
590 | =back |
618 | =back |
591 | |
619 | |
592 | =head2 F<STATICPERL> CONFIGURATION AND HOOKS |
620 | =head2 F<STATICPERL> CONFIGURATION AND HOOKS |
593 | |
621 | |
594 | During (each) startup, F<staticperl> tries to source the following shell |
622 | During (each) startup, F<staticperl> tries to source some shell files to |
|
|
623 | allow you to fine-tune/override configuration settings. |
|
|
624 | |
|
|
625 | In them you can override shell variables, or define shell functions |
|
|
626 | ("hooks") to be called at specific phases during installation. For |
|
|
627 | example, you could define a C<postinstall> hook to install additional |
|
|
628 | modules from CPAN each time you start from scratch. |
|
|
629 | |
|
|
630 | If the env variable C<$STATICPERLRC> is set, then F<staticperl> will try |
|
|
631 | to source the file named with it only. Otherwise, it tries the following |
595 | files in order: |
632 | shell files in order: |
596 | |
633 | |
597 | /etc/staticperlrc |
634 | /etc/staticperlrc |
598 | ~/.staticperlrc |
635 | ~/.staticperlrc |
599 | $STATICPERL/rc |
636 | $STATICPERL/rc |
600 | |
|
|
601 | They can be used to override shell variables, or define functions to be |
|
|
602 | called at specific phases. |
|
|
603 | |
637 | |
604 | Note that the last file is erased during F<staticperl distclean>, so |
638 | Note that the last file is erased during F<staticperl distclean>, so |
605 | generally should not be used. |
639 | generally should not be used. |
606 | |
640 | |
607 | =head3 CONFIGURATION VARIABLES |
641 | =head3 CONFIGURATION VARIABLES |
… | |
… | |
669 | |
703 | |
670 | More commonly, you would either activate 64 bit integer support |
704 | More commonly, you would either activate 64 bit integer support |
671 | (C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to |
705 | (C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to |
672 | reduce filesize further. |
706 | reduce filesize further. |
673 | |
707 | |
674 | =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> |
675 | |
709 | |
676 | These flags are passed to perl's F<Configure> script, and are generally |
710 | These flags are passed to perl's F<Configure> script, and are generally |
677 | optimised for small size (at the cost of performance). Since they also |
711 | optimised for small size (at the cost of performance). Since they also |
678 | contain subtle workarounds around various build issues, changing these |
712 | contain subtle workarounds around various build issues, changing these |
679 | usually requires understanding their default values - best look at the top |
713 | usually requires understanding their default values - best look at the top |
… | |
… | |
682 | =back |
716 | =back |
683 | |
717 | |
684 | =head4 Variables you probably I<do not want> to override |
718 | =head4 Variables you probably I<do not want> to override |
685 | |
719 | |
686 | =over 4 |
720 | =over 4 |
|
|
721 | |
|
|
722 | =item C<MAKE> |
|
|
723 | |
|
|
724 | The make command to use - default is C<make>. |
687 | |
725 | |
688 | =item C<MKBUNDLE> |
726 | =item C<MKBUNDLE> |
689 | |
727 | |
690 | Where F<staticperl> writes the C<mkbundle> command to |
728 | Where F<staticperl> writes the C<mkbundle> command to |
691 | (default: F<$STATICPERL/mkbundle>). |
729 | (default: F<$STATICPERL/mkbundle>). |
… | |
… | |
953 | |
991 | |
954 | If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn |
992 | If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn |
955 | functions), you also need to include C<"AnyEvent/Util/idna.pl"> and |
993 | functions), you also need to include C<"AnyEvent/Util/idna.pl"> and |
956 | C<"AnyEvent/Util/uts46data.pl">. |
994 | C<"AnyEvent/Util/uts46data.pl">. |
957 | |
995 | |
|
|
996 | Or you can use C<--usepacklist> and specify C<-MAnyEvent> to include |
|
|
997 | everything. |
|
|
998 | |
958 | =item Carp |
999 | =item Carp |
959 | |
1000 | |
960 | Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of |
1001 | Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of |
961 | perl 5.12.2 (maybe earlier), this dependency no longer exists. |
1002 | perl 5.12.2 (maybe earlier), this dependency no longer exists. |
962 | |
1003 | |
… | |
… | |
966 | turn might need L<"Config_heavy.pl">. Including the latter gives you |
1007 | turn might need L<"Config_heavy.pl">. Including the latter gives you |
967 | both. |
1008 | both. |
968 | |
1009 | |
969 | =item Term::ReadLine::Perl |
1010 | =item Term::ReadLine::Perl |
970 | |
1011 | |
971 | Also needs L<Term::ReadLine::readline>. |
1012 | Also needs L<Term::ReadLine::readline>, or C<--usepacklist>. |
972 | |
1013 | |
973 | =item URI |
1014 | =item URI |
974 | |
1015 | |
975 | URI implements schemes as separate modules - the generic URL scheme is |
1016 | URI implements schemes as separate modules - the generic URL scheme is |
976 | implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If |
1017 | implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If |
977 | you need to use any of these schemes, you should include these manually. |
1018 | you need to use any of these schemes, you should include these manually, |
|
|
1019 | or use C<--usepacklist>. |
978 | |
1020 | |
979 | =back |
1021 | =back |
980 | |
1022 | |
981 | =head2 RECIPES |
1023 | =head2 RECIPES |
982 | |
1024 | |
… | |
… | |
1015 | PERL_CONFIGURE="$PERL_CONFIGURE -U$sym" |
1057 | PERL_CONFIGURE="$PERL_CONFIGURE -U$sym" |
1016 | done |
1058 | done |
1017 | } |
1059 | } |
1018 | |
1060 | |
1019 | This mostly gains space when linking staticaly, as the functions will |
1061 | This mostly gains space when linking staticaly, as the functions will |
1020 | liekly not be linked in. The gain for dynamically-linked binaries is |
1062 | likely not be linked in. The gain for dynamically-linked binaries is |
1021 | smaller. |
1063 | smaller. |
1022 | |
1064 | |
1023 | Also, this leaves C<gethostbyname> in - not only is it actually used |
1065 | Also, this leaves C<gethostbyname> in - not only is it actually used |
1024 | often, the L<Socket> module also exposes it, so leaving it out usually |
1066 | often, the L<Socket> module also exposes it, so leaving it out usually |
1025 | gains little. Why Socket exposes a C function that is in the core already |
1067 | gains little. Why Socket exposes a C function that is in the core already |