fixwin32mak.pl 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #
  2. # fixwin32mak.pl ::: Apache/Win32 maintanace program
  3. #
  4. # This program, launched from the build/ directory, replaces all nasty absoulute paths
  5. # in the win32 .mak files with the appropriate relative root.
  6. #
  7. # Run this program prior to committing or packaging any newly exported make files.
  8. use Cwd;
  9. use IO::File;
  10. use File::Find;
  11. $root = cwd;
  12. # ignore our own direcory (allowing us to move into any parallel tree)
  13. $root =~ s|^.:(.*)?$|cd "$1|;
  14. $root =~ s|/|\\\\|g;
  15. print "Testing " . $root . "\n";
  16. find(\&fixcwd, '.');
  17. sub fixcwd {
  18. if (m|.mak$|) {
  19. $thisroot = $File::Find::dir;
  20. $thisroot =~ s|^./(.*)$|$1|;
  21. $thisroot =~ s|/|\\\\|g;
  22. $thisroot = $root . "\\\\" . $thisroot;
  23. $oname = $_;
  24. $tname = '.#' . $_;
  25. $verchg = 0;
  26. #print "Processing " . $thisroot . " of " . $_ . "\n";
  27. $srcfl = new IO::File $_, "r" || die;
  28. $dstfl = new IO::File $tname, "w" || die;
  29. while ($src = <$srcfl>) {
  30. if ($src =~ m|^\s*($root[^\"]*)\".*$|) {
  31. #print "Found " . $1 . "\"\n";
  32. $orig = $thisroot;
  33. $repl = "cd \".";
  34. while (!($src =~ s|$orig|$repl|)) {
  35. #print "Tried replacing " . $orig . " with " . $repl . "\n";
  36. if (!($orig =~ s|^(.*)\\\\[^\\]+$|$1|)) {
  37. break;
  38. }
  39. $repl .= "\\..";
  40. }
  41. #print "Replaced " . $orig . " with " . $repl . "\n";
  42. $verchg = -1;
  43. }
  44. print $dstfl $src;
  45. }
  46. undef $srcfl;
  47. undef $dstfl;
  48. if ($verchg) {
  49. unlink $oname || die;
  50. rename $tname, $oname || die;
  51. print "Corrected absolute paths within " . $oname . " in " . $File::Find::dir . "\n";
  52. }
  53. else {
  54. unlink $tname;
  55. }
  56. $dname = $oname;
  57. $dname =~ s/.mak$/.dsp/;
  58. @dstat = stat($dname);
  59. @ostat = stat($oname);
  60. if ($ostat[9] && $dstat[9] && ($ostat[9] != $dstat[9])) {
  61. @onames = ($oname);
  62. utime $dstat[9], $dstat[9], @onames;
  63. print "Touched datestamp for " . $oname . " in " . $File::Find::dir . "\n";
  64. }
  65. $oname =~ s/.mak$/.dep/;
  66. @ostat = stat($oname);
  67. if ($ostat[9] && $dstat[9] && ($ostat[9] != $dstat[9])) {
  68. @onames = ($oname);
  69. utime $dstat[9], $dstat[9], @onames;
  70. print "Touched datestamp for " . $oname . " in " . $File::Find::dir . "\n";
  71. }
  72. }
  73. }