2
0

files.pl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/local/bin/perl
  2. #
  3. # used to generate the file MINFO for use by util/mk1mf.pl
  4. # It is basically a list of all variables from the passed makefile
  5. #
  6. while ($ARGV[0] =~ /^([^\s=]+)\s*=\s*(.*)$/)
  7. {
  8. $sym{$1} = $2;
  9. shift;
  10. }
  11. $s="";
  12. while (<>)
  13. {
  14. s|\R$||;
  15. s/#.*//;
  16. if (/^([^\s=]+)\s*=\s*(.*)$/)
  17. {
  18. $o="";
  19. ($s,$b)=($1,$2);
  20. for (;;)
  21. {
  22. if ($b =~ /\\$/)
  23. {
  24. $b=$`; # Keep what is before the backslash
  25. $o.=$b." ";
  26. $b = "" unless defined($b = <>);
  27. $b =~ s{\R$}{};
  28. }
  29. else
  30. {
  31. $o.=$b." ";
  32. last;
  33. }
  34. }
  35. $o =~ s/^\s+//;
  36. $o =~ s/\s+$//;
  37. $o =~ s/\s+/ /g;
  38. $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
  39. $sym{$s}=$o if !exists $sym{$s};
  40. }
  41. }
  42. ($pwd=`pwd`) =~ s{\R$}{};
  43. if ($sym{'TOP'} eq ".")
  44. {
  45. $n=0;
  46. $dir=".";
  47. }
  48. else {
  49. $n=split(/\//,$sym{'TOP'});
  50. @_=split(/\//,$pwd);
  51. $z=$#_-$n+1;
  52. foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
  53. chop($dir); # Remove the last slash
  54. }
  55. print "RELATIVE_DIRECTORY=$dir\n";
  56. foreach (sort keys %sym)
  57. {
  58. print "$_=$sym{$_}\n";
  59. }
  60. print "RELATIVE_DIRECTORY=\n";