aboutsummaryrefslogtreecommitdiffstats
path: root/doc/texidep.pl
blob: 0275e7470908f3a929aa58e5db450e6c7444b491 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /usr/bin/perl

use warnings;
use strict;

my ($root, $target) = @ARGV;

sub print_deps {
    my ($file, $deps) = @_;
    $deps->{$file} = 1;

    open(my $fh, "$file") or die "Cannot open file '$file': $!";
    while (<$fh>) {
        /^@(?:verbatim)?include\s+(\S+)/ and do {
            die "Circular dependency found in file $root\n" if exists $deps->{"doc/$1"};
            print "$target: doc/$1\n";
            print_deps("doc/$1", {%$deps});
        }
    }
}

print_deps($root, {});