summaryrefslogtreecommitdiff
path: root/tools/addtargetdir.pl
blob: 2cddf8d3d484a512b45db1f82f1f0c94e260f3f8 (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
#!/usr/bin/perl
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#

# addtargetdir.pl - Adds target directory to gcc-generated dependency data

use File::Basename;

my $rbroot = $ARGV[0];
my $builddir = $ARGV[1];

my $target2;

for (<STDIN>) {
    if (/^([^:]+): (\S+) (.*)/) {
        my ($target, $src, $rest) = ($1, $2, $3);
        my $dir = dirname $src;
        $dir =~ s/$rbroot//;
        print "$builddir$dir/$target: $src $rest\n";
    }
    elsif (/^([^:]+):  \\/) {
        # target and source on different lines
        $target2 = $1;
    }
    elsif ($target2) {
        if (/^\s+([^ ]+) (.*)/) {
            my ($src, $rest) = ($1, $2);
            my $dir = dirname $src;
            $dir =~ s/$rbroot//;
            print "$builddir$dir/$target2: $src $rest\n";
            $target2 = "";
        }
    }
    else {
        print $_;
    }
}