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