aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-19 16:39:18 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-19 16:39:31 +0200
commitaa6c30a140afbe7bb850f0b8eb85c5be9c281d5d (patch)
tree4000dc0571bfe061e13c0a51e64ddad665b311af /etc
parentdf8da90e44da373251db5e040b72955ab89f95d2 (diff)
downloadxutil-aa6c30a140afbe7bb850f0b8eb85c5be9c281d5d.tar.gz
wpdf: Fix build(1) support
Diffstat (limited to 'etc')
-rwxr-xr-xetc/wpdf7
1 files changed, 6 insertions, 1 deletions
diff --git a/etc/wpdf b/etc/wpdf
index 94e5029..077b699 100755
--- a/etc/wpdf
+++ b/etc/wpdf
@@ -7,6 +7,7 @@ use warnings;
my $alive; # number of children alive
my %deptarget; # dependency => target
+my %depsource; # dependency => source
my $parent = $$; # pid of parent
$SIG{USR1} = sub { kill 'HUP', 0 if not --$alive };
@@ -42,12 +43,14 @@ for my $target (@ARGV) {
my $source = $target;
$target =~ s,\.[^./]*$,,; $target .= '.pdf';
$deptarget{$source} = $target;
+ $depsource{$source} = $source;
open my $f, '<', $source;
while (<$f>) {
last if ++$i > 20;
if (/\s% (.*)/) {
$deptarget{$_} = $target for split /\s/, $1;
+ $depsource{$_} = $source for split /\s/, $1;
last;
}
}
@@ -69,7 +72,9 @@ open my $p, '-|', 'watch', keys %deptarget
or die "could not start watch: $!\n";
while (<$p>) {
chomp;
- system('make', "$deptarget{$_}") == 0
+ my $cmd = ($_ =~ /\.pdf$/) ? 'make' : 'build';
+ my $arg = ($_ =~ /\.pdf$/) ? $deptarget{$_} : $depsource{$_};
+ system($cmd, $arg) == 0
&& system('xpdf', '-remote', "wpdf-$deptarget{$_}", '-reload');
}
close $p;