1 package ExtUtils::Command::MM;
7 use vars qw($VERSION @ISA @EXPORT);
10 @EXPORT = qw(test_harness pod2man perllocal_install uninstall
11 warn_if_old_packlist);
14 my $Is_VMS = $^O eq 'VMS';
18 ExtUtils::Command::MM - Commands for the MM's to use in Makefiles
22 perl "-MExtUtils::Command::MM" -e "function" "--" arguments...
27 B<FOR INTERNAL USE ONLY!> The interface is not stable.
29 ExtUtils::Command::MM encapsulates code which would otherwise have to
30 be done with large "one" liners.
32 Any $(FOO) used in the examples are make variables, not Perl.
38 test_harness($verbose, @test_libs);
40 Runs the tests on @ARGV via Test::Harness passing through the $verbose
41 flag. Any @test_libs will be unshifted onto the test's @INC.
43 @test_libs are run in alphabetical order.
48 require Test::Harness;
51 $Test::Harness::verbose = shift;
54 unshift @INC, map { File::Spec->rel2abs($_) } @_;
55 Test::Harness::runtests(sort { lc $a cmp lc $b } @ARGV);
62 pod2man( '--option=value',
63 $podfile1 => $manpage1,
64 $podfile2 => $manpage2,
70 pod2man() is a function performing most of the duties of the pod2man
71 program. Its arguments are exactly the same as pod2man as of 5.8.0
74 --perm_rw octal permission to set the resulting manpage to
81 If no arguments are given to pod2man it will read from @ARGV.
91 # We will cheat and just use Getopt::Long. We fool it by putting
92 # our arguments into @ARGV. Should be safe.
93 local @ARGV = @_ ? @_ : @ARGV;
94 Getopt::Long::config ('bundling_override');
95 Getopt::Long::GetOptions (\%options,
96 'section|s=s', 'release|r=s', 'center|c=s',
97 'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
98 'fixedbolditalic=s', 'official|o', 'quotes|q=s', 'lax|l',
99 'name|n=s', 'perm_rw:i'
102 # If there's no files, don't bother going further.
103 return 0 unless @ARGV;
105 # Official sets --center, but don't override things explicitly set.
106 if ($options{official} && !defined $options{center}) {
107 $options{center} = 'Perl Programmers Reference Guide';
110 # This isn't a valid Pod::Man option and is only accepted for backwards
112 delete $options{lax};
114 my $parser = Pod::Man->new(%options);
116 do {{ # so 'next' works
117 my ($pod, $man) = splice(@ARGV, 0, 2);
119 next if ((-e $man) &&
120 (-M $man < -M $pod) &&
121 (-M $man < -M "Makefile"));
123 print "Manifying $man\n";
125 $parser->parse_from_file($pod, $man)
126 or do { warn("Could not install $man\n"); next };
128 if (length $options{perm_rw}) {
129 chmod(oct($options{perm_rw}), $man)
130 or do { warn("chmod $options{perm_rw} $man: $!\n"); next };
138 =item B<warn_if_old_packlist>
140 perl "-MExtUtils::Command::MM" -e warn_if_old_packlist <somefile>
142 Displays a warning that an old packlist file was found. Reads the
147 sub warn_if_old_packlist {
148 my $packlist = $ARGV[0];
150 return unless -f $packlist;
151 print <<"PACKLIST_WARNING";
152 WARNING: I have found an old package in
154 Please make sure the two installations are not conflicting
160 =item B<perllocal_install>
162 perl "-MExtUtils::Command::MM" -e perllocal_install
163 <type> <module name> <key> <value> ...
165 # VMS only, key/value pairs come on STDIN
166 perl "-MExtUtils::Command::MM" -e perllocal_install
167 <type> <module name> < <key> <value> ...
169 Prints a fragment of POD suitable for appending to perllocal.pod.
170 Arguments are read from @ARGV.
172 'type' is the type of what you're installing. Usually 'Module'.
174 'module name' is simply the name of your module. (Foo::Bar)
176 Key/value pairs are extra information about the module. Fields include:
178 installed into which directory your module was out into
179 LINKTYPE dynamic or static linking
180 VERSION module version number
181 EXE_FILES any executables installed in a space seperated
186 sub perllocal_install {
187 my($type, $name) = splice(@ARGV, 0, 2);
189 # VMS feeds args as a piped file on STDIN since it usually can't
190 # fit all the args on a single command line.
191 @ARGV = split /\|/, <STDIN> if $Is_VMS;
194 $pod = sprintf <<POD, scalar localtime;
195 =head2 %s: C<$type> L<$name|$name>
202 my($key, $val) = splice(@ARGV, 0, 2);
222 perl "-MExtUtils::Command::MM" -e uninstall <packlist>
224 A wrapper around ExtUtils::Install::uninstall(). Warns that
225 uninstallation is deprecated and doesn't actually perform the
231 my($packlist) = shift;
233 require ExtUtils::Install;
237 Uninstall is unsafe and deprecated, the uninstallation was not performed.
238 We will show what would have been done.
242 ExtUtils::Install::uninstall($packlist, 1, 1);
246 Uninstall is unsafe and deprecated, the uninstallation was not performed.
247 Please check the list above carefully, there may be errors.
248 Remove the appropriate files manually.
249 Sorry for the inconvenience.