-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.PL
84 lines (75 loc) · 3.21 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use lib qw(inc);
use ExtUtils::MakeMaker;
use Devel::CheckLib;
use Cwd;
use File::Temp qw/tempdir/;
use IO::File;
use strict;
# Check whether we have an "xattr.h" on Linux.
# Suggest what the user needs to install, to get these files.
my (@DEFINES, @LIBS);
if ($^O eq 'linux') {
# check for libc6-dev first
if (!check_lib( header => [qw(sys/xattr.h)] ) ) {
warn "'sys/xattr.h' not found. Either package 'lib6-dev' (Debian) or glibc-devel (RHEL/CentOS/Fedora) is not installed, or is very old\n";
warn "Trying for 'attr/xattr.h' from package 'libattr1-dev' (Debian) or libattr-devel (RHEL/CentOS/Fedora)\n";
check_lib_or_exit(
header => [qw(sys/types.h attr/xattr.h attr/attributes.h )],
lib => [qw(attr)],
);
push @DEFINES, 'HAS_LIBATTR';
# Don't actually need -lattr on Linux - is this only if the libc supports xattrs?
push @LIBS, 'attr';
}
}
# OpenBSD does not support extended attributes.
if ($^O eq 'openbsd') {
warn 'OpenBSD does not support extended attributes';
die "OS unsupported";
}
# Check whether extended attributes are supported on this filesystem.
# If we're running non-interactive there is no point failing all the tests,
# because the machine is not set up correctly.
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});
}
}
# TODO: Check filesystem on other operating systems
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'File::ExtAttr',
VERSION_FROM => 'lib/File/ExtAttr.pm', # finds $VERSION
PREREQ_PM => {
# e.g., Module::Name => 1.1
'Carp' => 0,
'Scalar::Util' => 0
},
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/File/ExtAttr.pm', # retrieve abstract from module
AUTHOR => 'Kevin M. Goess <[email protected]>'
.', Richard Dawe <[email protected]>') : ()),
LIBS => join(' ', map { "-l$_" } @LIBS),
OBJECT => '$(O_FILES)',
DEFINE => join(' ', map { "-D$_" } @DEFINES),
# INC => join(' ', map { "-I$_" } @DIRS),
# 'MYEXTLIB' => 'mylib/libxattrlib$(LIB_EXT)',
# Un-comment this if you add C files to link with later:
# OBJECT => '$(O_FILES)', # link all the C files too
# Hand-roll META.yml and MANIFEST.
NO_META => 1,
);