--- App-Staticperl/staticperl.pod 2010/12/10 15:25:24 1.19
+++ App-Staticperl/staticperl.pod 2011/02/24 07:01:46 1.37
@@ -22,7 +22,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
@@ -42,6 +42,10 @@
that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO,
Coro and so on. Or any other choice of modules.
+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
+modules: just follow the links at L .
+
The created files do not need write access to the file system (like PAR
does). In fact, since this script is in many ways similar to PAR::Packer,
here are the differences:
@@ -120,10 +124,12 @@
=head1 THE F SCRIPT
This module installs a script called F into your perl
-binary directory. The script is fully self-contained, and can be used
-without perl (for example, in an uClibc chroot environment). In fact,
-it can be extracted from the C distribution tarball as
-F, without any installation.
+binary directory. The script is fully self-contained, and can be
+used without perl (for example, in an uClibc chroot environment). In
+fact, it can be extracted from the C distribution
+tarball as F, without any installation. The
+newest (possibly alpha) version can also be downloaded from
+L.
F interprets the first argument as a command to execute,
optionally followed by any parameters.
@@ -135,7 +141,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.
@@ -143,18 +149,27 @@
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.
=over 4
+=item F
+
+Prints some info about the version of the F script you are using.
+
=item F
Runs only the download and unpack phase, unless this has already happened.
@@ -201,11 +216,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,
@@ -238,7 +254,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'
@@ -264,20 +280,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
@@ -285,154 +335,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).
-
-=head3 PACKAGE SELECTION WORKFLOW
+order given on the command line.
-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 :)
+=head3 BUNDLE CREATION WORKFLOW / STATICPELR MKBUNDLE OPTIONS
-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 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) and find any
-extra libraries they need for linking (F).
+=item Step 0: Generic argument processing.
-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 or C . They will effectively be expanded
+and processed as if they were directly written on the command line, in
+place of the file name.
-The default is C, which uses the L module to remove all
-pod documentation, which is very fast and reduces file size a lot.
+=back
-The C method uses L to parse and condense the perl sources. This
-saves a lot more than just L, and is generally safer,
-but is also a lot slower (some files take almost a minute to strip -
-F maintains a cache of stripped files to speed up subsequent
-runs for this reason). Note that this method doesn't optimise for raw file
-size, but for best compression (that means that the uncompressed file size
-is a bit larger, but the files compress better, e.g. with F).
+=item Step 1: gather candidate files and modules
-Last not least, if you need accurate line numbers in error messages,
-or in the unlikely case where C is too slow, or some module gets
-mistreated, you can specify C to not mangle included perl sources in
-any way.
+In this step, modules, perl libraries (F<.pl> files) and other files are
+selected for inclusion in the bundle. The relevant options are executed
+in order (this makes a difference mostly for C<--eval>, which can rely on
+earlier C<--use> options to have been executed).
-=item --perl
+=over 4
-After writing out the bundle files, try to link a new perl interpreter. It
-will be called F and will be left in the current working
-directory. The bundle files will be removed.
+=item C<--use> F | C<-M>F
-This switch is automatically used when F is invoked with the
-C command (instead of C):
+Include the named module or perl library and trace direct
+dependencies. This is done by loading the module in a subprocess and
+tracing which other modules and files it actually loads.
- # build a new ./perl with only common::sense in it - very small :)
- staticperl mkperl -Mcommon::sense
+Example: include AnyEvent and AnyEvent::Impl::Perl.
-=item --app name
+ staticperl mkbundle --use AnyEvent --use AnyEvent::Impl::Perl
-After writing out the bundle files, try to link a new standalone
-program. It will be called C, and the bundle files get removed after
-linking it.
+Sometimes you want to load old-style "perl libraries" (F<.pl> files), or
+maybe other weirdly named files. To support this, the C<--use> option
+actually tries to do what you mean, depending on the string you specify:
-The difference to the (mutually exclusive) C<--perl> option is that the
-binary created by this option will not try to act as a perl interpreter -
-instead it will simply initialise the perl interpreter, clean it up and
-exit.
+=over 4
-This switch is automatically used when F is invoked with the
-C command (instead of C):
+=item a possibly valid module name, e.g. F, F,
+F.
-To let it do something useful you I add some boot code, e.g. with
-the C<--boot> option.
+If the string contains no quotes, no F> and no F<.>, then C<--use>
+assumes that it is a normal module name. It will create a new package and
+evaluate a C in it, i.e. it will load the package and do a
+default import.
-Example: create a standalone perl binary that will execute F when
-it is started.
+The import step is done because many modules trigger more dependencies
+when something is imported than without.
- staticperl mkbundle --app myexe --boot appfile
+=item anything that contains F> or F<.> characters,
+e.g. F, F.
-=item --use module | -Mmodule
+The string will be quoted and passed to require, as if you used C. Nothing will be imported.
-Include the named module and all direct dependencies. This is done by
-C'ing the module in a subprocess and tracing which other modules
-and files it actually loads. If the module uses L, then all
-splitfiles will be included as well.
+=item "path" or 'path', e.g. C<"utf8_heavy.pl">.
-Example: include AnyEvent and AnyEvent::Impl::Perl.
+If you enclose the name into single or double quotes, then the quotes will
+be removed and the resulting string will be passed to require. This syntax
+is form compatibility with older versions of staticperl and should not be
+used anymore.
- staticperl mkbundle --use AnyEvent --use AnyEvent::Impl::Perl
+=back
-Sometimes you want to load old-style "perl libraries" (F<.pl> files), or
-maybe other weirdly named files. To do that, you need to quote the name in
-single or double quotes. When given on the command line, you probably need
-to quote once more to avoid your shell interpreting it. Common cases that
-need this are F and F.
+Example: C AnyEvent::Socket, once using C (importing the
+symbols), and once via C, not importing any symbols. The first
+form is preferred as many modules load some extra dependencies when asked
+to export symbols.
+
+ staticperl mkbundle -MAnyEvent::Socket # use + import
+ staticperl mkbundle -MAnyEvent/Socket.pm # require only
Example: include the required files for F to work in all its
-glory (F is included automatically by this).
+glory (F is included automatically by the dependency tracker).
- # bourne shell
- staticperl mkbundle --use '"Config_heavy.pl"'
+ # shell command
+ staticperl mkbundle -MConfig_heavy.pl
# bundle specification file
- use "Config_heavy.pl"
+ use Config_heavy.pl
-The C<-Mmodule> syntax is included as an alias that might be easier to
-remember than C. Or maybe it confuses people. Time will tell. Or
-maybe not. Argh.
+The C<-M>module syntax is included as a convenience that might be easier
+to remember than C<--use> - it's the same switch as perl itself uses
+to load modules. Or maybe it confuses people. Time will tell. Or maybe
+not. Sigh.
-=item --eval "perl code" | -e "perl code"
+=item C<--eval> "perl code" | C<-e> "perl code"
Sometimes it is easier (or necessary) to specify dependencies using perl
code, or maybe one of the modules you use need a special use statement. In
-that case, you can use C to execute some perl snippet or set some
-variables or whatever you need. All files C'd or C'd in the
-script are included in the final bundle.
-
-Keep in mind that F will only C the modules named
-by the C<--use> option, so do not expect the symbols from modules you
-C<--use>'d earlier on the command line to be available.
+that case, you can use C<--eval> to execute some perl snippet or set some
+variables or whatever you need. All files C'd or C'd while
+executing the snippet are included in the final bundle.
+
+Keep in mind that F will not import any symbols from the modules
+named by the C<--use> option, so do not expect the symbols from modules
+you C<--use>'d earlier on the command line to be available.
Example: force L to detect a backend and therefore include it
in the final bundle.
@@ -440,96 +463,301 @@
staticperl mkbundle --eval 'use AnyEvent; AnyEvent::detect'
# or like this
- staticperl mkbundle -MAnyEvent --eval 'use AnyEvent; AnyEvent::detect'
+ staticperl mkbundle -MAnyEvent --eval 'AnyEvent::detect'
Example: use a separate "bootstrap" script that C's lots of modules
-and include this in the final bundle, to be executed automatically.
+and also include this in the final bundle, to be executed automatically
+when the interpreter is initialised.
staticperl mkbundle --eval 'do "bootstrap"' --boot bootstrap
-=item --boot filename
+=item C<--boot> F
-Include the given file in the bundle and arrange for it to be executed
-(using a C) before anything else when the new perl is
-initialised. This can be used to modify C<@INC> or anything else before
-the perl interpreter executes scripts given on the command line (or via
-C<-e>). This works even in an embedded interpreter.
-
-=item --incglob pattern
-
-This goes through all library directories and tries to match any F<.pm>
-and F<.pl> files against the extended glob pattern (see below). If a file
-matches, it is added. This switch will automatically detect L
-files and the required link libraries for XS modules, but it will I
-scan the file for dependencies (at the moment).
+Include the given file in the bundle and arrange for it to be
+executed (using C) before the main program when the new perl
+is initialised. This can be used to modify C<@INC> or do similar
+modifications before the perl interpreter executes scripts given on the
+command line (or via C<-e>). This works even in an embedded interpreter -
+the file will be executed during interpreter initialisation in that case.
+
+=item C<--incglob> pattern
+
+This goes through all standard library directories and tries to match any
+F<.pm> and F<.pl> files against the extended glob pattern (see below). If
+a file matches, it is added. The pattern is matched against the full path
+of the file (sans the library directory prefix), e.g. F.
-This is mainly useful to include "everything":
+This is very useful to include "everything":
--incglob '*'
-Or to include perl libraries, or trees of those, such as the unicode
-database files needed by many other modules:
+It is also useful for including perl libraries, or trees of those, such as
+the unicode database files needed by some perl built-ins, the regex engine
+and other modules.
--incglob '/unicore/**.pl'
-=item --add file | --add "file alias"
+=item C<--add> F | C<--add> "F alias"
Adds the given (perl) file into the bundle (and optionally call it
-"alias"). This is useful to include any custom files into the bundle.
+"alias"). The F is either an absolute path or a path relative to the
+current directory. If an alias is specified, then this is the name it will
+use for C<@INC> searches, otherwise the path F will be used as the
+internal name.
+
+This switch is used to include extra files into the bundle.
-Example: embed the file F as F when creating the bundle.
+Example: embed the file F in the current directory as F
+when creating the bundle.
staticperl mkperl --add "httpd httpd.pm"
-It is also a great way to add any custom modules:
+ # can be accessed via "use httpd"
+
+Example: add a file F from the current directory.
+
+ staticperl mkperl --add 'initcode &initcode'
+
+ # can be accessed via "do '&initcode'"
+
+Example: add local files as extra modules in the bundle.
# specification file
- add file1 myfiles/file1
- add file2 myfiles/file2
- add file3 myfiles/file3
+ add file1 myfiles/file1.pm
+ add file2 myfiles/file2.pm
+ add file3 myfiles/file3.pl
+
+ # then later, in perl, use
+ use myfiles::file1;
+ require myfiles::file2;
+ my $res = do "myfiles/file3.pl";
-=item --binadd file | --add "file alias"
+=item C<--binadd> F | C<--add> "F alias"
Just like C<--add>, except that it treats the file as binary and adds it
-without any processing.
+without any postprocessing (perl files might get stripped to reduce their
+size).
-You should probably add a C> prefix to avoid clashing with embedded
-perl files (whose paths do not start with C>), and/or use a special
-directory, such as C.
+If you specify an alias you should probably add a C<&> prefix to avoid
+clashing with embedded perl files (whose paths never start with C<&>),
+and/or use a special directory prefix, such as C<&res/name>.
You can later get a copy of these files by calling C.
-=item --include pattern | -i pattern | --exclude pattern | -x pattern
+An alternative way to embed binary files is to convert them to perl and
+use C to get the contents - this method is a bit cumbersome, but works
+both inside and outside of a staticperl bundle:
+
+ # a "binary" file, call it "bindata.pl"
+ <<'SOME_MARKER'
+ binary data NOT containing SOME_MARKER
+ SOME_MARKER
-These two options define an include/exclude filter that is used after all
-files selected by the other options have been found. Each include/exclude
-is applied to all files found so far - an include makes sure that the
-given files will be part of the resulting file set, an exclude will
-exclude files. The patterns are "extended glob patterns" (see below).
+ # load the binary
+ chomp (my $data = do "bindata.pl");
-For example, to include everything, except C modules, but still
+=back
+
+=item Step 2: filter all files using C<--include> and C<--exclude> options.
+
+After all candidate files and modules are added, they are I
+by a combination of C<--include> and C<--exclude> patterns (there is an
+implicit C<--include *> at the end, so if no filters are specified, all
+files are included).
+
+All that this step does is potentially reduce the number of files that are
+to be included - no new files are added during this step.
+
+=over 4
+
+=item C<--include> pattern | C<-i> pattern | C<--exclude> pattern | C<-x> pattern
+
+These specify an include or exclude pattern to be applied to the candidate
+file list. An include makes sure that the given files will be part of the
+resulting file set, an exclude will exclude remaining files. The patterns
+are "extended glob patterns" (see below).
+
+The patterns are applied "in order" - files included via earlier
+C<--include> specifications cannot be removed by any following
+C<--exclude>, and likewise, and file excluded by an earlier C<--exclude>
+cannot be added by any following C<--include>.
+
+For example, to include everything except C modules, but still
include F, you could use this:
--incglob '*' -i '/Devel/PPPort.pm' -x '/Devel/**'
-=item --static
+=back
+
+=item Step 3: add any extra or "hidden" dependencies.
+
+F currently knows about three extra types of depdendencies
+that are added automatically. Only one (F<.packlist> files) is currently
+optional and can be influenced, the others are always included:
+
+=over 4
+
+=item C<--usepacklists>
+
+Read F<.packlist> files for each distribution that happens to match a
+module name you specified. Sounds weird, and it is, so expect semantics to
+change somehow in the future.
+
+The idea is that most CPAN distributions have a F<.pm> file that matches
+the name of the distribution (which is rather reasonable after all).
+
+If this switch is enabled, then if any of the F<.pm> files that have been
+selected match an install distribution, then all F<.pm>, F<.pl>, F<.al>
+and F<.ix> files installed by this distribution are also included.
+
+For example, using this switch, when the L module is specified, then
+all L submodules that have been installed via the CPAN distribution
+are included as well, so you don't have to manually specify them.
+
+=item L splitfiles
+
+Some modules use L - less commonly (hopefully) used functions
+are split into separate F<.al> files, and an index (F<.ix>) file contains
+the prototypes.
+
+Both F<.ix> and F<.al> files will be detected automatically and added to
+the bundle.
+
+=item link libraries (F<.a> files)
-When C<--perl> is also given, link statically instead of dynamically. The
-default is to link the new perl interpreter fully dynamic (that means all
-perl modules are linked statically, but all external libraries are still
+Modules using XS (or any other non-perl language extension compiled at
+installation time) will have a static archive (typically F<.a>). These
+will automatically be added to the linker options in F.
+
+Should F find a dynamic link library (typically F<.so>) it
+will warn about it - obviously this shouldn't happen unless you use
+F on the wrong perl, or one (probably wrongly) configured to
+use dynamic loading.
+
+=item extra libraries (F)
+
+Some modules need linking against external libraries - these are found in
+F and added to F.
+
+=back
+
+=item Step 4: write bundle files and optionally link a program
+
+At this point, the select files will be read, processed (stripped) and
+finally the bundle files get written to disk, and F
+is normally finished. Optionally, it can go a step further and either link
+a new F binary with all selected modules and files inside, or build
+a standalone application.
+
+Both the contents of the bundle files and any extra linking is controlled
+by these options:
+
+=over 4
+
+=item C<--strip> C|C|C
+
+Specify the stripping method applied to reduce the file of the perl
+sources included.
+
+The default is C, which uses the L module to remove all
+pod documentation, which is very fast and reduces file size a lot.
+
+The C method uses L to parse and condense the perl sources. This
+saves a lot more than just L, and is generally safer,
+but is also a lot slower (some files take almost a minute to strip -
+F maintains a cache of stripped files to speed up subsequent
+runs for this reason). Note that this method doesn't optimise for raw file
+size, but for best compression (that means that the uncompressed file size
+is a bit larger, but the files compress better, e.g. with F).
+
+Last not least, if you need accurate line numbers in error messages,
+or in the unlikely case where C is too slow, or some module gets
+mistreated, you can specify C to not mangle included perl sources in
+any way.
+
+=item C<--perl>
+
+After writing out the bundle files, try to link a new perl interpreter. It
+will be called F and will be left in the current working
+directory. The bundle files will be removed.
+
+This switch is automatically used when F is invoked with the
+C command instead of C.
+
+Example: build a new F<./perl> binary with only L inside -
+it will be even smaller than the standard perl interpreter as none of the
+modules of the base distribution (such as L) will be included.
+
+ staticperl mkperl -Mcommon::sense
+
+=item C<--app> F
+
+After writing out the bundle files, try to link a new standalone
+program. It will be called C, and the bundle files get removed after
+linking it.
+
+This switch is automatically used when F is invoked with the
+C command instead of C.
+
+The difference to the (mutually exclusive) C<--perl> option is that the
+binary created by this option will not try to act as a perl interpreter -
+instead it will simply initialise the perl interpreter, clean it up and
+exit.
+
+This means that, by default, it will do nothing but burn a few CPU cycles
+- for it to do something useful you I add some boot code, e.g. with
+the C<--boot> option.
+
+Example: create a standalone perl binary called F<./myexe> that will
+execute F when it is started.
+
+ staticperl mkbundle --app myexe --boot appfile
+
+=item C<--ignore-env>
+
+Generates extra code to unset some environment variables before
+initialising/running perl. Perl supports a lot of environment variables
+that might alter execution in ways that might be undesirablre for
+standalone applications, and this option removes those known to cause
+trouble.
+
+Specifically, these are removed:
+
+C and C can cause underaible
+output, C, C, C and
+C can alter execution significantly, and C,
+C and C can affect input and output.
+
+The variables C and C are always ignored because the
+startup code used by F overrides C<@INC> in all cases.
+
+This option will not make your program more secure (unless you are
+running with elevated privileges), but it will reduce the surprise effect
+when a user has these environment variables set and doesn't expect your
+standalone program to act like a perl interpreter.
+
+=item C<--static>
+
+Add C<-static> to F, which means a fully static (if
+supported by the OS) executable will be created. This is not immensely
+useful when just creating the bundle files, but is most useful when
+linking a binary with the C<--perl> or C<--app> options.
+
+The default is to link the new binary dynamically (that means all perl
+modules are linked statically, but all external libraries are still
referenced dynamically).
Keep in mind that Solaris doesn't support static linking at all, and
-systems based on GNU libc don't really support it in a usable fashion
-either. Try uClibc if you want to create fully statically linked
-executables, or try the C<--staticlibs> option to link only some libraries
+systems based on GNU libc don't really support it in a very usable
+fashion either. Try uClibc if you want to create fully statically linked
+executables, or try the C<--staticlib> option to link only some libraries
statically.
-=item --staticlib libname
+=item C<--staticlib> libname
When not linking fully statically, this option allows you to link specific
-libraries statically. What it does is simply replace all occurances of
+libraries statically. What it does is simply replace all occurrences of
C<-llibname> with the GCC-specific C<-Wl,-Bstatic -llibname -Wl,-Bdynamic>
option.
@@ -537,17 +765,14 @@
specifically, C<--staticlib> will not link against the named library
unless it would be linked against anyway.
-Example: link libcrypt statically into the binary.
+Example: link libcrypt statically into the final binary.
staticperl mkperl -MIO::AIO --staticlib crypt
- # ldopts might nwo contain:
+ # ldopts might now contain:
# -lm -Wl,-Bstatic -lcrypt -Wl,-Bdynamic -lpthread
-=item any other argument
-
-Any other argument is interpreted as a bundle specification file, which
-supports most long options (without extra quoting), one option per line.
+=back
=back
@@ -571,7 +796,7 @@
That is, F will match any file called F anywhere in the
hierarchy, but not any directories of the same name.
-=item A F<*> matches any single component.
+=item A F<*> matches anything within a single path component.
That is, F would match all F<.pl> files directly inside
C, not any deeper level F<.pl> files. Or in other words, F<*>
@@ -591,16 +816,22 @@
=head2 F CONFIGURATION AND HOOKS
-During (each) startup, F tries to source the following shell
-files in order:
+During (each) startup, F tries to source some shell files to
+allow you to fine-tune/override configuration settings.
+
+In them you can override shell variables, or define shell functions
+("hooks") to be called at specific phases during installation. For
+example, you could define a C hook to install additional
+modules from CPAN each time you start from scratch.
+
+If the env variable C<$STATICPERLRC> is set, then F will try
+to source the file named with it only. Otherwise, it tries the following
+shell files in order:
/etc/staticperlrc
~/.staticperlrc
$STATICPERL/rc
-They can be used to override shell variables, or define functions to be
-called at specific phases.
-
Note that the last file is erased during F, so
generally should not be used.
@@ -650,9 +881,9 @@
=item C
-The perl version to install - default is currently C<5.12.2>, but C<5.8.9>
-is also a good choice (5.8.9 is much smaller than 5.12.2, while 5.10.1 is
-about as big as 5.12.2).
+The perl version to install - default is currently C<5.12.3>, but C<5.8.9>
+is also a good choice (5.8.9 is much smaller than 5.12.3, while 5.10.1 is
+about as big as 5.12.3).
=item C
@@ -671,13 +902,17 @@
(C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to
reduce filesize further.
-=item C, C, C, C
+=item C, C, C, C, C
These flags are passed to perl's F script, and are generally
optimised for small size (at the cost of performance). Since they also
contain subtle workarounds around various build issues, changing these
-usually requires understanding their default values - best look at the top
-of the F script for more info on these.
+usually requires understanding their default values - best look at
+the top of the F script for more info on these, and use a
+F<~/.staticperlrc> to override them.
+
+Most of the variables override (or modify) the corresponding F
+variable, except C, which gets appended.
=back
@@ -685,6 +920,10 @@
=over 4
+=item C
+
+The make command to use - default is C.
+
=item C
Where F writes the C command to
@@ -778,7 +1017,7 @@
=over 4
-=item staticperl_init ()
+=item staticperl_init (xs_init = 0)
Initialises the perl interpreter. You can use the normal perl functions
after calling this function, for example, to define extra functions or
@@ -795,25 +1034,43 @@
static void
run_myapp(void)
{
- staticperl_init ();
+ staticperl_init (0);
newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$");
eval_pv ("require myapp::main", 1); // executes "myapp/main.pm"
}
-=item staticperl_xs_init (pTHX)
+When your bootcode already wants to access some XS functions at
+compiletime, then you need to supply an C function pointer that
+is called as soon as perl is initialised enough to define XS functions,
+but before the preamble code is executed:
-Sometimes you need direct control over C and C, in
-which case you do not want to use C but call them on your
-own.
+ static void
+ xs_init (pTHX)
+ {
+ newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$");
+ }
-Then you need this function - either pass it directly as the C
-function to C, or call it from your own C function.
+ static void
+ run_myapp(void)
+ {
+ staticperl_init (xs_init);
+ }
=item staticperl_cleanup ()
In the unlikely case that you want to destroy the perl interpreter, here
is the corresponding function.
+=item staticperl_xs_init (pTHX)
+
+Sometimes you need direct control over C and C, in
+which case you do not want to use C but call them on your
+own.
+
+Then you need this function - either pass it directly as the C
+function to C, or call it as one of the first things from your
+own C function.
+
=item PerlInterpreter *staticperl
The perl interpreter pointer used by staticperl. Not normally so useful,
@@ -858,7 +1115,7 @@
=back
-=head1 FULLY STATIC BINARIES - BUILDROOT
+=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT
To make truly static (Linux-) libraries, you might want to have a look at
buildroot (L ).
@@ -929,7 +1186,7 @@
for unicode character ranges in regexes) is implemented in the
C<"utf8_heavy.pl"> library:
- -M'"utf8_heavy.pl"'
+ -Mutf8_heavy.pl
Many Unicode properties in turn are defined in separate modules,
such as C<"unicore/Heavy.pl"> and more specific data tables such as
@@ -940,7 +1197,7 @@
To simply include the whole unicode database, use:
- --incglob '/unicore/*.pl'
+ --incglob '/unicore/**.pl'
=item AnyEvent
@@ -955,6 +1212,9 @@
functions), you also need to include C<"AnyEvent/Util/idna.pl"> and
C<"AnyEvent/Util/uts46data.pl">.
+Or you can use C<--usepacklists> and specify C<-MAnyEvent> to include
+everything.
+
=item Carp
Carp had (in older versions of perl) a dependency on L. As of
@@ -968,13 +1228,14 @@
=item Term::ReadLine::Perl
-Also needs L.
+Also needs L, or C<--usepacklists>.
=item URI
URI implements schemes as separate modules - the generic URL scheme is
implemented in L, HTTP is implemented in L. If
-you need to use any of these schemes, you should include these manually.
+you need to use any of these schemes, you should include these manually,
+or use C<--usepacklists>.
=back
@@ -982,14 +1243,22 @@
=over 4
-=item Linking everything in
+=item Just link everything in
To link just about everything installed in the perl library into a new
-perl, try this:
+perl, try this (the first time this runs it will take a long time, as a
+lot of files need to be parsed):
+
+ staticperl mkperl -v --strip ppi --incglob '*'
+
+If you don't mind the extra megabytes, this can be a very effective way of
+creating bundles without having to worry about forgetting any modules.
- staticperl mkperl --strip ppi --incglob '*'
+You get even more useful variants of this method by first selecting
+everything, and then excluding stuff you are reasonable sure not to need -
+L uses this approach.
-=item Getting rid of netdb function
+=item Getting rid of netdb functions
The perl core has lots of netdb functions (C, C
and so on) that few applications use. You can avoid compiling them in by
@@ -1016,8 +1285,8 @@
done
}
-This mostly gains space when linking staticaly, as the functions will
-liekly not be linked in. The gain for dynamically-linked binaries is
+This mostly gains space when linking statically, as the functions will
+likely not be linked in. The gain for dynamically-linked binaries is
smaller.
Also, this leaves C in - not only is it actually used