aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-21 14:15:01 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-21 14:16:51 +0200
commit0b3dfa14a17831333aad9cc02f8e37398bff739c (patch)
treedce121553f15f58823e60b524748c63e6276512c
parentd26f20ff4f4494c4dfe26793918edf9c42ecd47d (diff)
downloadxutil-0b3dfa14a17831333aad9cc02f8e37398bff739c.tar.gz
wpdf: Support multiple implicit dependencies
Turns out that make's -dv option is rather inflexible.
-rwxr-xr-xwpdf30
1 files changed, 13 insertions, 17 deletions
diff --git a/wpdf b/wpdf
index 304f687..99fa525 100755
--- a/wpdf
+++ b/wpdf
@@ -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 {