use alienfile;

# If the probe fails to find an already installed libevent, the
# "share" block contains instructions for downloading and
# installing it.
#
probe [ 
  'test -f /usr/include/boost/version.hpp',
];

share {

  start_url 'https://www.boost.org/users/download/';
  plugin 'Download' => (
    filter => qr/^boost_[0-9_]*\.tar\.gz$/,
    version => qr/([0-9_]+)/,
  );


  plugin 'Extract';

  build [
    './bootstrap.sh',
    './b2 install --prefix=%{.install.prefix} link=static cxxflags=-fPIC',
  ];

  gather sub {
    my($build) =@_;
    my $prefix = $build->runtime_prop->{prefix};
    $build->runtime_prop->{cflags}        = "-I$prefix/include";
    $build->runtime_prop->{cflags_static} = "-I$prefix/include";
    $build->runtime_prop->{libs}          = "-L$prefix/lib -lboost_program_options";
    $build->runtime_prop->{libs_static}   = "-L$prefix/lib -lboost_program_options";
  };
  
};

sys {

  gather sub {
    my($build) =@_;
    $build->runtime_prop->{libs}          = "-lboost_program_options";
    $build->runtime_prop->{libs_static}   = "-lboost_program_options";
  };
};

