When testing, check if '/proc/mounts' exists.
[perl-fuse.git] / Makefile.PL
1 use ExtUtils::MakeMaker;
2 use Config;
3 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
4 # the contents of the Makefile that is written.
5
6 my $ver = `fusermount -V`;
7 my $ver2 = `mount_fusefs -V`;
8 chomp(my $ver3 = `mount_fusefs -V 2>&1 | head -n1`);
9 $ver =~ s/^.*?version:\s+//;
10 $ver2 =~ s/^.*?version:\s+//;
11 $ver3 =~ s/^.*?version\s+//;
12 if (! $ver && ! $ver2 && ! $ver3) {
13         # make CPANPLUS happy and don't report errors if fuse isn't installed
14         die("No support for os: $^O\n",
15                 "You need to have fuse-dev (or similar) package installed and have sufficient permissions in order to install this module\n",
16                 $^O eq 'darwin' ? ("One option on Mac is http://code.google.com/p/macfuse/\n") : (),
17         );
18 }
19 if ($ver && $ver + 0 < 2.5) {
20         die "Fuse perl bindings need Linux fuse version 2.5 or newer\n";
21 } elsif ($ver2 && $ver2 + 0 < 0.3) {
22         die "Fuse perl bindings need FreeBSD fuse version 0.3 or newer\n";
23 } elsif ($^O eq 'darwin' && $ver3 && !(($ver3 ge "0.1.0b006") || ($ver3 eq "0.1.0"))) {
24         # the "ge" string-compare check will match all later revs and all later
25         # betas, but not the final release of the current rev (0.1.0).
26         die "Fuse perl bindings need MacFUSE version 0.1.0b006 or newer, your version is \"$ver3\"\n";
27 } else {
28         warn "fuse version found: ", $ver || $ver2 || $ver3, "\n";
29 }
30
31 my $inc = '-DFUSE_USE_VERSION=26 ' . `pkg-config --cflags fuse` || '-I ../include -D_FILE_OFFSET_BITS=64';
32 my $obj = `pkg-config --libs fuse` || (($^O eq 'netbsd') ? '-lrefuse' : '-lfuse');
33 my $def = '-Wall -g -ggdb';
34 $def .= ' -D__FreeBSD__=10 -D_FILE_OFFSET_BITS=64' if $^O eq 'darwin';
35 $def .= ' -DPERL_HAS_64BITINT' if $Config{'use64bitint'};
36
37 WriteMakefile(
38         'NAME'                  => 'Fuse',
39         'VERSION_FROM'  => 'Fuse.pm', # finds $VERSION
40         'PREREQ_PM'             => {}, # e.g., Module::Name => 1.1
41         ($] >= 5.005 ?  ## Add these new keywords supported since 5.005
42                 (ABSTRACT_FROM  => 'Fuse.pm', # retrieve abstract from module
43                 AUTHOR                  => 'Mark Glines <mark@glines.org>') : ()),
44                 ($ExtUtils::MakeMaker::VERSION < 6.46 ? () : (
45                         META_MERGE => {
46                                 resources => {
47                                 bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Fuse',
48                                 repository => 'http://github.com/dpavlin/perl-fuse'
49                         }
50                 })
51         ),
52         'LIBS'                  => [''], # e.g., '-lm'
53         'DEFINE'                => $def, # e.g., '-DHAVE_SOMETHING'
54         # Insert -I. if you add *.h files later:
55         'INC'                   => $inc, # e.g., '-I/usr/include/other'
56         # Un-comment this if you add C files to link with later:
57         'OBJECT'                => "$obj Fuse.o -lpthread", # link all the C files too
58 );
59
60 sub MY::postamble {
61         return <<'MAKE_MORE';
62
63 cpan:
64         make clean
65         rm -f Fuse-*.tar.gz
66         perl Makefile.PL
67         make dist
68         make disttest
69         @echo
70         @echo -n "Upload" Fuse-*.tar.gz "to CPAN? [y/N]:"
71         @read upload && test "$$upload" == "y" && cpan-upload -verbose Fuse-*.tar.gz
72
73
74
75 sf:
76         svn2cvs.pl file:///home/dpavlin/private/svn/fuse/perl-llin :ext:dpavlin@fuse.cvs.sourceforge.net:/cvsroot/fuse perl
77
78 MAKE_MORE
79 };