mpegplayer:
[kugel-rb.git] / tools / addtargetdir.pl
blob6a9a72a878b25e9c99076b27c5729d7c92301a66
1 #!/usr/bin/perl
2 # __________ __ ___.
3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 # \/ \/ \/ \/ \/
8 # $Id$
11 # addtargetdir.pl - Adds target directory to gcc-generated dependency data
13 use File::Basename;
15 my $rbroot = $ARGV[0];
16 my $builddir = $ARGV[1];
17 undef $/;
19 my $target;
20 my $rootlen = length $rbroot;
21 my $src;
23 # Split the input file on any runs of '\' and whitespace.
24 for (split(/[\s\\]+/m, <STDIN>)) {
25 /^(\/)?[^:]+(\:)?$/;
26 # Save target and continue if this item ends in ':'
27 if (!($2 && ($target=$&))) {
28 $src = $&;
29 # If $target is set, prefix it with the target path
30 if ($target) {
31 my $dir = dirname $src;
32 substr($dir, 0, $rootlen) = $builddir;
33 print "\n$dir/$target";
34 $target = "";
35 # Otherwise, check for an incomplete path for the source file
36 } elsif (!$1) {
37 $src = "$builddir/$src";
39 print " \\\n $src";