# __________ __ ___. # Open \______ \ ____ ____ | | _\_ |__ _______ ___ # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ # \/ \/ \/ \/ \/ # $Id$ # # preprocess - run preprocessor on a file and return the result as a string # # This uses the native 'gcc' compiler and not $(CC) since we use the -imacros # option and older gcc compiler doesn't have that. We use one such older # compiler for the win32 cross-compiles on Linux. # # The weird grep -v thing in here is due to Apple's stupidities and is needed # to make this do right when used on Mac OS X. # # The sed line is to prepend the directory to all source files preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \ grep -v '^\#' | \ sed -e 's:^..*:$(dir $(1))&:') preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \ grep -v '^\#' | grep -v "^$$" > $(2)) c2obj = $(addsuffix .o,$(basename $(subst $(ROOTDIR),$(BUILDDIR),$(1)))) # calculate dependencies for a list of source files $(2) and output them # to a file $(1) mkdepfile = $(shell \ $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h $(2) | \ $(TOOLSDIR)/addtargetdir.pl $(ROOTDIR) $(BUILDDIR) | \ sed -e "s: lang.h: $(BUILDDIR)/lang.o:" \ -e "s: sysfont.h: $(BUILDDIR)/sysfont.h:" \ -e "s: max_language_size.h: $(BUILDDIR)/max_language_size.h:" \ -e "s: bitmaps/: $(BUILDDIR)/bitmaps/:g" \ -e "s: pluginbitmaps/: $(BUILDDIR)/pluginbitmaps/:g" \ -e "s: lib/: $(APPSDIR)/plugins/lib/:g" \ -e "s: codeclib.h: $(APPSDIR)/codecs/lib/codeclib.h:g" \ >> $(1)_) # function to create .bmp dependencies bmpdepfile = $(shell \ for each in $(2); do \ obj=`echo $$each | sed -e 's/\.bmp/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \ src=`echo $$each | sed -e 's/\.bmp/.c/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \ echo $$obj: $$src; \ echo $$src: $$each; \ done \ >> $(1); ) ifndef V SILENT:=@ else VERBOSEOPT:=-v endif PRINTS=$(SILENT)$(call info,$(1)) # old 'make' versions don't have the built-in 'info' function info=old$(shell echo >&2 "Consider upgrading to GNU make 3.81+ for optimum build performance.") ifeq ($(call info),old) export info=echo "$$(1)"; endif '/cgit/rockbox/tree/?id=7243fdcee3ce88970bfcd2cce7a7c2e0b8e72cbb'>root/apps/plugins/elfdep.pl
blob: 0e32852b3dc50e07023ab91163dfc1eb61b65347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl

sub getdir {
    my ($some_dir, $files)=@_;
    opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
    my @all = grep { /$files$/ && -f "$some_dir/$_" } readdir(DIR);
    closedir DIR;
    return @all;
}

my @all=getdir(".", "\.c");
my @pluginhead=getdir("lib", "\.h");

for(@pluginhead) {
    $plug{$_}=$_;
}

my %head2lib=('Tremor' => 'libTremor');

my $s;
foreach $s (sort @all) {

    my $plib=0;
    my $codec;
    open(F, "<$s");
    while(<F>) {
        if($_ =~ /^ *\#include [\"<]([^\"]+)[\">]/) {
            my $f = $1;
            if($plug{$f}) {
                $plib=1;
            }
            if($f =~ /codecs\/([^\/]+)/) {
                $codec=$1;
                my $d = $head2lib{$codec};
                if($d) {
                    $codec = $d;
                }
            }
        }
    }

    #print "$s uses $plib and $codec\n";

    $s =~ s/\.c//;
    printf("\$(OBJDIR)/$s.elf: \$(OBJDIR)/$s.o \$(LINKFILE)%s%s\n\t\$(ELFIT)\n\n",
           $plib?" \$(OBJDIR)/libplugin.a":"",
           $codec?" \$(OBJDIR)/$codec.a":"");
}