Commit | Line | Data |
---|---|---|
2ba45a60 DM |
1 | #! /usr/bin/env perl |
2 | ||
3 | # This script will print the dependency of a Texinfo file to stdout. | |
4 | # texidep.pl <src-path> <input.texi> <output.ext> | |
5 | ||
6 | use warnings; | |
7 | use strict; | |
8 | ||
9 | die unless @ARGV == 3; | |
10 | ||
11 | my ($src_path, $root, $target) = @ARGV; | |
12 | ||
13 | sub print_deps { | |
14 | my ($file, $deps) = @_; | |
15 | $deps->{$file} = 1; | |
16 | ||
17 | open(my $fh, "<", "$file") or die "Cannot open file '$file': $!"; | |
18 | while (<$fh>) { | |
19 | if (my ($i) = /^\@(?:verbatim)?include\s+(\S+)/) { | |
20 | die "Circular dependency found in file $root\n" if exists $deps->{"doc/$1"}; | |
21 | print "$target: doc/$1\n"; | |
22 | ||
23 | # skip looking for config.texi dependencies, since it has | |
24 | # none, and is not located in the source tree | |
25 | if ("$1" ne "config.texi") { | |
26 | print_deps("$src_path/doc/$1", {%$deps}); | |
27 | } | |
28 | } | |
29 | } | |
30 | } | |
31 | ||
32 | print_deps($root, {}); |