… | |
… | |
14 | staticperl cpan # invoke CPAN shell |
14 | staticperl cpan # invoke CPAN shell |
15 | staticperl instmod path... # install unpacked modules |
15 | staticperl instmod path... # install unpacked modules |
16 | staticperl instcpan modulename... # install modules from CPAN |
16 | staticperl instcpan modulename... # install modules from CPAN |
17 | staticperl mkbundle <bundle-args...> # see documentation |
17 | staticperl mkbundle <bundle-args...> # see documentation |
18 | staticperl mkperl <bundle-args...> # see documentation |
18 | staticperl mkperl <bundle-args...> # see documentation |
|
|
19 | staticperl mkapp appname <bundle-args...> # see documentation |
19 | |
20 | |
20 | Typical Examples: |
21 | Typical Examples: |
21 | |
22 | |
22 | staticperl install # fetch, configure, build and install perl |
23 | staticperl install # fetch, configure, build and install perl |
23 | staticperl cpan # run interactive cpan shell |
24 | staticperl cpan # run interactive cpan shell |
24 | staticperl mkperl -M '"Config_heavy.pl"' # build a perl that supports -V |
25 | staticperl mkperl -M '"Config_heavy.pl"' # build a perl that supports -V |
25 | staticperl mkperl -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI -MURI::http |
26 | staticperl mkperl -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI -MURI::http |
26 | # build a perl with the above modules linked in |
27 | # build a perl with the above modules linked in |
|
|
28 | staticperl mkapp myapp --boot mainprog mymodules |
|
|
29 | # build a binary "myapp" from mainprog and mymodules |
27 | |
30 | |
28 | =head1 DESCRIPTION |
31 | =head1 DESCRIPTION |
29 | |
32 | |
30 | This script helps you creating single-file perl interpreters, or embedding |
33 | This script helps you to create single-file perl interpreters |
31 | a perl interpreter in your applications. Single-file means that it is |
34 | or applications, or embedding a perl interpreter in your |
32 | fully self-contained - no separate shared objects, no autoload fragments, |
35 | applications. Single-file means that it is fully self-contained - no |
33 | no .pm or .pl files are needed. And when linking statically, you can |
36 | separate shared objects, no autoload fragments, no .pm or .pl files are |
34 | create (or embed) a single file that contains perl interpreter, libc, all |
37 | needed. And when linking statically, you can create (or embed) a single |
35 | the modules you need and all the libraries you need. |
38 | file that contains perl interpreter, libc, all the modules you need, all |
|
|
39 | the libraries you need and of course your actual program. |
36 | |
40 | |
37 | 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 |
38 | 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, |
39 | Coro and so on. Or any other choice of modules. |
43 | Coro and so on. Or any other choice of modules. |
40 | |
44 | |
… | |
… | |
80 | |
84 | |
81 | Maintaining your own custom perl build can be a pain in the ass, and while |
85 | Maintaining your own custom perl build can be a pain in the ass, and while |
82 | F<staticperl> tries to make this easy, it still requires a custom perl |
86 | F<staticperl> tries to make this easy, it still requires a custom perl |
83 | build and possibly fiddling with some modules. PAR is likely to produce |
87 | build and possibly fiddling with some modules. PAR is likely to produce |
84 | results faster. |
88 | results faster. |
|
|
89 | |
|
|
90 | Ok, PAR never has worked for me out of the box, and for some people, |
|
|
91 | F<staticperl> does work out of the box, as they don't count "fiddling with |
|
|
92 | module use lists" against it, but nevertheless, F<staticperl> is certainly |
|
|
93 | a bit more difficult to use. |
85 | |
94 | |
86 | =back |
95 | =back |
87 | |
96 | |
88 | =head1 HOW DOES IT WORK? |
97 | =head1 HOW DOES IT WORK? |
89 | |
98 | |
… | |
… | |
239 | (required by L<AnyEvent::HTTPD>) implements various URI schemes as extra |
248 | (required by L<AnyEvent::HTTPD>) implements various URI schemes as extra |
240 | modules - since L<AnyEvent::HTTPD> only needs C<http> URIs, we only need |
249 | modules - since L<AnyEvent::HTTPD> only needs C<http> URIs, we only need |
241 | to include that module. I found out about these dependencies by carefully |
250 | to include that module. I found out about these dependencies by carefully |
242 | watching any error messages about missing modules... |
251 | watching any error messages about missing modules... |
243 | |
252 | |
|
|
253 | Instead of building a new perl binary, you can also build a standalone |
|
|
254 | application: |
|
|
255 | |
|
|
256 | # build the app |
|
|
257 | staticperl mkapp app --boot eg/httpd \ |
|
|
258 | -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI::http |
|
|
259 | |
|
|
260 | # run it |
|
|
261 | ./app |
|
|
262 | |
244 | =head3 OPTION PROCESSING |
263 | =head3 OPTION PROCESSING |
245 | |
264 | |
246 | All options can be given as arguments on the command line (typically |
265 | All options can be given as arguments on the command line (typically |
247 | using long (e.g. C<--verbose>) or short option (e.g. C<-v>) style). Since |
266 | using long (e.g. C<--verbose>) or short option (e.g. C<-v>) style). Since |
248 | specifying a lot of modules can make the command line very cumbersome, |
267 | specifying a lot of modules can make the command line very cumbersome, |
… | |
… | |
307 | C<mkperl> command (instead of C<mkbundle>): |
326 | C<mkperl> command (instead of C<mkbundle>): |
308 | |
327 | |
309 | # build a new ./perl with only common::sense in it - very small :) |
328 | # build a new ./perl with only common::sense in it - very small :) |
310 | staticperl mkperl -Mcommon::sense |
329 | staticperl mkperl -Mcommon::sense |
311 | |
330 | |
|
|
331 | =item --app name |
|
|
332 | |
|
|
333 | After writing out the bundle files, try to link a new standalone |
|
|
334 | program. It will be called C<name>, and the bundle files get removed after |
|
|
335 | linking it. |
|
|
336 | |
|
|
337 | The difference to the (mutually exclusive) C<--perl> option is that the |
|
|
338 | binary created by this option will not try to act as a perl interpreter - |
|
|
339 | instead it will simply initialise the perl interpreter, clean it up and |
|
|
340 | exit. |
|
|
341 | |
|
|
342 | This switch is automatically used when F<staticperl> is invoked with the |
|
|
343 | C<mkapp> command (instead of C<mkbundle>): |
|
|
344 | |
|
|
345 | To let it do something useful you I<must> add some boot code, e.g. with |
|
|
346 | the C<--boot> option. |
|
|
347 | |
|
|
348 | Example: create a standalone perl binary that will execute F<appfile> when |
|
|
349 | it is started. |
|
|
350 | |
|
|
351 | staticperl mkbundle --app myexe --boot appfile |
|
|
352 | |
312 | =item --use module | -Mmodule |
353 | =item --use module | -Mmodule |
313 | |
354 | |
314 | Include the named module and all direct dependencies. This is done by |
355 | Include the named module and all direct dependencies. This is done by |
315 | C<require>'ing the module in a subprocess and tracing which other modules |
356 | C<require>'ing the module in a subprocess and tracing which other modules |
316 | and files it actually loads. If the module uses L<AutoLoader>, then all |
357 | and files it actually loads. If the module uses L<AutoLoader>, then all |
… | |
… | |
418 | Any other argument is interpreted as a bundle specification file, which |
459 | Any other argument is interpreted as a bundle specification file, which |
419 | supports most long options (without extra quoting), one option per line. |
460 | supports most long options (without extra quoting), one option per line. |
420 | |
461 | |
421 | =back |
462 | =back |
422 | |
463 | |
423 | =head2 F<STATCPERL> CONFIGURATION AND HOOKS |
464 | =head2 F<STATICPERL> CONFIGURATION AND HOOKS |
424 | |
465 | |
425 | During (each) startup, F<staticperl> tries to source the following shell |
466 | During (each) startup, F<staticperl> tries to source the following shell |
426 | files in order: |
467 | files in order: |
427 | |
468 | |
428 | /etc/staticperlrc |
469 | /etc/staticperlrc |