summaryrefslogtreecommitdiff
path: root/pm_filter
blob: 71f26fae8cfad62002bd304700460a02ac27c6df (plain)
  1. #!/usr/bin/perl -i -p
  2. BEGIN {
  3. $prefix=shift;
  4. $ver=shift;
  5. $libdir=shift;
  6. }
  7. if (/INSTALLDIR_AUTOREPLACE/) {
  8. $_=qq{our \$installdir="$prefix";};
  9. }
  10. elsif (/VERSION_AUTOREPLACE/) {
  11. $_=qq{our \$version="$ver";};
  12. }
  13. elsif (/^use lib/) {
  14. # The idea here is to figure out if the libdir the Makefile.PL
  15. # was configure to use is in perl's normal search path.
  16. # If not, hard code it into ikiwiki.
  17. if ((grep { $_ eq $libdir } @INC) &&
  18. (! exists $ENV{PERL5LIB} || ! length $ENV{PERL5LIB} ||
  19. $ENV{PERL5LIB} ne $libdir)) {
  20. $_="";
  21. }
  22. else {
  23. $_="use lib '$libdir';\n";
  24. }
  25. }
  26. elsif ($. == 1 && ($ENV{NOTAINT} || ! exists $ENV{NOTAINT}) && m{^(#!.*perl.*?) -T$}) {
  27. $_=qq{$1\n};
  28. }
  29. elsif (/^\$ENV{PATH}="(.*)";/) {
  30. $_="\$ENV{PATH}=\"$1:$prefix/bin\";\n";
  31. }