PerlAlien / Alien-Build

Build external dependencies for use in CPAN
16 stars 25 forks source link

Add autoreconf helper to Autoconf plugin #317

Closed chromatic closed 2 years ago

chromatic commented 2 years ago

I found myself needing something like this to support an upstream library that doesn't ship a ./configure script, but instead ships an autogen.sh script that calls autoreconf with these options. If there's a better way to do this, I'm open to the idea.

My alienfile looks like this:

plugin 'PkgConfig' => (
  pkg_name => 'libdogecoin',
);

share {
  start_url 'https://github.com/dogecoinfoundation/libdogecoin/archive/refs/tags/v0.1.0.tar.gz';
  plugin 'Download';
  plugin 'Extract' => 'tar.gz';
  plugin 'Build::Autoconf';
  build [
    '%{autoreconf} -if --warnings=all',
    '%{configure} --disable-shared',
    '%{make}',
    '%{make} install',
  ];
};

All tests pass for me on 64-bit x86 Linux.

chromatic commented 2 years ago

I see the problem with the Windows tests. That should be easy to fix.

plicease commented 2 years ago

The usual way that I deal with this is to use Alien::Autotools (which in turn uses Alien::autoconf, Alien::automake, Alien::libtool). I've not added any helpers for these though, and probably should!

share {
  requires 'Alien::Autotools';
  build [ 'autoreconf -if --warnings=all', ... ];
};

The downside to these is that they always perform a share install for Alien::autoconf and Alien::automake because using a system tool implemented in Perl can be problematic if the system Perl is different from the Perl that you are using and you have XS modules installed in a PERL5LIB directory. The silver lining is that if you require Alien::Autotools in the share block they will only be installed if your Alien is doing a share install.

We could put this helper in here with a documented caveat that it might not work in the described situation or we could add the helper to Alien::Autotools. My thinking is the latter is more reliable, but I'm also open to the former if you are okay with the caveats.

plicease commented 2 years ago

I will look into the one remaining CI failure, I am pretty sure that is unrelated to this PR.

chromatic commented 2 years ago

I have no strong preference between the two approaches you mention here (patching the project upstream may not always be an option), so I'm happy to use either.

plicease commented 2 years ago

Cool I am in the progress of implementing helpers in Alien::autoconf and Alien::Autotools that should address this.

plicease commented 2 years ago

I've made the required changes to Alien::Autotools (and its dependencies), and added some notes pointing to those aliens so hopefully future developers will be able to find it. You should be good with something like this:

plugin 'PkgConfig' => (
  pkg_name => 'libdogecoin',
);

share {
  requires 'Alien::Autotools' => 1.07;  # <- added this; 1.07 makes sure you get the appropriate helpers
  start_url 'https://github.com/dogecoinfoundation/libdogecoin/archive/refs/tags/v0.1.0.tar.gz';
  plugin 'Download';
  plugin 'Extract' => 'tar.gz';
  plugin 'Build::Autoconf';
  build [
    '%{autoreconf} -if --warnings=all',
    '%{configure} --disable-shared',
    '%{make}',
    '%{make} install',
  ];
};
plicease commented 2 years ago

Thanks for reporting this, and let me know if you have any questions.

The incantation for getting these tools to work on windows is a wee bit crazy

https://metacpan.org/dist/Alien-autoconf/source/lib/Alien/autoconf.pm#L18

so it is worth the effort to make it easier to build autotool packages on windows!

chromatic commented 2 years ago

I've just tried your suggestion and everything appears successful. Thank you kindly!