use alienfile;

plugin 'PkgConfig' => 'dontpanic';

plugin 'Probe::CommandLine' => (
  command   => 'dontpanic',
  secondary => 1,
);

share {

  start_url 'https://alienfile.org/dontpanic/';
  digest SHA256 => 'd6f7603c0bf0d3994631bdeab59d38fa7ce5eccf53be04047dd1e83b312a7b5a';

  plugin Download => (
    version => qr/([0-9\.]+)\.tar\.gz$/,
  );
  plugin Extract => 'tar.gz';
  plugin 'Build::Autoconf';
  
  test [ '%{make} check' ];

  ffi {
  
    build [
      # TODO: under windows, dll is installed in bin.  setting --bindir doesn't seem to work for the .dll
      # only the .exe.
      '%{configure} --enable-shared --disable-static --libdir=%{.install.autoconf_prefix}/dynamic',
      '%{make}',
      '%{make} install',
    ];
    
    test [ '%{make} check' ];

  };

};

meta->after_hook(
  $_ => sub {
    my($build) = @_;
    $build->runtime_prop->{legacy}->{inline_auto_include} = ['libdontpanic.h'];
  },
) for qw( gather_share gather_system );
