files.pl 854 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. $s="";
  7. while (<>)
  8. {
  9. chop;
  10. s/#.*//;
  11. if (/^(\S+)\s*=\s*(.*)$/)
  12. {
  13. $o="";
  14. ($s,$b)=($1,$2);
  15. for (;;)
  16. {
  17. if ($b =~ /\\$/)
  18. {
  19. chop($b);
  20. $o.=$b." ";
  21. $b=<>;
  22. chop($b);
  23. }
  24. else
  25. {
  26. $o.=$b." ";
  27. last;
  28. }
  29. }
  30. $o =~ s/^\s+//;
  31. $o =~ s/\s+$//;
  32. $o =~ s/\s+/ /g;
  33. $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
  34. $sym{$s}=$o;
  35. }
  36. }
  37. $pwd=`pwd`; chop($pwd);
  38. if ($sym{'TOP'} eq ".")
  39. {
  40. $n=0;
  41. $dir=".";
  42. }
  43. else {
  44. $n=split(/\//,$sym{'TOP'});
  45. @_=split(/\//,$pwd);
  46. $z=$#_-$n+1;
  47. foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
  48. chop($dir);
  49. }
  50. print "RELATIVE_DIRECTORY=$dir\n";
  51. foreach (sort keys %sym)
  52. {
  53. print "$_=$sym{$_}\n";
  54. }
  55. print "RELATIVE_DIRECTORY=\n";