avoid cpan indexing of test::helper
[perl-fuse.git] / Makefile.PL
1 use ExtUtils::MakeMaker;
2 use POSIX;
3 use Config;
4 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
5 # the contents of the Makefile that is written.
6
7 # Note: This is a hack. This hack is necessary because MacFUSE's libfuse
8 # (and libfuse_ino64, by extension) don't link in libiconv. This wouldn't
9 # be a problem, but it appears the Darwin/OS X dynamic linker won't
10 # satisfy runtime link dependencies in those libraries from libraries
11 # imported by our library, and it uses a symbol from libiconv without
12 # actually linking the library to itself. Awesome.
13 package MY;
14 sub test_via_harness {
15     my($self, $perl, $tests) = @_;
16     local $_ = $self->SUPER::test_via_harness($perl, $tests);
17     s/PERL_DL_NONLAZY=1//g if $^O eq 'darwin';
18     return $_;
19 }
20
21 sub test_via_script {
22     my($self, $perl, $tests) = @_;
23     local $_ = $self->SUPER::test_via_script($perl, $tests);
24     s/PERL_DL_NONLAZY=1//g if $^O eq 'darwin';
25     return $_;
26 }
27
28 package main;
29
30 chomp(my $fusever = `pkg-config --modversion fuse 2> /dev/null`);
31 # Required for refuse on NetBSD
32 if (!$fusever && $^O eq 'netbsd') {
33     chomp($fusever = `fusermount -V`);
34     $fusever =~ s/^.*?version:\s+//;
35 }
36
37 unless ($fusever) {
38     # make CPANPLUS happy and don't report errors if fuse isn't installed
39     my $explanation;
40     if ($^O eq 'linux') {
41         if (-e '/etc/debian_version') {
42             $explanation = 'You need to install "libfuse-dev" to provide build support for this module';
43         }
44         elsif (-e '/etc/redhat-release') {
45             $explanation = 'You need to install "fuse-devel" to provide build support for this module';
46         }
47         else {
48             $explanation = 'I don\'t know your Linux distribution, but please install the FUSE libraries and headers to build this module';
49         }
50     }
51     elsif ($^O eq 'freebsd') {
52         $explanation = 'You need to install the "fusefs-libs" package from ports to support this module';
53     }
54     elsif ($^O eq 'netbsd') {
55         $explanation = 'Could not find librefuse? Maybe install "perfuse" from pkgsrc, or upgrade to newer NetBSD';
56     }
57     elsif ($^O eq 'darwin') {
58         $explanation = 'Please install OSXFUSE from http://osxfuse.github.com/';
59     }
60     else {
61         $explanation = 'There is no FUSE support for your platform to our knowledge, sorry';
62     }
63     die("Cannot build for platform: $^O\n", $explanation, "\n");
64 }
65 if ($fusever && $fusever + 0 < 2.6) {
66     die "FUSE API is ", $fusever, ", must be 2.6 or later\n";
67 } else {
68     warn "fuse version found: ", $fusever, "\n";
69 }
70
71 chomp(my $inc = `pkg-config --cflags-only-I fuse 2> /dev/null`);
72 chomp(my $libs = `pkg-config --libs-only-L fuse 2> /dev/null`);
73 chomp($libs .= `pkg-config --libs-only-l fuse 2> /dev/null` || (($^O eq 'netbsd') ? '-lrefuse' : '-lfuse'));
74 # Needed for Fuse on OS X 10.6, due to 10.6 and up always using the 64-bit
75 # inode structs; unfortunately MacFuse doesn't just do the right thing
76 # on its own. (Not applicable for OSXFUSE; it uses a new SONAME, so we
77 # don't have to worry about conflicts/compatibility, it "just works".)
78 if ($^O eq 'darwin' && (uname())[2] =~ /^1[01]\./) {
79     $libs =~ s/-lfuse\b/-lfuse_ino64/;
80 }
81 chomp(my $def = '-Wall -DFUSE_USE_VERSION=26 ' . `pkg-config --cflags-only-other fuse 2> /dev/null` || '-D_FILE_OFFSET_BITS=64');
82 chomp($def .= `pkg-config --libs-only-other fuse 2> /dev/null`);
83 $def .= ' -DPERL_HAS_64BITINT' if $Config{'use64bitint'};
84
85 WriteMakefile(
86     'NAME'          => 'Fuse',
87     'VERSION_FROM'  => 'Fuse.pm', # finds $VERSION
88     'PREREQ_PM'     => { # e.g., Module::Name => 1.1
89         'Lchown'            => 0,
90         'Filesys::Statvfs'  => 0,
91         'Unix::Mknod'       => 0,
92     },
93     ($] >= 5.005 ?  ## Add these new keywords supported since 5.005
94        (ABSTRACT_FROM   => 'Fuse.pm', # retrieve abstract from module
95         AUTHOR          => 'Mark Glines <mark@glines.org>') : ()),
96     ($ExtUtils::MakeMaker::VERSION < 6.3002 ? () : (
97         'LICENSE' => 'LGPL_2_1',
98     )),
99     ($ExtUtils::MakeMaker::VERSION < 6.46 ? () : (
100         META_MERGE => {
101             resources => {
102                 license => 'http://www.gnu.org/licenses/lgpl-2.1.html',
103                 bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Fuse',
104                 repository => 'http://github.com/dpavlin/perl-fuse'
105             },
106         })
107     ),
108     'LIBS'          => '-lpthread ' . $libs, # e.g., '-lm'
109     'DEFINE'        => $def, # e.g., '-DHAVE_SOMETHING'
110     'OPTIMIZE'      => '-g -ggdb',
111     # Insert -I. if you add *.h files later:
112     'INC'           => $inc, # e.g., '-I/usr/include/other'
113     # Un-comment this if you add C files to link with later:
114     'OBJECT'        => 'Fuse$(OBJ_EXT)', # link all the C files too
115 );
116
117 sub MY::postamble {
118     return <<'MAKE_MORE';
119
120 cpan:
121         make clean
122         rm -f Fuse-*.tar.gz
123         perl Makefile.PL
124         make dist
125         make disttest
126         @echo
127         @echo -n "Upload" Fuse-*.tar.gz "to CPAN? [y/N]:"
128         @read upload && test "$$upload" == "y" && cpan-upload -verbose Fuse-*.tar.gz
129
130
131
132 sf:
133         svn2cvs.pl file:///home/dpavlin/private/svn/fuse/perl-llin :ext:dpavlin@fuse.cvs.sourceforge.net:/cvsroot/fuse perl
134
135 MAKE_MORE
136 };
137
138 # vim: ts=4 ai et hls