use alienfile;

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

share {

  requires 'Alien::Build'     => '0.75';
  requires 'Alien::Autotools' => '1.02';

  plugin 'Download' => (
    url => 'https://github.com/hunspell/hunspell/releases',
    version => qr/^v([0-9\.]+)\.tar\.gz$/,
  );

  plugin 'Extract' => 'tar.gz';
  plugin 'Build::Autoconf' => (
    ffi => 1,
  );

  my @acflags;
  unshift @acflags, '--disable-nls' if $^O =~ /^(?:MSWin32|darwin|freebsd)/;

  build [
    [ 'sh', -c => 'libtoolize', ],
    [ 'sh', -c => 'autoreconf -vfi' ],
    "%{configure} --disable-shared --enable-static @acflags",
    '%{make}',
    '%{make} install',
  ];

  ffi {
    build [
      [ 'sh', -c => 'libtoolize', ],
      [ 'sh', -c => 'autoreconf -vfi' ],
      "%{configure} --disable-static --enable-shared --libdir=%{.install.autoconf_prefix}/dynamic @acflags",
      '%{make}',
      '%{make} install',
    ];
  };
};
