mirror of
http://mpg123.de/trunk/.git
synced 2025-07-31 13:24:22 +03:00
build: relative header includes, dropping -Isrc/compat and -Isrc/common
Only the generated config.h and the API headers in src/include should be located via search path now. git-svn-id: svn://scm.orgis.org/mpg123/trunk@5386 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
42
scripts/fixinc.pl
Normal file
42
scripts/fixinc.pl
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use File::Basename qw(dirname);
|
||||
use File::Spec::Functions qw(abs2rel);
|
||||
|
||||
my @incdirs = ('src/common', 'src/compat', 'src');
|
||||
|
||||
sub header
|
||||
{
|
||||
my ($from, $inc) = @_;
|
||||
for(dirname($from), @incdirs)
|
||||
{
|
||||
my $cand = "$_/$inc";
|
||||
return $cand if -e $cand;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
for my $f (@ARGV)
|
||||
{
|
||||
open(my $ih, '<', $f) or die "meh: $!\n";
|
||||
open(my $oh, '>', "$f.tmp") or die "moh: $!\n";
|
||||
while(my $line = <$ih>)
|
||||
{
|
||||
if($line =~ m,^(\s*\#\s*include\s+)"([^/]+)\"(.*)$,)
|
||||
{
|
||||
my ($pre, $inc, $post) = ($1, $2, $3);
|
||||
my $h = header($f, $inc);
|
||||
if($inc ne "config.h" and defined $h)
|
||||
{
|
||||
if(dirname($h) ne dirname($f))
|
||||
{
|
||||
my $rel = abs2rel($h, dirname($f));
|
||||
print "$f: including $inc ($rel)\n";
|
||||
$line = $pre.'"'.$rel.'"'.$post."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
print $oh "$line";
|
||||
}
|
||||
rename("$f.tmp", $f);
|
||||
}
|
Reference in New Issue
Block a user