summaryrefslogtreecommitdiff
path: root/source4/script
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-03-16 16:02:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:57:31 -0500
commit187628634f8abd88fa41b72b2dc4956b9293d013 (patch)
tree56e037e7190e917c9e2125efbbed647f77b52d3a /source4/script
parent43c7536883bf6313c47c4edb57cbbc66969b6ca7 (diff)
downloadsamba-187628634f8abd88fa41b72b2dc4956b9293d013.tar.gz
samba-187628634f8abd88fa41b72b2dc4956b9293d013.tar.bz2
samba-187628634f8abd88fa41b72b2dc4956b9293d013.zip
r14481: Change paths in headers on the fly when installing. Adds a simple text
file that contains the paths where headers need to be installed. (This used to be commit c3d975f4dce85245c7ba2b159c1128711d828291)
Diffstat (limited to 'source4/script')
-rwxr-xr-xsource4/script/installheader.pl78
1 files changed, 70 insertions, 8 deletions
diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl
index 1af05f3fea..808ab8d433 100755
--- a/source4/script/installheader.pl
+++ b/source4/script/installheader.pl
@@ -1,18 +1,70 @@
#!/usr/bin/perl
+# Copyright (C) 2006 Jelmer Vernooij
use strict;
use File::Basename;
my $includedir = shift;
+
+sub read_headermap($)
+{
+ my ($fn) = @_;
+ my %map = ();
+ my $ln = 0;
+ open(MAP, "<headermap.txt");
+ while(<MAP>) {
+ $ln++;
+ s/#.*$//g;
+ next if (/^\s*$/);
+ if (! /^(.*): (.*)$/) {
+ print STDERR "headermap.txt:$ln: Malformed line\n";
+ next;
+ }
+ $map{$1} = $2;
+ }
+
+ close(MAP);
+
+ return %map;
+}
+
+my %map = read_headermap("headermap.txt");
+
+sub findmap($)
+{
+ $_ = shift;
+ s/^\.\///g;
+
+ if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; }
+
+ return $map{$_};
+}
+
+sub rewrite_include($$)
+{
+ my ($pos,$d) = @_;
+
+ my $n = findmap($d);
+ return $n if $n;
+ return $d;
+}
+
sub install_header($$)
{
my ($src,$dst) = @_;
+ my $lineno = 0;
+
open(IN, "<$src");
open(OUT, ">$dst");
while (<IN>) {
- print OUT $_;
+ $lineno++;
+ if (/^#include \"(.*)\"/) {
+ print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n";
+ } else {
+ print OUT $_;
+ }
}
close(OUT);
@@ -21,15 +73,25 @@ sub install_header($$)
foreach my $p (@ARGV)
{
- my $p2 = basename($p);
- print "Installing $p as $includedir/$p2\n";
+ my $p2 = findmap($p);
+ unless ($p2) {
+ warn("Unable to map $p");
+ next;
+ }
+ print "Installing $p as $includedir/$p2\n";
+
+ my $dirname = dirname($p2);
- if ( -f "$includedir/$p2" ) {
- unlink("$includedir/$p2.old");
- rename("$includedir/$p2", "$includedir/$p2.old");
- }
+ if (! -d "$includedir/$dirname") {
+ mkdir("$includedir/$dirname");
+ }
+
+ if ( -f "$includedir/$p2" ) {
+ unlink("$includedir/$p2.old");
+ rename("$includedir/$p2", "$includedir/$p2.old");
+ }
- install_header($p,"$includedir/$p2");
+ install_header($p,"$includedir/$p2");
}
print <<EOF;