Various changes to tests and Makefile.
[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 unless ($fusever) {
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     die("No support for os: $^O\n",
40         "You need to have fuse-dev (or similar) package installed and have sufficient permissions in order to install this module\n",
41         $^O eq 'darwin' ? ("One option on Mac is http://code.google.com/p/macfuse/\n") : (),
42     );
43 }
44 if ($fusever && $fusever + 0 < 2.6) {
45     die "FUSE API is ", $fusever, ", must be 2.6 or later\n";
46 } else {
47     warn "fuse version found: ", $fusever, "\n";
48 }
49
50 chomp(my $inc = `pkg-config --cflags-only-I fuse 2> /dev/null` || '-I ../include');
51 chomp(my $libs = `pkg-config --libs-only-L fuse 2> /dev/null`);
52 chomp($libs .= `pkg-config --libs-only-l fuse 2> /dev/null` || (($^O eq 'netbsd') ? '-lrefuse' : '-lfuse'));
53 if ($^O eq 'darwin' && (uname())[2] =~ /^10\./) {
54     $libs =~ s/-lfuse/-lfuse_ino64/;
55 }
56 chomp(my $def = '-Wall -g -ggdb -DFUSE_USE_VERSION=26 ' . `pkg-config --cflags-only-other fuse 2> /dev/null` || '-D_FILE_OFFSET_BITS=64');
57 chomp($def .= `pkg-config --libs-only-other fuse 2> /dev/null`);
58 $def .= ' -DPERL_HAS_64BITINT' if $Config{'use64bitint'};
59
60 WriteMakefile(
61     'NAME'          => 'Fuse',
62     'VERSION_FROM'  => 'Fuse.pm', # finds $VERSION
63     'PREREQ_PM'     => {}, # e.g., Module::Name => 1.1
64     ($] >= 5.005 ?  ## Add these new keywords supported since 5.005
65        (ABSTRACT_FROM   => 'Fuse.pm', # retrieve abstract from module
66         AUTHOR          => 'Mark Glines <mark@glines.org>') : ()),
67     ($ExtUtils::MakeMaker::VERSION < 6.46 ? () : (
68         META_MERGE => {
69             resources => {
70                 bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Fuse',
71                 repository => 'http://github.com/dpavlin/perl-fuse'
72             },
73         })
74     ),
75         'LIBS'          => '-lpthread ' . $libs, # e.g., '-lm'
76         'DEFINE'        => $def, # e.g., '-DHAVE_SOMETHING'
77         # Insert -I. if you add *.h files later:
78         'INC'           => $inc, # e.g., '-I/usr/include/other'
79         # Un-comment this if you add C files to link with later:
80         'OBJECT'        => 'Fuse$(OBJ_EXT)', # link all the C files too
81 );
82
83 sub MY::postamble {
84     return <<'MAKE_MORE';
85
86 cpan:
87         make clean
88         rm -f Fuse-*.tar.gz
89         perl Makefile.PL
90         make dist
91         make disttest
92         @echo
93         @echo -n "Upload" Fuse-*.tar.gz "to CPAN? [y/N]:"
94         @read upload && test "$$upload" == "y" && cpan-upload -verbose Fuse-*.tar.gz
95
96
97
98 sf:
99         svn2cvs.pl file:///home/dpavlin/private/svn/fuse/perl-llin :ext:dpavlin@fuse.cvs.sourceforge.net:/cvsroot/fuse perl
100
101 MAKE_MORE
102 };
103
104 # vim: ts=4 ai et hls