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