diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-19 16:39:18 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-19 16:39:31 +0200 |
commit | aa6c30a140afbe7bb850f0b8eb85c5be9c281d5d (patch) | |
tree | 4000dc0571bfe061e13c0a51e64ddad665b311af /etc | |
parent | df8da90e44da373251db5e040b72955ab89f95d2 (diff) | |
download | xutil-aa6c30a140afbe7bb850f0b8eb85c5be9c281d5d.tar.gz |
wpdf: Fix build(1) support
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/wpdf | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; |