use alienfile;

# see xz.alienfile for a more reliable and portable
# example that uses plugins.

# Use pkg-config to check if the library exists.
# also, use which to check that the xz command is
# in the path.
probe [
  'pkg-config --exists liblzma',
  'which xz',
];

share {

  start_url 'http://tukaani.org/xz/xz-5.2.3.tar.gz';

  # the first one which succeeds will be used
  download [ 'wget %{.meta.start_url}' ];
  download [ 'curl -O %{.meta.start_url}' ];

  # use tar to extract the tarball
  extract [ 'tar zxf %{.install.download}' ];

  # use the standard build process
  build [
    './configure --prefix=%{.install.prefix} --disable-shared',
    '%{make}',
    '%{make} install',
  ];

  # This package doesn't build a dynamic library by default, but if
  # it did this would make sure that it wasn't used with XS.
  # (See Alien::Build::Manual::AlienAuthor for details).
  plugin 'Gather::IsolateDynamic';

};

# You can specify individual gather steps in share {} or
# sys {} too, but for many cases the same procedure can
# be used for both.
gather [
  # store the (chomped) output into the appropriate runtime properties
  [ 'pkg-config', '--modversion', 'liblzma', \'%{.runtime.version}' ],
  [ 'pkg-config', '--cflags',     'liblzma', \'%{.runtime.cflags}'  ],
  [ 'pkg-config', '--libs',       'liblzma', \'%{.runtime.libs}'    ],
];
