texidep.pl 864 B

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