3 # Program: GenLibDeps.pl
5 # Synopsis: Generate HTML output that shows the dependencies between a set of
6 # libraries. The output of this script should periodically replace
7 # the similar content in the UsingLibraries.html document.
9 # Syntax: GenLibDeps.pl <directory_with_libraries_in_it>
12 # Give first option a name.
13 my $Directory = $ARGV[0];
15 # Open the directory and read its contents, sorting by name and differentiating
16 # by whether its a library (.a) or an object file (.o)
17 opendir DIR,$Directory;
18 my @files = readdir DIR;
20 @libs = grep(/libLLVM.*\.a$/,sort(@files));
21 @objs = grep(/LLVM.*\.o$/,sort(@files));
23 # Declare the hashes we will use to keep track of the library and object file
28 # Gather definitions from the libraries
29 foreach $lib (@libs ) {
31 "nm -g --defined-only $lib | grep ' [ABCDGRSTVW] ' | sed -e 's/^[0-9A-Fa-f]* [ABCDGRSTVW] //' | sort | uniq |";
39 # Gather definitions from the object files.
40 foreach $obj (@objs ) {
42 "nm -g --defined-only $obj | grep ' [ABCDGRST] ' | sed -e 's/^[0-9A-Fa-f]* [ABCDGRST] //' | sort | uniq |";
50 # Generate one entry in the <dl> list. This generates the <dt> and <dd> elements
51 # for one library or object file. The <dt> provides the name of the library or
52 # object. The <dd> provides a list of the libraries/objects it depends on.
55 print " <dt><b>$lib</b</dt><dd>\n";
57 "nm -u $lib | grep ' U ' | sed -e 's/ U //' | sort | uniq |";
59 "| sort | uniq > GenLibDeps.out";
62 if (defined($libdefs{$_}) && $libdefs{$_} ne $lib) {
63 print DEPENDS "$libdefs{$_}\n";
64 } elsif (defined($objdefs{$_}) && $objdefs{$_} ne $lib) {
66 $libroot =~ s/lib(.*).a/$1/;
67 if ($objdefs{$_} ne "$libroot.o") {
68 print DEPENDS "$objdefs{$_}\n";
74 open DF, "<GenLibDeps.out";
83 # Make sure we flush on write. This is slower but correct based on the way we
84 # write I/O in gen_one_entry.
87 # Print the definition list tag
90 # Print libraries first
91 foreach $lib (@libs) {
95 # Print objects second
96 foreach $obj (@objs) {
100 # Print end tag of definition list element