perl / Makefile.PLon commit Merge branch 'js/commit-slab-decl-fix' (7a3ea66)
   1use strict;
   2use warnings;
   3use ExtUtils::MakeMaker;
   4use Getopt::Long;
   5use File::Find;
   6
   7# Don't forget to update the perl/Makefile, too.
   8# Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
   9
  10# Sanity: die at first unknown option
  11Getopt::Long::Configure qw/ pass_through /;
  12
  13my $localedir = '';
  14GetOptions("localedir=s" => \$localedir);
  15
  16sub MY::postamble {
  17        return <<'MAKE_FRAG';
  18instlibdir:
  19        @echo '$(INSTALLSITELIB)'
  20
  21ifneq (,$(DESTDIR))
  22ifeq (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)
  26endif
  27endif
  28
  29MAKE_FRAG
  30}
  31
  32# Find all the .pm files in "Git/" and Git.pm
  33my %pm;
  34find sub {
  35        return unless /\.pm$/;
  36
  37        # sometimes File::Find prepends a ./  Strip it.
  38        my $pm_path = $File::Find::name;
  39        $pm_path =~ s{^\./}{};
  40
  41        $pm{$pm_path} = '$(INST_LIBDIR)/'.$pm_path;
  42}, "Git", "Git.pm";
  43
  44
  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.
  47if ( !eval { require Error } || $Error::VERSION < 0.15009) {
  48        $pm{'private-Error.pm'} = '$(INST_LIBDIR)/Error.pm';
  49}
  50
  51# redirect stdout, otherwise the message "Writing perl.mak for Git"
  52# disrupts the output for the target 'instlibdir'
  53open STDOUT, ">&STDERR";
  54
  55WriteMakefile(
  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'
  62);