2008-11-21 15:07:15 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
2008-11-25 19:54:23 +00:00
|
|
|
# $Id$
|
2008-11-21 15:07:15 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# addtargetdir.pl - Adds target directory to gcc-generated dependency data
|
|
|
|
|
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
my $rbroot = $ARGV[0];
|
|
|
|
my $builddir = $ARGV[1];
|
2009-07-12 22:02:09 +00:00
|
|
|
undef $/;
|
2008-11-21 15:07:15 +00:00
|
|
|
|
2009-07-12 22:02:09 +00:00
|
|
|
my $target;
|
|
|
|
my $rootlen = length $rbroot;
|
|
|
|
my $src;
|
2008-11-22 23:04:15 +00:00
|
|
|
|
2009-07-12 22:02:09 +00:00
|
|
|
# Split the input file on any runs of '\' and whitespace.
|
|
|
|
for (split(/[\s\\]+/m, <STDIN>)) {
|
|
|
|
/^(\/)?[^:]+(\:)?$/;
|
|
|
|
# Save target and continue if this item ends in ':'
|
|
|
|
if (!($2 && ($target=$&))) {
|
|
|
|
$src = $&;
|
|
|
|
# If $target is set, prefix it with the target path
|
|
|
|
if ($target) {
|
2008-11-22 23:04:15 +00:00
|
|
|
my $dir = dirname $src;
|
2009-07-12 22:02:09 +00:00
|
|
|
substr($dir, 0, $rootlen) = $builddir;
|
|
|
|
print "\n$dir/$target";
|
|
|
|
$target = "";
|
|
|
|
# Otherwise, check for an incomplete path for the source file
|
|
|
|
} elsif (!$1) {
|
|
|
|
$src = "$builddir/$src";
|
2008-11-22 23:04:15 +00:00
|
|
|
}
|
2009-07-12 22:02:09 +00:00
|
|
|
print " \\\n $src";
|
2008-11-21 15:07:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-21 18:07:12 +00:00
|
|
|
print "\n";
|