rockbox/tools/addtargetdir.pl
Rafaël Carré 27c509fc55 makefiles
- some functions don't need to return their output, drop $(shell ... )
and prefix with $(SILENT), make V=1 will show the complete scripts being
run

- tweak make.dep generation: make the temporary file appear in root.make
  only, and remove a useless "real command", there is already a real
  command (mv)

- make addtargetdir.pl terminate its output with a newline ($(shell) did
  that for us)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27855 a1c6a512-1295-4272-9138-f99709370657
2010-08-21 18:07:12 +00:00

42 lines
1.2 KiB
Perl
Executable file

#!/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];
undef $/;
my $target;
my $rootlen = length $rbroot;
my $src;
# 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) {
my $dir = dirname $src;
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";
}
print " \\\n $src";
}
}
print "\n";