13 getopts('vnj:f:o:s:', \%opts);
15 print "Using $opts{j} processors\n" if $opts{v};
17 my $var_re = qr/[A-Za-z_][A-Za-z0-9_]*/;
20 my ($base, $iext, $oext) = @_;
21 my $cmd = $rules{$oext}{$iext};
22 my $infile = "$base.$iext";
24 $cmd =~ s!\$\<!"$infile"!g;
27 # Strip leading path from base so we can stick the file in
29 $base = basename($base);
30 $outfile = "$opts{o}/$base.$oext";
32 $outfile = "$base.$oext";
34 $outfile =~ s/"/\\"/g;
35 $cmd =~ s!\$\@!"$outfile"!g;
47 s/\$($var_re)/(exists $vars{$1} ? $vars{$1} : '$' . $1)/eg;
51 open CONF, ($opts{f} || 'Convfile') or die "Could not open Convfile";
58 if (/^([\w.]+)\s*=>\s*([\w.]+)\s*:\s*(.*)$/) {
60 } elsif (/^($var_re)\s*=\s*(.*)$/) {
61 $vars{$1} = expand($2);
63 warn "Error in Convfile line $.: $_\n";
70 # If we specify reading from stdin, do this.
71 if (exists $opts{s}) {
77 print "File specified on stdin, $_, does not exist.\n";
81 if (/^(.+)\.(\w+)$/) {
84 print "Considering $base.$iext\n" if $opts{v};
85 if (exists $rules{$opts{s}}{$iext}) {
86 print "Using $base.$iext\n" if $opts{v};
87 push @queue, [$base, $iext, $opts{s}];
90 print "I don't see an extension on $_, so I don't know what to do with it.\n";
95 # Not reading filenames from stdin.
104 map { s/\.(\w+)$/\.$extsub/; $_ }
108 push @tmpARGV, @files;
115 # I like to call this the TOWER OF POWER
116 for my $ofile (@ARGV) {
118 for my $oext (keys %rules) {
120 $oext_re =~ s/\./\\./g;
121 if ($ofile =~ /^(.*)\.$oext_re$/) {
124 for my $iext (keys %{$rules{$oext}}) {
125 print "Considering $base.$iext\n" if $opts{v};
126 if (-e "$base.$iext") {
127 print "Using $base.$iext\n" if $opts{v};
128 push @queue, [$base, $iext, $oext];
134 print "No suitable input file found for $ofile\n";
141 print "No rule to make $ofile\n";
146 print scalar @queue, " items to process\n" if $opts{v};
149 foreach my $chunk (@queue) {
152 if ($procs == $opts{j}) {
159 # vim:set ts=4 sts=4 sw=4 expandtab: