Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild/FAQ.pod view on Meta::CPAN
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
use Alien::Base::ModuleBuild;
Alien::Base::ModuleBuild->new(
...
alien_bin_requires => {
'Alien::gmake' => 0.11, # needed for %{gmake} helper
},
alien_build_commands => [
"%{gmake}",
],
alien_install_commands => [
"%{gmake} install",
],
...
)->create_build_script;
=head2 When debugging my package build, I get different results!
If you get results from running the commands in your shell different to what happens when your C<Alien::>
distribution attempts to build, it may be because your environment is different than the one that your
distribution is using. For example, if you use L<Alien::CMake> or L<Alien::gmake> to build with specific tools
that are provided by your operating system, L<Alien::Base::ModuleBuild> will adjust the path before executing
build and install commands.
In the alien build directory (usually C<_alien>) you will find environment files that you can source
into your shell (C<env.csh> for tcsh and C<env.sh> for bourne based shells), which should provide the
identical environment used by the build process in order to troubleshoot the build manually.
( run in 0.910 second using v1.01-cache-2.11-cpan-64ef6c95b5d )