#!/bin/perl
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# This program reads the a.list file, which  should  contain  a  list  of  .a #
# files,  and  write a.syms, which will contain a list of the defined symbols #
# in the listed .a files.  The idea is to make it  easy  to  find  out  which #
# archives define which symbols.  See also the ga script.                     #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
$L = "< $ENV{'HOME'}/a.list";
$S = "> $ENV{'HOME'}/a.syms";
open(L,$L) || die "Can't read `$L'\n";
open(S,$S) || die "Can't write `$S'\n";
for (<L>) {
	chop;
	$N = "nm $_ |";
	if (open(N,$N)) {
		for $n (<N>) {
			chop $n;
			if ($n =~ /^Symbols from (.*):/) {
				$a = $1;
			} elsif ($n =~ /\|UNDEF *\|(.*)$/) {
			} elsif ($n =~ /\| *$/) {
			} elsif ($n =~ /\|([^|]+)\|([^|]+)$/) {
				print S "$a\t$2\n";
			} else {
			}
		}
	}
}
