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.76';
15 my $Is_VMS = $^O eq 'VMS';
17 eval { require Time::HiRes; die unless Time::HiRes->can("stat"); };
19 sub { [ stat($_[0])]->[9] } :
20 sub { [Time::HiRes::stat($_[0])]->[9] } ;
24 ExtUtils::Command::MM - Commands for the MM's to use in Makefiles
28 perl "-MExtUtils::Command::MM" -e "function" "--" arguments...
33 B<FOR INTERNAL USE ONLY!> The interface is not stable.
35 ExtUtils::Command::MM encapsulates code which would otherwise have to
36 be done with large "one" liners.
38 Any $(FOO) used in the examples are make variables, not Perl.
44 test_harness($verbose, @test_libs);
46 Runs the tests on @ARGV via Test::Harness passing through the $verbose
47 flag. Any @test_libs will be unshifted onto the test's @INC.
49 @test_libs are run in alphabetical order.
54 require Test::Harness;
57 $Test::Harness::verbose = shift;
59 # Because Windows doesn't do this for us and listing all the *.t files
60 # out on the command line can blow over its exec limit.
61 require ExtUtils::Command;
62 my @argv = ExtUtils::Command::expand_wildcards(@ARGV);
65 unshift @INC, map { File::Spec->rel2abs($_) } @_;
66 Test::Harness::runtests(sort { lc $a cmp lc $b } @argv);
73 pod2man( '--option=value',
74 $podfile1 => $manpage1,
75 $podfile2 => $manpage2,
81 pod2man() is a function performing most of the duties of the pod2man
82 program. Its arguments are exactly the same as pod2man as of 5.8.0
85 --perm_rw octal permission to set the resulting manpage to
92 If no arguments are given to pod2man it will read from @ARGV.
94 If Pod::Man is unavailable, this function will warn and return undef.
99 local @ARGV = @_ ? @_ : @ARGV;
103 if( !eval { require Pod::Man } ) {
104 warn "Pod::Man is not available: $@".
105 "Man pages will not be generated during this install.\n";
109 require Getopt::Long;
111 # We will cheat and just use Getopt::Long. We fool it by putting
112 # our arguments into @ARGV. Should be safe.
114 Getopt::Long::config ('bundling_override');
115 Getopt::Long::GetOptions (\%options,
116 'section|s=s', 'release|r=s', 'center|c=s',
117 'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
118 'fixedbolditalic=s', 'official|o', 'quotes|q=s', 'lax|l',
119 'name|n=s', 'perm_rw=i'
122 # If there's no files, don't bother going further.
123 return 0 unless @ARGV;
125 # Official sets --center, but don't override things explicitly set.
126 if ($options{official} && !defined $options{center}) {
127 $options{center} = q[Perl Programmer's Reference Guide];
130 # This isn't a valid Pod::Man option and is only accepted for backwards
132 delete $options{lax};
134 do {{ # so 'next' works
135 my ($pod, $man) = splice(@ARGV, 0, 2);
137 next if ((-e $man) &&
138 (mtime($man) > mtime($pod)) &&
139 (mtime($man) > mtime("Makefile")));
141 print "Manifying $man\n";
143 my $parser = Pod::Man->new(%options);
144 $parser->parse_from_file($pod, $man)
145 or do { warn("Could not install $man\n"); next };
147 if (exists $options{perm_rw}) {
148 chmod(oct($options{perm_rw}), $man)
149 or do { warn("chmod $options{perm_rw} $man: $!\n"); next };
157 =item B<warn_if_old_packlist>
159 perl "-MExtUtils::Command::MM" -e warn_if_old_packlist <somefile>
161 Displays a warning that an old packlist file was found. Reads the
166 sub warn_if_old_packlist {
167 my $packlist = $ARGV[0];
169 return unless -f $packlist;
170 print <<"PACKLIST_WARNING";
171 WARNING: I have found an old package in
173 Please make sure the two installations are not conflicting
179 =item B<perllocal_install>
181 perl "-MExtUtils::Command::MM" -e perllocal_install
182 <type> <module name> <key> <value> ...
184 # VMS only, key|value pairs come on STDIN
185 perl "-MExtUtils::Command::MM" -e perllocal_install
186 <type> <module name> < <key>|<value> ...
188 Prints a fragment of POD suitable for appending to perllocal.pod.
189 Arguments are read from @ARGV.
191 'type' is the type of what you're installing. Usually 'Module'.
193 'module name' is simply the name of your module. (Foo::Bar)
195 Key/value pairs are extra information about the module. Fields include:
197 installed into which directory your module was out into
198 LINKTYPE dynamic or static linking
199 VERSION module version number
200 EXE_FILES any executables installed in a space seperated
205 sub perllocal_install {
206 my($type, $name) = splice(@ARGV, 0, 2);
208 # VMS feeds args as a piped file on STDIN since it usually can't
209 # fit all the args on a single command line.
210 my @mod_info = $Is_VMS ? split /\|/, <STDIN>
214 $pod = sprintf <<POD, scalar localtime;
215 =head2 %s: C<$type> L<$name|$name>
222 my($key, $val) = splice(@mod_info, 0, 2);
242 perl "-MExtUtils::Command::MM" -e uninstall <packlist>
244 A wrapper around ExtUtils::Install::uninstall(). Warns that
245 uninstallation is deprecated and doesn't actually perform the
251 my($packlist) = shift @ARGV;
253 require ExtUtils::Install;
257 Uninstall is unsafe and deprecated, the uninstallation was not performed.
258 We will show what would have been done.
262 ExtUtils::Install::uninstall($packlist, 1, 1);
266 Uninstall is unsafe and deprecated, the uninstallation was not performed.
267 Please check the list above carefully, there may be errors.
268 Remove the appropriate files manually.
269 Sorry for the inconvenience.