diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-21 14:15:01 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-21 14:16:51 +0200 |
commit | 0b3dfa14a17831333aad9cc02f8e37398bff739c (patch) | |
tree | dce121553f15f58823e60b524748c63e6276512c | |
parent | d26f20ff4f4494c4dfe26793918edf9c42ecd47d (diff) | |
download | xutil-0b3dfa14a17831333aad9cc02f8e37398bff739c.tar.gz |
wpdf: Support multiple implicit dependencies
Turns out that make's -dv option is rather inflexible.
-rwxr-xr-x | wpdf | 30 |
1 files changed, 13 insertions, 17 deletions
@@ -10,27 +10,23 @@ my %deptarget; # dependency => target # collect dependencies for given pdf files for my $target (@ARGV) { if ($target =~ /\.pdf$/) { - # try to directly parse out dependencies + (my $basename = $target) =~ s/\.pdf$//; open my $f, '<', 'Makefile' or die "could not open Makefile: $!\n"; while (<$f>) { - next if not /^\Q$target\E:\s*(.*)/; - $deptarget{$_} = $target for split /\s/, $1; - goto found; + # explicit + if (/^\Q$target\E:\s*(.*)/) { + $deptarget{$_} = $target for split /\s/, $1; + last; + } + # implicit + if (/^\.([^ .]+)\.pdf\s*:\s*(.*)/) { + $deptarget{"$basename.$1"} = $target; + $deptarget{$_} = $target for split /\s/, $2; + last; + } } - - # try to get implicit dependencies - (my $esc = $target) =~ s/'/'"'"'/g; - open my $p, "make -ndv 2>&1 '$esc' |" - or die "could not run make: $!\n"; - while (<$p>) { - next if not /^\Q$target\E:< = (.*)/; - $deptarget{$_} = $target for split /\s/, $1; - last; - } - - close $p; -found: close $f; + close $f; exec('xpdf', '-remote', "wpdf-$target", $target) if fork == 0; next; } else { |