Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[cascardo/ovs.git] / soexpand.pl
1 use strict;
2 use warnings;
3 use Getopt::Long;
4
5 my ($exit_code) = 0;
6 my (@include_dirs);
7 Getopt::Long::Configure ("bundling");
8 GetOptions("I|include=s" => \@include_dirs) or exit(1);
9 @include_dirs = ('.') if !@include_dirs;
10 OUTER: while (<STDIN>) {
11     if (my ($name) = /^\.so (\S+)$/) {
12         foreach my $dir (@include_dirs, '.') {
13             if (open(INNER, "$dir/$name")) {
14                 while (<INNER>) {
15                     print $_;
16                 }
17                 close(INNER);
18                 next OUTER;
19             }
20         }
21         print STDERR "$name not found in: ", join(' ', @include_dirs), "\n";
22         $exit_code = 1;
23     }
24     print $_;
25 }
26 exit $exit_code;