fix red.
[kugel-rb/myfork.git] / apps / plugins / elfdep.pl
blob0e32852b3dc50e07023ab91163dfc1eb61b65347
1 #!/usr/bin/perl
3 sub getdir {
4 my ($some_dir, $files)=@_;
5 opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
6 my @all = grep { /$files$/ && -f "$some_dir/$_" } readdir(DIR);
7 closedir DIR;
8 return @all;
11 my @all=getdir(".", "\.c");
12 my @pluginhead=getdir("lib", "\.h");
14 for(@pluginhead) {
15 $plug{$_}=$_;
18 my %head2lib=('Tremor' => 'libTremor');
20 my $s;
21 foreach $s (sort @all) {
23 my $plib=0;
24 my $codec;
25 open(F, "<$s");
26 while(<F>) {
27 if($_ =~ /^ *\#include [\"<]([^\"]+)[\">]/) {
28 my $f = $1;
29 if($plug{$f}) {
30 $plib=1;
32 if($f =~ /codecs\/([^\/]+)/) {
33 $codec=$1;
34 my $d = $head2lib{$codec};
35 if($d) {
36 $codec = $d;
42 #print "$s uses $plib and $codec\n";
44 $s =~ s/\.c//;
45 printf("\$(OBJDIR)/$s.elf: \$(OBJDIR)/$s.o \$(LINKFILE)%s%s\n\t\$(ELFIT)\n\n",
46 $plib?" \$(OBJDIR)/libplugin.a":"",
47 $codec?" \$(OBJDIR)/$codec.a":"");