use alienfile;

plugin 'Probe::CBuilder' => (
  libs => '-lgmp',
  version => qr/version = '(.*?)'/,
  program => <<'EOM'
#include <stdio.h>
#include <gmp.h>
int
main(int argc, char *argv[])
{
  printf("version = '%s'\n", gmp_version);
  return 0;
}
EOM
);

share {
  plugin Download => (
    url => 'ftp://ftp.gnu.org/gnu/gmp',
    filter => qr/^gmp-.*\.tar\.gz$/,
    version => qr/([0-9\.]+)/,
  );
  plugin Extract => 'tar.gz',
  plugin 'Build::Autoconf' => ();

  build [
    '%{configure} --enable-shared --enable-static',
    '%{make}',
    '%{make} check',
    '%{make} install',
  ];
  
  plugin 'Gather::IsolateDynamic';
  
  gather sub {
    my($build) = @_;
    $build->runtime_prop->{$_} = "-I@{[ $build->runtime_prop->{prefix} ]}/include " for qw( cflags cflags_static );
    $build->runtime_prop->{$_} = "-L@{[ $build->runtime_prop->{prefix} ]}/lib -lgmp " for qw( libs libs_static );
  };
};
