Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild/FAQ.pod view on Meta::CPAN
extracted. One way to do this is to create a module in your distribution's inc directory that does the
patching (modules in inc can be used during build/test but won't be installed):
# inc/My/AlienPatch.pm
package My::AlienPatch;
# add this sub to the main namespace
# so we don't need to quote or escape
# anything below
sub main::alien_patch {
# is executed in the package root,
# make what ever changes you need to
# to the source here.
}
1;
# Build.PL
use Alien::Base::ModuleBuild;
Alien::Base::ModuleBuild->new(
...
alien_build_commands => [
# %x will be replaced by path for calling Perl
# from the command line
"%x -I../../inc -MMy::AlienPatch -e alien_patch",
...
],
...
)->create_build_script;
=head2 How do I build a package that uses I<build system>?
=head3 autoconf
By default L<Alien::Base::ModuleBuild> assumes a package with an autoconf style C<configure> script. The
default is
# Build.PL
use Alien::Base::ModuleBuild;
Alien::Base::ModuleBuild->new(
...
alien_build_commands => [
'%c --prefix=%s',
'make',
],
alien_install_commands => [
'make install',
],
...
)->create_build_script;
There are a couple of short cuts here, C<%c> indicates the platform independent method for executing the
C<configure> script, plus any normal autoconf flags that are appropriate for Perl Alien libraries. The C<%c>
also tells L<Alien::Base::ModuleBuild> to use L<Alien::MSYS> on Windows platforms and to add that as a
dependency. The C<%s> is a placeholder for the location to which the package will be installed. This is
normally in a share directory specific to your distribution.
=head3 autoconf-like
If you see an error like this:
Unknown option "--with-pic".
It may be because your package provides a C<configure> script that provides an autoconf-style interface, but is
not actually autoconf. L<Alien::Base::ModuleBuild> is aggressive in using the C<--with-pic> option because when
supported by autoconf it produces position independent code (important for reliably building XS extensions), and
when not supported autoconf simply ignores the option. Unfortunately some autoconf-style C<configure> scripts
consider it an error when they see options that they do not recognize. You can tell L<Alien::Base::ModuleBuild>
to not use the C<--with-pic> option via the C<alien_autoconf_with_pic> property:
# Build.PL
use Alien::Base::ModuleBuild;
Alien::Base::ModuleBuild->new(
...
alien_autoconf_with_pic => 0,
...
)->create_build_script;
=head3 CMAKE
You probably cannot count on CMake being available on most platforms. Fortunately, there is an alien
distribution L<Alien::CMake> which will either use the CMake provided by the operating system, or download and
install it for you. You can use this from your C<Build.PL> with the C<alien_bin_requires> property:
# Build.PL
use Alien::Base::ModuleBuild;
use Config;
Alien::Base::ModuleBuild->new(
...
alien_bin_requires => {
'Alien::CMake' => 0.07,
},
alien_build_commands => [
# acutal required arguments may vary
"cmake -G 'Unix Makefiles' -DCMAKE_MAKE_PROGRAM=$Config{make} -DCMAKE_INSTALL_PREFIX:PATH=%s",
"$Config{make}",
],
alien_install_commands => [
"$Config{make} install",
],
...
)->create_build_script;
=head3 vanilla Makefiles?
If you want to use the same C<make> as Perl, you can use L<Config>:
# Build.PL
use Alien::Base::ModuleBuild;
use Config;
Alien::Base::ModuleBuild->new(
...
alien_build_commands => [
"$Config{make}",
],
alien_install_commands => [
"$Config{make} install",
],
...
)->create_build_script;
=head3 GNU Makefiles?
Some packages require GNU Make's unique syntax. Perl's L<Config> provides an entry for C<gmake>, but it is
frequently wrong. Do not depend on it. Instead you can use L<Alien::gmake> to provide a real GNU Make (either
from the operating system, or built from source):
# Build.PL
( run in 1.693 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )