aboutsummaryrefslogtreecommitdiff
path: root/wpdf
diff options
context:
space:
mode:
Diffstat (limited to 'wpdf')
-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 {