use lib qw(inc);
use ExtUtils::MakeMaker;
use Devel::CheckLib;
use Cwd;
use File::Temp qw/tempdir/;
use IO::File;
use strict;
if ($^O eq 'linux') {
check_lib_or_exit(
lib => [qw(attr)]
);
}
my @DIRS = qw(. /usr/include);
if ($^O eq 'linux')
{
my %headers = (
'attr/attributes.h' => 0,
'attr/xattr.h' => 0,
);
my $incdir;
my $missing = 0;
foreach $incdir (@DIRS)
{
foreach (keys %headers)
{
$headers{$_}++ if (-r "$incdir/$_");
}
}
foreach (keys %headers)
{
if ($headers{$_} == 0) {
warn "<$_> not found; perhaps you need to install libattr-devel";
$missing++;
}
}
exit(0) if ($missing > 0);
}
if ($^O eq 'openbsd') {
warn 'OpenBSD does not support extended attributes';
die "OS unsupported";
}
if ($^O eq 'linux') {
my $basedir = $ENV{ATTR_TEST_DIR} || getcwd();
my $template .= "$basedir/XXXXXXXX";
my $dir = tempdir($template, CLEANUP => 1);
my $file = "$dir/testfile";
my $fh = new IO::File(">$file") or die "Unable to open $file: $!";
undef $fh;
my $output = `setfattr -n user.foo -v foo $file 2>&1`;
if ($output =~ /command not found/i) {
warn "Please install the attr package (containing the setfattr program)";
exit(0) if ($ENV{AUTOMATED_TESTING});
}
if ($output =~ /Operation not supported/i) {
warn "To run the tests, you need mount the filesystem containing $basedir with the user_xattr option";
warn "Alternatively set the environment variable ATTR_TEST_DIR to point at a filesystem where user_xattr is enabled";
exit(0) if ($ENV{AUTOMATED_TESTING});
}
}
WriteMakefile(
NAME => 'File::ExtAttr',
VERSION_FROM => 'lib/File/ExtAttr.pm', PREREQ_PM => {
'Carp' => 0,
'Scalar::Util' => 0
},
($] >= 5.005 ? (ABSTRACT_FROM => 'lib/File/ExtAttr.pm', AUTHOR => 'Kevin M. Goess <kgoess@ensenda.com>'
.', Richard Dawe <richdawe@cpan.org>') : ()),
OBJECT => '$(O_FILES)',
DEFINE => '', INC => join(' ', map { "-I$_" } @DIRS),
NO_META => 1,
);