X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=util%2Fpostprocess-makedepend.pl;h=323ce9e0e4eac43f6746cbcb0c73159b0d002abb;hp=790738015f85043ae076365814182be8a08f5e5d;hb=23be743286c0f0a160de33365ef34af39427eac9;hpb=bbb9413b7e530aa25779b33b5ca7a5fd610e66f1 diff --git a/util/postprocess-makedepend.pl b/util/postprocess-makedepend.pl index 790738015f..323ce9e0e4 100644 --- a/util/postprocess-makedepend.pl +++ b/util/postprocess-makedepend.pl @@ -9,8 +9,15 @@ use strict; use warnings; -my $producer = shift @ARGV; +use lib '.'; +use configdata; + +use File::Spec::Functions qw(canonpath rel2abs); +my $abs_srcdir = rel2abs($config{sourcedir}); +my $abs_blddir = rel2abs($config{builddir}); + +my $producer = shift @ARGV; die "Producer not given\n" unless $producer; my $procedure = { @@ -41,9 +48,10 @@ my $procedure = { # Finally, discard all empty lines or comment lines return undef if $line =~ /:\s*$/ || $line =~ /^(#.*|\s*)$/; - $line.="\n" unless $line =~ /\R$/g; - - return $line; + my ($target, $deps) = $line =~ /^((?:\\.|[^:])*):(.*)/; + $deps =~ s/^\s+//; + $deps =~ s/\s+$//; + return ($target, $deps); }, 'VMS C' => sub { @@ -72,7 +80,10 @@ my $procedure = { # .TLB. return undef if /\.TLB\s*$/; - return $line; + my ($target, $deps) = $line =~ /^(.*)\s:\s(.*)/; + $deps =~ s/^\s+//; + $deps =~ s/\s+$//; + return ($target, $deps); }, 'VC' => sub { @@ -98,7 +109,15 @@ my $procedure = { if (/^Note: including file: */) { (my $tail = $') =~ s/\s*\R$//; - return "${object}: \"$tail\"\n"; + + # VC gives us absolute paths for all include files, so to + # remove system header dependencies, we need to check that + # they don't match $abs_srcdir or $abs_blddir + $tail = canonpath($tail); + if ($tail =~ m|^\Q$abs_srcdir\E|i + || $tail =~ m|^\Q$abs_blddir\E|i) { + return ($object, "\"$tail\""); + } } return undef; @@ -107,8 +126,35 @@ my $procedure = { die "Producer unrecognised: $producer\n" unless defined $procedure; +my %collect = (); while () { - if ($_ = $procedure->($_, @ARGV)) { - print or die "$!\n"; + s|\R$||; # The better chomp + my ($target, $deps) = $procedure->($_, @ARGV); + $collect{$target}->{$deps} = 1 + if defined $target; +} + +my $continuation = { + 'makedepend' => "\\", + 'VMS C' => "-", + 'VC' => "\\", +} -> {$producer}; + +die "Producer unrecognised: $producer\n" unless defined $continuation; + +foreach my $target (sort keys %collect) { + my $prefix = $target . ' :'; + my @deps = sort keys %{$collect{$target}}; + + while (@deps) { + my $buf = $prefix; + $prefix = ''; + + while (@deps && ($buf eq '' || length($buf) + length($deps[0]) <= 77)) { + $buf .= ' ' . shift @deps; + } + $buf .= ' '.$continuation if @deps; + + print $buf,"\n"; } }