1 package ExtUtils::Command::MM;
9 our @ISA = qw(Exporter);
11 our @EXPORT = qw(test_harness pod2man perllocal_install uninstall
12 warn_if_old_packlist);
13 our $VERSION = '6.52';
15 my $Is_VMS = $^O eq 'VMS';
20 ExtUtils::Command::MM - Commands for the MM's to use in Makefiles
24 perl "-MExtUtils::Command::MM" -e "function" "--" arguments...
29 B<FOR INTERNAL USE ONLY!> The interface is not stable.
31 ExtUtils::Command::MM encapsulates code which would otherwise have to
32 be done with large "one" liners.
34 Any $(FOO) used in the examples are make variables, not Perl.
40 test_harness($verbose, @test_libs);
42 Runs the tests on @ARGV via Test::Harness passing through the $verbose
43 flag. Any @test_libs will be unshifted onto the test's @INC.
45 @test_libs are run in alphabetical order.
50 require Test::Harness;
53 $Test::Harness::verbose = shift;
55 # Because Windows doesn't do this for us and listing all the *.t files
56 # out on the command line can blow over its exec limit.
57 require ExtUtils::Command;
58 my @argv = ExtUtils::Command::expand_wildcards(@ARGV);
61 unshift @INC, map { File::Spec->rel2abs($_) } @_;
62 Test::Harness::runtests(sort { lc $a cmp lc $b } @argv);
69 pod2man( '--option=value',
70 $podfile1 => $manpage1,
71 $podfile2 => $manpage2,
77 pod2man() is a function performing most of the duties of the pod2man
78 program. Its arguments are exactly the same as pod2man as of 5.8.0
81 --perm_rw octal permission to set the resulting manpage to
88 If no arguments are given to pod2man it will read from @ARGV.
90 If Pod::Man is unavailable, this function will warn and return undef.
95 local @ARGV = @_ ? @_ : @ARGV;
99 if( !eval { require Pod::Man } ) {
100 warn "Pod::Man is not available: $@".
101 "Man pages will not be generated during this install.\n";
105 require Getopt::Long;
107 # We will cheat and just use Getopt::Long. We fool it by putting
108 # our arguments into @ARGV. Should be safe.
110 Getopt::Long::config ('bundling_override');
111 Getopt::Long::GetOptions (\%options,
112 'section|s=s', 'release|r=s', 'center|c=s',
113 'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
114 'fixedbolditalic=s', 'official|o', 'quotes|q=s', 'lax|l',
115 'name|n=s', 'perm_rw=i'
118 # If there's no files, don't bother going further.
119 return 0 unless @ARGV;
121 # Official sets --center, but don't override things explicitly set.
122 if ($options{official} && !defined $options{center}) {
123 $options{center} = q[Perl Programmer's Reference Guide];
126 # This isn't a valid Pod::Man option and is only accepted for backwards
128 delete $options{lax};
130 do {{ # so 'next' works
131 my ($pod, $man) = splice(@ARGV, 0, 2);
133 next if ((-e $man) &&
134 (-M $man < -M $pod) &&
135 (-M $man < -M "Makefile"));
137 print "Manifying $man\n";
139 my $parser = Pod::Man->new(%options);
140 $parser->parse_from_file($pod, $man)
141 or do { warn("Could not install $man\n"); next };
143 if (exists $options{perm_rw}) {
144 chmod(oct($options{perm_rw}), $man)
145 or do { warn("chmod $options{perm_rw} $man: $!\n"); next };
153 =item B<warn_if_old_packlist>
155 perl "-MExtUtils::Command::MM" -e warn_if_old_packlist <somefile>
157 Displays a warning that an old packlist file was found. Reads the
162 sub warn_if_old_packlist {
163 my $packlist = $ARGV[0];
165 return unless -f $packlist;
166 print <<"PACKLIST_WARNING";
167 WARNING: I have found an old package in
169 Please make sure the two installations are not conflicting
175 =item B<perllocal_install>
177 perl "-MExtUtils::Command::MM" -e perllocal_install
178 <type> <module name> <key> <value> ...
180 # VMS only, key|value pairs come on STDIN
181 perl "-MExtUtils::Command::MM" -e perllocal_install
182 <type> <module name> < <key>|<value> ...
184 Prints a fragment of POD suitable for appending to perllocal.pod.
185 Arguments are read from @ARGV.
187 'type' is the type of what you're installing. Usually 'Module'.
189 'module name' is simply the name of your module. (Foo::Bar)
191 Key/value pairs are extra information about the module. Fields include:
193 installed into which directory your module was out into
194 LINKTYPE dynamic or static linking
195 VERSION module version number
196 EXE_FILES any executables installed in a space seperated
201 sub perllocal_install {
202 my($type, $name) = splice(@ARGV, 0, 2);
204 # VMS feeds args as a piped file on STDIN since it usually can't
205 # fit all the args on a single command line.
206 my @mod_info = $Is_VMS ? split /\|/, <STDIN>
210 $pod = sprintf <<POD, scalar localtime;
211 =head2 %s: C<$type> L<$name|$name>
218 my($key, $val) = splice(@mod_info, 0, 2);
238 perl "-MExtUtils::Command::MM" -e uninstall <packlist>
240 A wrapper around ExtUtils::Install::uninstall(). Warns that
241 uninstallation is deprecated and doesn't actually perform the
247 my($packlist) = shift @ARGV;
249 require ExtUtils::Install;
253 Uninstall is unsafe and deprecated, the uninstallation was not performed.
254 We will show what would have been done.
258 ExtUtils::Install::uninstall($packlist, 1, 1);
262 Uninstall is unsafe and deprecated, the uninstallation was not performed.
263 Please check the list above carefully, there may be errors.
264 Remove the appropriate files manually.
265 Sorry for the inconvenience.