Debian Codegraph @

source/util/good-depfile

raw
1 #! /usr/bin/env perl
2
3 use warnings;
4
5 # Check a gcc -M dependency file (provided on stdin or in ARGV) for
6 # existence of all the prerequisites. If any is missing, exit with failure.
7
8 use strict;
9
10 undef $/;
11
12 my $deps = <>;
13
14 # Join lines
15 $deps =~ s/\\\n/ /g;
16 # Chomp newline and trailing space
17 $deps =~ s/\s*$//;
18
19 # Remove the target
20 $deps =~ s/^[^:]*:\s*//;
21
22 # Exit false if any dependency is missing
23 for my $file (split /\s+/, $deps) {
24 -e $file or exit 1;
25 }
26
27 # All dependencies present, exit true.
28 exit 0;