Subject: | lack of PL_FILTER to compliment PM_FILTER |
While there is the PM_FILTER facility, there is nothing for .pl files along these same lines!
I needed to make a package that customizes the pm _and_ pl files during the pm_to_blib() phase and found a dead end, so I duplicated the pm_filter setup for pl_filter appropriately.
The patch attached implements the PL_FILTER feature and documents it exactly as PM_FILTER has been documented (in fact I literally duped and then s/PM/PL/gi as nessary).
I would really like to see this feature implemented upstream as I'd hate to have to get everyone who wants to use my package patch their EU::MM just to build it properly.
diff -ur ./Changes ../ExtUtils-MakeMaker-6.16/Changes
--- ./Changes 2003-08-18 04:40:00.000000000 -0400
+++ ../ExtUtils-MakeMaker-6.16/Changes 2003-09-06 08:24:40.000000000 -0400
@@ -1,3 +1,8 @@
+6.17 Sat Sep 6 08:00:00 EST 2003
+ * Adding in support for PL_FILTER which is a compliment to PM_FILTER
+ except for .pl files. [Kevin C. Krinke]
+ * Documented PL_FILTER in all the expected places. [Kevin C. Krinke]
+
6.16 Mon Aug 18 01:39:51 PDT 2003
* Fixing the max exec length for Windows to account for old
versions of nmake (the one you can download for free from MS).
diff -ur ./lib/ExtUtils/Install.pm ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/Install.pm
--- ./lib/ExtUtils/Install.pm 2003-06-05 04:04:31.000000000 -0400
+++ ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/Install.pm 2003-09-06 08:11:54.000000000 -0400
@@ -395,14 +395,15 @@
=item B<pm_to_blib>
pm_to_blib(\%from_to, $autosplit_dir);
- pm_to_blib(\%from_to, $autosplit_dir, $filter_cmd);
+ pm_to_blib(\%from_to, $autosplit_dir, $filter_cmd, $pl_filter_cmd);
Copies each key of %from_to to its corresponding value efficiently.
Filenames with the extension .pm are autosplit into the $autosplit_dir.
$filter_cmd is an optional shell command to run each .pm file through
prior to splitting and copying. Input is the contents of the module,
-output the new module contents.
+output the new module contents. $pl_filter_cmd is the same as the
+$fileter_cmd except that it works on .pl files instead of .pm files.
You can have an environment variable PERL_INSTALL_ROOT set which will
be prepended as a directory to each installed file (and directory).
@@ -410,7 +411,7 @@
=cut
sub pm_to_blib {
- my($fromto,$autodir,$pm_filter) = @_;
+ my($fromto,$autodir,$pm_filter,$pl_filter) = @_;
use File::Basename qw(dirname);
use File::Copy qw(copy);
@@ -459,8 +460,17 @@
run_filter($pm_filter, $from, $to);
print "$pm_filter <$from >$to\n";
} else {
- copy($from,$to);
- print "cp $from $to\n";
+ # When a pl_filter is defined, we need to run_filter just like with
+ # pm_filters. -- KCK, Sep. 6, 2003
+ my $need_pl_filtering = defined $pl_filter && length $pl_filter &&
+ $from =~ /\.pl$/;
+ if ($need_pl_filtering) {
+ run_filter($pl_filter, $from, $to);
+ print "$pl_filter <$from >$to\n";
+ } else {
+ copy($from,$to);
+ print "cp $from $to\n";
+ }
}
my($mode,$atime,$mtime) = (stat $from)[2,8,9];
utime($atime,$mtime+$Is_VMS,$to);
diff -ur ./lib/ExtUtils/MM_Unix.pm ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MM_Unix.pm
--- ./lib/ExtUtils/MM_Unix.pm 2003-08-14 21:28:42.000000000 -0400
+++ ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MM_Unix.pm 2003-09-06 07:51:43.000000000 -0400
@@ -486,7 +486,7 @@
for my $macro (qw/
FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
- LDFROM LINKTYPE PM_FILTER
+ LDFROM LINKTYPE PM_FILTER PL_FILTER
/ )
{
next unless defined $self->{$macro};
@@ -3256,7 +3256,7 @@
};
my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
-pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
+pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)', '\$(PL_FILTER)')
CODE
my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
diff -ur ./lib/ExtUtils/MakeMaker.pm ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MakeMaker.pm
--- ./lib/ExtUtils/MakeMaker.pm 2003-08-14 21:28:55.000000000 -0400
+++ ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MakeMaker.pm 2003-09-06 07:57:29.000000000 -0400
@@ -224,7 +224,7 @@
MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE
PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE
PERL_SRC PERM_RW PERM_RWX
- PL_FILES PM PM_FILTER PMLIBDIRS POLLUTE PPM_INSTALL_EXEC
+ PL_FILES PM PM_FILTER PL_FILTER PMLIBDIRS POLLUTE PPM_INSTALL_EXEC
PPM_INSTALL_SCRIPT PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ
SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
XS_VERSION clean depend dist dynamic_lib linkext macro realclean
@@ -1911,6 +1911,29 @@
Without the \\ before the #, we'd have the start of a Makefile comment,
and the macro would be incorrectly defined.
+=item PL_FILTER
+
+A filter program, in the traditional Unix sense (input from stdin, output
+to stdout) that is passed on each .pl file during the build (in the
+pm_to_blib() phase). It is empty by default, meaning no filtering is done.
+
+Great care is necessary when defining the command if quoting needs to be
+done. For instance, you would need to say:
+
+ {'PL_FILTER' => 'grep -v \\"^\\#\\"'}
+
+to remove all the leading coments on the fly during the build. The
+extra \\ are necessary, unfortunately, because this variable is interpolated
+within the context of a Perl program built on the command line, and double
+quotes are what is used with the -e switch to build that command line. The
+# is escaped for the Makefile, since what is going to be generated will then
+be:
+
+ PL_FILTER = grep -v \"^\#\"
+
+Without the \\ before the #, we'd have the start of a Makefile comment,
+and the macro would be incorrectly defined.
+
=item POLLUTE
Release 5.005 grandfathered old global symbol names by providing preprocessor