This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Patch unit tests to explicitly insert "." into @INC when needed.
[perl5.git] / cpan / podlators / Makefile.PL
1 # Build instructions for podlators.
2 #
3 # We need to use ExtUtils::MakeMaker since this module is part of Perl core,
4 # which only supports that build method, and because it is a dependency of
5 # other build systems like Module::Build.
6 #
7 # Copyright 1999, 2000, 2001, 2008, 2010, 2012, 2014, 2015, 2016
8 #     Russ Allbery <rra@cpan.org>
9 #
10 # This program is free software; you may redistribute it and/or modify it
11 # under the same terms as Perl itself.
12
13 use 5.006;
14 use strict;
15 use warnings;
16
17 use Config;
18 use ExtUtils::MakeMaker;
19 use File::Spec;
20
21 # Generate full paths for scripts distributed in the bin directory.  Appends
22 # the .com extension to scripts on VMS, unless they already have the .PL
23 # extension.
24 #
25 # @scripts - List of script names
26 #
27 # Returns: (Array) List of relative paths from top of distribution
28 #          (Scalar) Space-separated relative paths from top of distribution
29 sub scripts {
30     my (@scripts) = @_;
31     my @paths = map { File::Spec->catfile('scripts', $_) } @scripts;
32     if ($^O eq 'VMS') {
33         @paths = map { m{ [.] PL \z }xms ? $_ : $_ . '.com' } @paths;
34     }
35     return wantarray ? @paths : join(q{ }, @paths);
36 }
37
38 # Generate an association between a source file and a destination man page for
39 # non-module man pages.  ExtUtils::MakeMaker only really understands how to
40 # generate man pages for modules, so we need to help it for the script man
41 # pages and (particularly) the perlpodstyle man page.
42 #
43 # $directory - Directory containing the file
44 # $file      - File containing POD in that directory
45 #
46 # Returns: The path to the file with POD and the output man page, as a pair
47 sub man1pod {
48     my ($directory, $file) = @_;
49
50     # Build the base name of the file by stripping any *.pod or *.PL suffix.
51     my $basename = $file;
52     $basename =~ s{ [.] (?: pod | PL ) \z }{}xms;
53
54     # Determine the output file name for the generated man page.
55     my $outname = $basename . q{.} . $Config{man1ext};
56     my $outpath = File::Spec->catfile(qw(blib man1), $outname);
57     return (File::Spec->catfile($directory, $file), $outpath);
58 }
59
60 # The hash of all the metadata.  This will be modified before WriteMakefile to
61 # remove keys not supported by the local version of ExtUtils::MakeMaker.
62 my %metadata = (
63     NAME             => 'Pod',
64     DISTNAME         => 'podlators',
65     ABSTRACT         => 'Convert POD data to various other formats',
66     AUTHOR           => 'Russ Allbery <rra@cpan.org>',
67     LICENSE          => 'perl_5',
68     EXE_FILES        => [scripts('pod2text', 'pod2man')],
69     VERSION_FROM     => 'lib/Pod/Man.pm',
70     MIN_PERL_VERSION => '5.006',
71
72     # Use *.PL files to generate the driver scripts so that we get the correct
73     # invocation of Perl on non-UNIX platforms.
74     PL_FILES => {
75         scripts('pod2man.PL', 'pod2man'), scripts('pod2text.PL', 'pod2text'),
76     },
77
78     # Override the files that generate section 1 man pages.
79     MAN1PODS => {
80         man1pod('scripts', 'pod2man.PL'),
81         man1pod('scripts', 'pod2text.PL'),
82
83         # Perl core uses a separate copy in the top-level pod directory.
84         ($ENV{PERL_CORE} ? () : man1pod('pod', 'perlpodstyle.pod')),
85     },
86
87     # Clean some additional files.
88     clean     => { FILES => File::Spec->catdir('t',    'tmp') },
89     realclean => { FILES => scalar(scripts('pod2text', 'pod2man')) },
90
91     # Dependencies on other modules.
92     PREREQ_PM => {
93         'Encode'      => 0,
94         'Pod::Simple' => 3.06,
95     },
96
97     # Older versions of ExtUtils::MakeMaker don't pick up nested test
98     # directories by default.
99     test => { TESTS => 't/*/*.t' },
100
101     # For older versions of Perl, we have to force installation into the Perl
102     # module directories since site modules did not take precedence over core
103     # modules.
104     INSTALLDIRS => $] lt '5.011' ? 'perl' : 'site',
105
106     # Additional metadata.
107     META_ADD => {
108         'meta-spec' => { version => 2 },
109         resources   => {
110             bugtracker => {
111                 mailto => 'bug-podlators@rt.cpan.org',
112                 web => 'https://rt.cpan.org/Dist/Display.html?Name=podlators',
113             },
114             homepage   => 'http://www.eyrie.org/~eagle/software/podlators/',
115             repository => {
116                 url  => 'git://github.com/rra/podlators.git',
117                 web  => 'https://github.com/rra/podlators',
118                 type => 'git',
119             },
120         },
121     },
122 );
123
124 # Remove keys that aren't supported by this version of ExtUtils::MakeMaker.
125 # This hash maps keys to the minimum supported version.
126 my %supported = (
127     LICENSE          => 6.31,
128     META_ADD         => 6.46,
129     MIN_PERL_VERSION => 6.48,
130 );
131 for my $key (keys(%supported)) {
132     if ($ExtUtils::MakeMaker::VERSION < $supported{$key}) {
133         delete $metadata{$key};
134     }
135 }
136
137 # Generate the actual Makefile.  Pick an arbitrary module to pull the version
138 # from, since they should all have the same version.
139 WriteMakefile(%metadata);