--- App-Staticperl/staticperl.pod 2010/12/11 23:28:22 1.21 +++ App-Staticperl/staticperl.pod 2019/03/21 16:41:36 1.64 @@ -1,6 +1,6 @@ =head1 NAME -staticperl - perl, libc, 100 modules, all in one 500kb file +staticperl - perl, libc, 100 modules, all in one standalone 500kb file =head1 SYNOPSIS @@ -11,8 +11,9 @@ staticperl install # build and then install perl staticperl clean # clean most intermediate files (restart at configure) staticperl distclean # delete everything installed by this script + staticperl perl ... # invoke the perlinterpreter staticperl cpan # invoke CPAN shell - staticperl instmod path... # install unpacked modules + staticperl instsrc path... # install unpacked modules staticperl instcpan modulename... # install modules from CPAN staticperl mkbundle # see documentation staticperl mkperl # see documentation @@ -22,7 +23,7 @@ staticperl install # fetch, configure, build and install perl staticperl cpan # run interactive cpan shell - staticperl mkperl -M '"Config_heavy.pl"' # build a perl that supports -V + staticperl mkperl -MConfig_heavy.pl # build a perl that supports -V staticperl mkperl -MAnyEvent::Impl::Perl -MAnyEvent::HTTPD -MURI -MURI::http # build a perl with the above modules linked in staticperl mkapp myapp --boot mainprog mymodules @@ -40,7 +41,7 @@ With F and F on x86, you can create a single 500kb binary that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, -Coro and so on. Or any other choice of modules. +Coro and so on. Or any other choice of modules (and some other size :). To see how this turns out, you can try out smallperl and bigperl, two pre-built static and compressed perl binaries with many and even more @@ -85,7 +86,7 @@ This means the modules to include often need to be tweaked manually. All this does not preclude more permissive modes to be implemented in -the future, but right now, you have to resolve state hidden dependencies +the future, but right now, you have to resolve hidden dependencies manually. =item * PAR works out of the box, F does not. @@ -141,7 +142,7 @@ =head2 PHASE 1 COMMANDS: INSTALLING PERL The most important command is F, which does basically -everything. The default is to download and install perl 5.12.2 and a few +everything. The default is to download and install perl 5.12.3 and a few modules required by F itself, but all this can (and should) be changed - see L, below. @@ -149,12 +150,17 @@ staticperl install -Is normally all you need: It installs the perl interpreter in +is normally all you need: It installs the perl interpreter in F<~/.staticperl/perl>. It downloads, configures, builds and installs the perl interpreter if required. -Most of the following commands simply run one or more steps of this -sequence. +Most of the following F subcommands simply run one or more +steps of this sequence. + +If it fails, then most commonly because the compiler options I selected +are not supported by your compiler - either edit the F script +yourself or create F<~/.staticperl> shell script where your set working +C etc. variables. To force recompilation or reinstallation, you need to run F first. @@ -183,12 +189,24 @@ Wipes the perl installation directory (usually F<~/.staticperl/perl>) and installs the perl distribution, potentially after building it first. +=item F [args...] + +Invokes the compiled perl interpreter with the given args. Basically the +same as starting perl directly (usually via F<~/.staticperl/bin/perl>), +but beats typing the path sometimes. + +Example: check that the Gtk2 module is installed and loadable. + + staticperl perl -MGtk2 -e0 + =item F [args...] Starts an interactive CPAN shell that you can use to install further modules. Installs the perl first if necessary, but apart from that, no magic is involved: you could just as well run it manually via -F<~/.staticperl/perl/bin/cpan>. +F<~/.staticperl/perl/bin/cpan>, except that F additionally +sets the environment variable C<$PERL> to the path of the perl +interpreter, which is handy in subshells. Any additional arguments are simply passed to the F command. @@ -211,11 +229,12 @@ Deletes the perl source directory (and potentially cleans up other intermediate files). This can be used to clean up files only needed for -building perl, without removing the installed perl interpreter, or to -force a re-build from scratch. +building perl, without removing the installed perl interpreter. At the moment, it doesn't delete downloaded tarballs. +The exact semantics of this command will probably change. + =item F This wipes your complete F<~/.staticperl> directory. Be careful with this, @@ -248,7 +267,7 @@ staticperl instcpan AnyEvent::HTTPD # now build the perl - staticperl mkperl -M'"Config_heavy.pl"' -MAnyEvent::Impl::Perl \ + staticperl mkperl -MConfig_heavy.pl -MAnyEvent::Impl::Perl \ -MAnyEvent::HTTPD -MURI::http \ --add 'eg/httpd httpd.pm' @@ -274,20 +293,54 @@ # run it ./app +Here are the three phase 2 commands: + +=over 4 + +=item F args... + +The "default" bundle command - it interprets the given bundle options and +writes out F, F, F and F +files, useful for embedding. + +=item F args... + +Creates a bundle just like F (in fact, it's the same +as invoking F args...), but then compiles and +links a new perl interpreter that embeds the created bundle, then deletes +all intermediate files. + +=item F filename args... + +Does the same as F (in fact, it's the same as +invoking F filename args...), but then compiles +and links a new standalone application that simply initialises the perl +interpreter. + +The difference to F is that the standalone application +does not act like a perl interpreter would - in fact, by default it would +just do nothing and exit immediately, so you should specify some code to +be executed via the F<--boot> option. + +=back + =head3 OPTION PROCESSING All options can be given as arguments on the command line (typically using long (e.g. C<--verbose>) or short option (e.g. C<-v>) style). Since -specifying a lot of modules can make the command line very cumbersome, -you can put all long options into a "bundle specification file" (with or -without C<--> prefix) and specify this bundle file instead. +specifying a lot of options can make the command line very long and +unwieldy, you can put all long options into a "bundle specification file" +(one option per line, with or without C<--> prefix) and specify this +bundle file instead. -For example, the command given earlier could also look like this: +For example, the command given earlier to link a new F could also +look like this: staticperl mkperl httpd.bundle -And all options could be in F: - +With all options stored in the F file (one option per line, +everything after the option is an argument): + use "Config_heavy.pl" use AnyEvent::Impl::Perl use AnyEvent::HTTPD @@ -295,155 +348,127 @@ add eg/httpd httpd.pm All options that specify modules or files to be added are processed in the -order given on the command line (that affects the C<--use> and C<--eval> -options at the moment). +order given on the command line. -=head3 PACKAGE SELECTION WORKFLOW +=head3 BUNDLE CREATION WORKFLOW / STATICPERL MKBUNDLE OPTIONS -F has a number of options to control package -selection. This section describes how they interact with each other. Also, -since I am still a newbie w.r.t. these issues, maybe future versions of -F will change this, so watch out :) - -The idiom "in order" means "in order that they are specified on the -commandline". If you use a bundle specification file, then the options -will be processed as if they were given in place of the bundle file name. +F works by first assembling a list of candidate +files and modules to include, then filtering them by include/exclude +patterns. The remaining modules (together with their direct dependencies, +such as link libraries and L files) are then converted into +bundle files suitable for embedding. F can then +optionally build a new perl interpreter or a standalone application. =over 4 -=item 1. apply all C<--use>, C<--eval>, C<--add>, C<--addbin> and -C<--incglob> options, in order. - -In addition, C<--use> and C<--eval> dependencies will be added when the -options are processed. +=item Step 0: Generic argument processing. -=item 2. apply all C<--include> and C<--exclude> options, in order. - -All this step does is potentially reduce the number of files already -selected or found in phase 1. - -=item 3. find all modules (== F<.pm> files), gather their static archives -(F<.a>) and AutoLoader splitfiles (F<.ix> and F<.al> files), find any -extra libraries they need for linking (F) and optionally -evaluate any F<.packlist> files. - -This step is required to link against XS extensions and also adds files -required for L to do it's job. - -=back - -After this, all the files selected for bundling will be read and processed -(stripped), the bundle files will be written, and optionally a new F -or application binary will be linked. - -=head3 MKBUNDLE OPTIONS +The following options influence F itself. =over 4 -=item --verbose | -v +=item C<--verbose> | C<-v> Increases the verbosity level by one (the default is C<1>). -=item --quiet | -q +=item C<--quiet> | C<-q> Decreases the verbosity level by one. -=item --strip none|pod|ppi +=item any other argument -Specify the stripping method applied to reduce the file of the perl -sources included. +Any other argument is interpreted as a bundle specification file, which +supports all options (without extra quoting), one option per line, in the +format C