Merge branch 'nd/grep-true-path' into maint
[git/jnareb-git.git] / perl / Makefile.PL
blob3f29ba98a6fcaa6ad023123b68cd6f6b5b9250dd
1 use strict;
2 use warnings;
3 use ExtUtils::MakeMaker;
4 use Getopt::Long;
5 use File::Find;
7 # Don't forget to update the perl/Makefile, too.
8 # Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
10 # Sanity: die at first unknown option
11 Getopt::Long::Configure qw/ pass_through /;
13 my $localedir = '';
14 GetOptions("localedir=s" => \$localedir);
16 sub MY::postamble {
17         return <<'MAKE_FRAG';
18 instlibdir:
19         @echo '$(INSTALLSITELIB)'
21 ifneq (,$(DESTDIR))
22 ifeq (0,$(shell expr '$(MM_VERSION)' '>' 6.10))
23 $(error ExtUtils::MakeMaker version "$(MM_VERSION)" is older than 6.11 and so \
24         is likely incompatible with the DESTDIR mechanism.  Try setting \
25         NO_PERL_MAKEMAKER=1 instead)
26 endif
27 endif
29 MAKE_FRAG
32 # Find all the .pm files in "Git/" and Git.pm
33 my %pm;
34 find sub {
35         return unless /\.pm$/;
37         # sometimes File::Find prepends a ./  Strip it.
38         my $pm_path = $File::Find::name;
39         $pm_path =~ s{^\./}{};
41         $pm{$pm_path} = '$(INST_LIBDIR)/'.$pm_path;
42 }, "Git", "Git.pm";
45 # We come with our own bundled Error.pm. It's not in the set of default
46 # Perl modules so install it if it's not available on the system yet.
47 if ( !eval { require Error } || $Error::VERSION < 0.15009) {
48         $pm{'private-Error.pm'} = '$(INST_LIBDIR)/Error.pm';
51 # redirect stdout, otherwise the message "Writing perl.mak for Git"
52 # disrupts the output for the target 'instlibdir'
53 open STDOUT, ">&STDERR";
55 WriteMakefile(
56         NAME            => 'Git',
57         VERSION_FROM    => 'Git.pm',
58         PM              => \%pm,
59         PM_FILTER       => qq[\$(PERL) -pe "s<\\Q++LOCALEDIR++\\E><$localedir>"],
60         MAKEFILE        => 'perl.mak',
61         INSTALLSITEMAN3DIR => '$(SITEPREFIX)/share/man/man3'