etc/services - sync with NetBSD-8
[minix.git] / crypto / external / bsd / openssl / dist / util / src-dep.pl
blobad997e4746838fcf3152fa2f5b673c0caf83bdcc
1 #!/usr/local/bin/perl
3 # we make up an array of
4 # $file{function_name}=filename;
5 # $unres{filename}="func1 func2 ...."
6 $debug=1;
7 #$nm_func="parse_linux";
8 $nm_func="parse_solaris";
10 foreach (@ARGV)
12 &$nm_func($_);
15 foreach $file (sort keys %unres)
17 @a=split(/\s+/,$unres{$file});
18 %ff=();
19 foreach $func (@a)
21 $f=$file{$func};
22 $ff{$f}=1 if $f ne "";
25 foreach $a (keys %ff)
26 { $we_need{$file}.="$a "; }
29 foreach $file (sort keys %we_need)
31 # print " $file $we_need{$file}\n";
32 foreach $bit (split(/\s+/,$we_need{$file}))
33 { push(@final,&walk($bit)); }
35 foreach (@final) { $fin{$_}=1; }
36 @final="";
37 foreach (sort keys %fin)
38 { push(@final,$_); }
40 print "$file: @final\n";
43 sub walk
45 local($f)=@_;
46 local(@a,%seen,@ret,$r);
48 @ret="";
49 $f =~ s/^\s+//;
50 $f =~ s/\s+$//;
51 return "" if ($f =~ "^\s*$");
53 return(split(/\s/,$done{$f})) if defined ($done{$f});
55 return if $in{$f} > 0;
56 $in{$f}++;
57 push(@ret,$f);
58 foreach $r (split(/\s+/,$we_need{$f}))
60 push(@ret,&walk($r));
62 $in{$f}--;
63 $done{$f}=join(" ",@ret);
64 return(@ret);
67 sub parse_linux
69 local($name)=@_;
71 open(IN,"nm $name|") || die "unable to run 'nn $name':$!\n";
72 while (<IN>)
74 chop;
75 next if /^\s*$/;
76 if (/^[^[](.*):$/)
78 $file=$1;
79 $file="$1.c" if /\[(.*).o\]/;
80 print STDERR "$file\n";
81 $we_need{$file}=" ";
82 next;
85 @a=split(/\s*\|\s*/);
86 next unless $#a == 7;
87 next unless $a[4] eq "GLOB";
88 if ($a[6] eq "UNDEF")
90 $unres{$file}.=$a[7]." ";
92 else
94 if ($file{$a[7]} ne "")
96 print STDERR "duplicate definition of $a[7],\n$file{$a[7]} and $file \n";
98 else
100 $file{$a[7]}=$file;
104 close(IN);
107 sub parse_solaris
109 local($name)=@_;
111 open(IN,"nm $name|") || die "unable to run 'nn $name':$!\n";
112 while (<IN>)
114 chop;
115 next if /^\s*$/;
116 if (/^(\S+):$/)
118 $file=$1;
119 #$file="$1.c" if $file =~ /^(.*).o$/;
120 print STDERR "$file\n";
121 $we_need{$file}=" ";
122 next;
124 @a=split(/\s*\|\s*/);
125 next unless $#a == 7;
126 next unless $a[4] eq "GLOB";
127 if ($a[6] eq "UNDEF")
129 $unres{$file}.=$a[7]." ";
130 print STDERR "$file needs $a[7]\n" if $debug;
132 else
134 if ($file{$a[7]} ne "")
136 print STDERR "duplicate definition of $a[7],\n$file{$a[7]} and $file \n";
138 else
140 $file{$a[7]}=$file;
141 print STDERR "$file has $a[7]\n" if $debug;
145 close(IN);