make_parser.pm 21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# Copyright 1999, 2000, 2001 Patrik Stridvall
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 18
#

19 20 21 22
package make_parser;

use strict;

23
use setup qw($current_dir $wine_dir $winapi_dir);
Patrik Stridvall's avatar
Patrik Stridvall committed
24 25 26 27 28 29 30 31 32 33

use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw($directory $tool $file $line $message);

use vars qw($directory $tool $file $line $message);

34
use output qw($output);
Patrik Stridvall's avatar
Patrik Stridvall committed
35
use options qw($options);
36

37 38 39 40 41 42 43 44 45 46

#sub command($);
#sub gcc_output($$);
#sub ld_output($$);
#sub make_output($$);
#sub winebuild_output($$);
#sub wmc_output($$);
#sub wrc_output($$);


47 48 49 50
########################################################################
# global
########################################################################

51
my $current;
52 53 54 55 56 57
my $function;

########################################################################
# error
########################################################################

58
sub error($) {
Patrik Stridvall's avatar
Patrik Stridvall committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    my $where = shift;

    if(!defined($where)) {
	$where = "";
    }

    my $context;
    if($tool) {
	$context = "$tool";
	if($where) {
	    $context .= "<$where>";
	}
    } else {
	if($where) {
	    $context = "<$where>";
	} else {
	    $context = "<>";
	}
    }

Patrik Stridvall's avatar
Patrik Stridvall committed
79
    if(defined($tool)) {
80
	$output->write("$directory: $context: can't parse output: '$current'\n");
Patrik Stridvall's avatar
Patrik Stridvall committed
81
    } else {
82
	$output->write("$directory: $context: can't parse output: '$current'\n");
Patrik Stridvall's avatar
Patrik Stridvall committed
83
    }
84 85 86 87 88 89 90
    exit 1;
}

########################################################################
# make_output
########################################################################

91
sub make_output($$) {
92 93 94 95 96 97
    my $level = shift;
    local $_ = shift;

    $file = "";
    $message = "";

98
    if(/^\*\*\* \[(.*?)\] Error (\d+)$/) {
99 100 101
	# Nothing
    } elsif(/^\*\*\* Error code (\d+)$/) {
	# Nothing
102
    } elsif(/^\*\*\* Warning:\s+/) { #
103 104 105
	if(/^File \`(.+?)\' has modification time in the future \((.+?) > \(.+?\)\)$/) {
	    # Nothing
	} else {
Patrik Stridvall's avatar
Patrik Stridvall committed
106
	    error("make_output");
107 108 109 110 111
	}
    } elsif(/^\`(.*?)\' is up to date.$/) {
	# Nothing
    } elsif(/^\[(.*?)\] Error (\d+) \(ignored\)$/) {
	# Nothing
112 113
    } elsif(/^don\'t know how to make (.*?)\. Stop$/) {
	$message = "$_";
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    } elsif(/^(Entering|Leaving) directory \`(.*?)\'$/) {
	if($1 eq "Entering") {
	    $directory = $2;
	} else {
	    $directory = "";
	}

	my @components;
	foreach my $component (split(/\//, $directory)) {
	    if($component eq "wine") {
		@components = ();
	    } else {
		push @components, $component;
	    }
	}
	$directory = join("/", @components);
Patrik Stridvall's avatar
Patrik Stridvall committed
130 131 132
    } elsif(/^(.*?) is older than (.*?), please rerun (.*?)\$/) {
	# Nothing
    } elsif(/^Nothing to be done for \`(.*?)\'\.$/) {
133 134 135 136 137
	# Nothing
    } elsif(s/^warning:\s+//) {
	if(/^Clock skew detected.  Your build may be incomplete.$/) {
	    # Nothing
	} else {
Patrik Stridvall's avatar
Patrik Stridvall committed
138
	    error("make_output");
139
	}
140 141 142 143
    } elsif(/^Stop in (.*?)\.$/) {
	# Nothing
    } elsif(/^\s*$/) {
	# Nothing
144
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
145
	error("make_output");
146 147 148 149 150 151 152 153
    }

}

########################################################################
# ar_command
########################################################################

154
sub ar_command($) {
155 156 157 158 159 160 161 162 163 164 165
    local $_ = shift;

    my $read_files;
    my $write_files;

    if(/rc\s+(\S+)(\s+\S+)+$/) {
	$write_files = [$1];
	$read_files = $2;
	$read_files =~ s/^\s*//;
	$read_files = [split(/\s+/, $read_files)];
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
166
	error("ar_command");
167 168 169 170 171 172 173 174 175
    }

    return ($read_files, $write_files);
}

########################################################################
# as_command
########################################################################

176
sub as_command($) {
177 178 179 180 181 182 183 184 185
    local $_ = shift;

    my $read_files;
    my $write_files;

    if(/-o\s+(\S+)\s+(\S+)$/) {
	$write_files = [$1];
	$read_files = [$2];
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
186
	error("as_command");
187 188 189 190 191 192 193 194 195
    }

    return ($read_files, $write_files);
}

########################################################################
# bision_command
########################################################################

196
sub bison_command($) {
197 198 199 200 201 202 203 204 205
    local $_ = shift;

    return ([], []);
}

########################################################################
# cd_command
########################################################################

206
sub cd_command($) {
207 208 209 210 211 212 213 214 215
    local $_ = shift;

    return ([], []);
}

########################################################################
# cd_output
########################################################################

216
sub cd_output($) {
217 218 219 220 221 222 223 224 225 226 227
    local $_ = shift;

    if(/^(.*?): No such file or directory/) {
	$message = "directory '$1' doesn't exist";
    }
}

########################################################################
# flex_command
########################################################################

228
sub flex_command($) {
229 230 231 232 233 234 235 236 237
    local $_ = shift;

    return ([], []);
}

########################################################################
# for_command
########################################################################

238
sub for_command($) {
239 240 241 242 243 244 245 246 247
    local $_ = shift;

    return ([], []);
}

########################################################################
# gcc_command
########################################################################

248
sub gcc_command($) {
249 250 251 252
    my $read_files;
    my $write_files;

    if(/-o\s+(\S+)\s+(\S+)$/) {
253 254 255 256 257 258 259 260
	my $write_file = $1;
	my $read_file = $2;

	$write_file =~ s%^\./%%;
	$read_file =~ s%^\./%%;

	$write_files = [$write_file];
	$read_files = [$read_file];
261
    } elsif(/-o\s+(\S+)/) {
262 263 264 265 266
	my $write_file = $1;

	$write_file =~ s%^\./%%;

	$write_files = [$write_file];
267 268
	$read_files = ["<???>"];
    } elsif(/^-shared.*?-o\s+(\S+)/) {
269 270 271 272 273
	my $write_file = $1;

	$write_file =~ s%^\./%%;

	$write_files = [$write_file];
274 275
	$read_files = ["<???>"];
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
276
	error("gcc_command");
277 278 279 280 281 282 283 284 285
    }

    return ($read_files, $write_files);
}

########################################################################
# gcc_output
########################################################################

286
sub gcc_output($$) {
287 288 289 290 291 292
    $file = shift;
    local $_ = shift;

    if(s/^(\d+):\s+//) {
	$line = $1;
	if(s/^warning:\s+//) {
293
	    my $suppress = 0;
294

295
	    if(/^((?:signed |unsigned )?(?:int|long)) format, (different type|\S+) arg \(arg (\d+)\)$/) {
Patrik Stridvall's avatar
Patrik Stridvall committed
296
		my $type = $2;
297 298 299
		if($type =~ /^(?:
		   HACCEL|HACMDRIVER|HANDLE|HBITMAP|HBRUSH|HCALL|HCURSOR|HDC|HDRVR|HDESK|HDRAWDIB
		   HGDIOBJ|HKL|HGLOBAL|HIMC|HINSTANCE|HKEY|HLOCAL|
Patrik Stridvall's avatar
Patrik Stridvall committed
300
		   HMENU|HMIDISTRM|HMIDIIN|HMIDIOUT|HMIXER|HMIXEROBJ|HMMIO|HMODULE|
301 302
		   HLINE|HPEN|HPHONE|HPHONEAPP|
		   HRASCONN|HRGN|HRSRC|HWAVEIN|HWAVEOUT|HWINSTA|HWND|
303
		   SC_HANDLE|WSAEVENT|handle_t|pointer)$/x)
Patrik Stridvall's avatar
Patrik Stridvall committed
304
		{
305
		    $suppress = 1;
Patrik Stridvall's avatar
Patrik Stridvall committed
306
		} else {
307
		    $suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
308
		}
309
	    } elsif(/^\(near initialization for \`(.*?)\'\)$/) {
310
		$suppress = 0;
311
	    } elsif(/^\`(.*?)\' defined but not used$/) {
312
		$suppress = 0;
313
	    } elsif(/^\`(.*?)\' is not at beginning of declaration$/) {
314
		$suppress = 0;
315
	    } elsif(/^\`%x\' yields only last 2 digits of year in some locales$/) {
316
		$suppress = 1;
Patrik Stridvall's avatar
Patrik Stridvall committed
317
	    } elsif(/^assignment makes integer from pointer without a cast$/) {
318
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
319
	    } elsif(/^assignment makes pointer from integer without a cast$/) {
320
		$suppress = 0;
321
	    } elsif(/^assignment from incompatible pointer type$/) {
322
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
323
	    } elsif(/^cast from pointer to integer of different size$/) {
324
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
325
	    } elsif(/^comparison between pointer and integer$/) {
326
		$suppress = 0;
327
	    } elsif(/^comparison between signed and unsigned$/) {
328
		$suppress = 0;
329
	    } elsif(/^comparison of unsigned expression < 0 is always false$/) {
330
		$suppress = 0;
331
	    } elsif(/^comparison of unsigned expression >= 0 is always true$/) {
332
		$suppress = 0;
333
	    } elsif(/^conflicting types for built-in function \`(.*?)\'$/) {
334
		$suppress = 0;
335
	    } elsif(/^empty body in an if-statement$/) {
336
		$suppress = 0;
337
	    } elsif(/^empty body in an else-statement$/) {
338
		$suppress = 0;
339
	    } elsif(/^implicit declaration of function \`(.*?)\'$/) {
340
		$suppress = 0;
341
	    } elsif(/^initialization from incompatible pointer type$/) {
342
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
343
	    } elsif(/^initialization makes pointer from integer without a cast$/) {
344
		$suppress = 0;
345
	    } elsif(/^missing initializer$/) {
346
		$suppress = 0;
347
	    } elsif(/^ordered comparison of pointer with integer zero$/) {
348
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
349
	    } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') from incompatible pointer type$/) {
350
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
351
	    } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes integer from pointer without a cast$/) {
352
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
353
	    } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes pointer from integer without a cast$/) {
354
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
355
	    } elsif(/^return makes integer from pointer without a cast$/) {
356
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
357
	    } elsif(/^return makes pointer from integer without a cast$/) {
358
		$suppress = 0;
359
	    } elsif(/^type of \`(.*?)\' defaults to \`(.*?)\'$/) {
360
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
361
	    } elsif(/^unused variable \`(.*?)\'$/) {
362
		$suppress = 0;
Patrik Stridvall's avatar
Patrik Stridvall committed
363
	    } elsif(!$options->pedantic) {
364
		$suppress = 0;
365
	    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
366
		error("gcc_output");
367 368
	    }

369
	    if(!$suppress) {
370
		if($function) {
Patrik Stridvall's avatar
Patrik Stridvall committed
371
		    $message = "function $function: warning: $_";
372
		} else {
Patrik Stridvall's avatar
Patrik Stridvall committed
373
		    $message = "warning: $_";
374 375 376 377 378 379 380 381
		}
	    } else {
		$message = "";
	    }
	} elsif(/^\`(.*?)\' undeclared \(first use in this function\)$/) {
	    $message = "$_";
	} elsif(/^\(Each undeclared identifier is reported only once$/) {
	    $message = "$_";
Patrik Stridvall's avatar
Patrik Stridvall committed
382 383
	} elsif(/^conflicting types for \`(.*?)\'$/) {
	    $message = "$_";
384 385
	} elsif(/^for each function it appears in.\)$/) {
	    $message = "$_";
Patrik Stridvall's avatar
Patrik Stridvall committed
386 387 388 389
	} elsif(/^too many arguments to function$/) {
	    $message = "$_";
        } elsif(/^previous declaration of \`(.*?)\'$/) {
	    $message = "$_";
390 391
	} elsif(/^parse error before `(.*?)'$/) {
	    $message = "$_";
Patrik Stridvall's avatar
Patrik Stridvall committed
392
	} elsif(!$options->pedantic) {
393 394
	    $message = "$_";
	} else {
Patrik Stridvall's avatar
Patrik Stridvall committed
395
	    error("gcc_output");
396 397 398 399 400 401
	}
    } elsif(/^In function \`(.*?)\':$/) {
	$function = $1;
    } elsif(/^At top level:$/) {
	$function = "";
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
402
	error("gcc_output");
403 404 405 406 407 408 409
    }
}

########################################################################
# install_command
########################################################################

410
sub install_command($) {
411 412 413 414 415 416 417 418 419
    local $_ = shift;

    return ([], []);
}

########################################################################
# ld_command
########################################################################

420
sub ld_command($) {
421 422 423 424 425 426 427 428 429
    local $_ = shift;

    my $read_files;
    my $write_files;

    if(/-r\s+(.*?)\s+-o\s+(\S+)$/) {
	$write_files = [$2];
	$read_files = [split(/\s+/, $1)];
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
430
	error("ld_command");
431 432 433 434 435 436 437 438 439
    }

    return ($read_files, $write_files);
}

########################################################################
# ld_output
########################################################################

440
sub ld_output($$) {
441 442 443
    $file = shift;
    local $_ = shift;

444
    if(/^In function \`(.*?)\':$/) {
445
	$function = $1;
446 447 448
    } elsif(/^more undefined references to \`(.*?)\' follow$/) {
	# Nothing
    } elsif(/^the use of \`(.+?)\' is dangerous, better use \`(.+?)\'$/) {
449
	# Nothing
450 451 452 453 454 455
    } elsif(/^undefined reference to \`(.*?)\'$/) {
	# Nothing
    } elsif(/^warning: (.*?)\(\) possibly used unsafely; consider using (.*?)\(\)$/) {
	# Nothing
    } elsif(/^warning: type and size of dynamic symbol \`(.*?)\' are not defined$/) {
	$message = "$_";
456 457
    } else {
	$message = "$_";
458 459 460 461 462 463 464
    }
}

########################################################################
# ldconfig_command
########################################################################

465
sub ldconfig_command($) {
466 467 468 469 470 471 472 473 474
    local $_ = shift;

    return ([], []);
}

########################################################################
# makedep_command
########################################################################

475
sub makedep_command($) {
476 477 478 479 480 481 482 483 484
    local $_ = shift;

    return ([], []);
}

########################################################################
# mkdir_command
########################################################################

485
sub mkdir_command($) {
486 487 488 489 490 491 492 493 494
    local $_ = shift;

    return ([], []);
}

########################################################################
# ranlib_command
########################################################################

495
sub ranlib_command($) {
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
    local $_ = shift;

    my $read_files;
    my $write_files;

    $read_files = [split(/\s+/)];
    $write_files = [];

    return ($read_files, $write_files);
}

########################################################################
# rm_command
########################################################################

511
sub rm_command($) {
512 513 514 515 516 517 518 519 520
    local $_ = shift;
    s/^-f\s*//;
    return ([], [], [split(/\s+/, $_)]);
}

########################################################################
# sed_command
########################################################################

521
sub sed_command($) {
522 523 524 525 526 527 528 529 530
    local $_ = shift;

    return ([], []);
}

########################################################################
# strip_command
########################################################################

531
sub strip_command($) {
532 533 534 535 536 537 538 539 540
    local $_ = shift;

    return ([], []);
}

########################################################################
# winebuild_command
########################################################################

541
sub winebuild_command($) {
542 543 544 545 546 547 548 549 550
    local $_ = shift;

    return ([], []);
}

########################################################################
# winebuild_output
########################################################################

551
sub winebuild_output($$) {
552 553 554 555 556 557 558 559 560 561
    $file = shift;
    local $_ = shift;

    $message = $_;
}

########################################################################
# wmc_command
########################################################################

562
sub wmc_command($) {
563 564 565 566 567 568 569 570 571 572 573 574 575 576
    local $_ = shift;

    my $read_files;
    my $write_files;

    if(/\s+(\S+)$/) {
	my $mc_file = $1;

	my $rc_file = $mc_file;
	$rc_file =~ s/\.mc$/.rc/;

	$write_files = [$rc_file];
	$read_files = [$mc_file];
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
577
	error("wmc_command");
578 579 580 581 582 583 584 585 586
    }

    return ($read_files, $write_files);
}

########################################################################
# wmc_output
########################################################################

587
sub wmc_output($$) {
588 589 590 591 592 593 594 595
    $file = shift;
    local $_ = shift;
}

########################################################################
# wrc_command
########################################################################

596
sub wrc_command($) {
597 598 599 600 601 602 603 604 605 606 607 608 609 610
    local $_ = shift;

    my $read_files;
    my $write_files;

    if(/\s+(\S+)$/) {
	my $rc_file = $1;

	my $o_file = $rc_file;
	$o_file =~ s/\.rc$/.o/;

	$write_files = [$o_file];
	$read_files = [$rc_file];
    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
611
	error("wrc_command");
612 613 614 615 616 617 618 619 620
    }

    return ($read_files, $write_files);
}

########################################################################
# wrc_output
########################################################################

621
sub wrc_output($$) {
622 623 624 625
    $file = shift;
    local $_ = shift;
}

626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
########################################################################
# command
########################################################################

sub command($) {
    local $_ = shift;

    my $tool;
    my $file;
    my $read_files = ["<???>"];
    my $write_files = ["<???>"];
    my $remove_files = [];

    s/^\s*(.*?)\s*$/$1/;

    if(s/^\[\s+-d\s+(.*?)\s+\]\s+\|\|\s+//) {
	# Nothing
    }

    if(s/^ar\s+//) {
	$tool = "ar";
	($read_files, $write_files) = ar_command($_);
    } elsif(s/^as\s+//) {
	$tool = "as";
	($read_files, $write_files) = as_command($_);
    } elsif(s/^bison\s+//) {
	$tool = "bison";
	($read_files, $write_files) = bison_command($_);
    } elsif(s/^cd\s+//) {
	$tool = "cd";
	($read_files, $write_files) = cd_command($_);
    } elsif(s/^flex\s+//) {
	$tool = "flex";
	($read_files, $write_files) = flex_command($_);
    } elsif(s/^for\s+//) {
	$tool = "for";
	($read_files, $write_files) = for_command($_);
    } elsif(s/^\/usr\/bin\/install\s+//) {
	$tool = "install";
	($read_files, $write_files) = install_command($_);
    } elsif(s/^ld\s+//) {
	$tool = "ld";
	($read_files, $write_files) = ld_command($_);
    } elsif(s/^\/sbin\/ldconfig\s+//) {
	$tool = "ldconfig";
	($read_files, $write_files) = ldconfig_command();
    } elsif(s/^gcc\s+//) {
	$tool = "gcc";
	($read_files, $write_files) = gcc_command($_);
    } elsif(s/^(?:(?:\.\.\/)+|\.\/)tools\/makedep\s+//) {
	$tool = "makedep";
	($read_files, $write_files) = makedep_command($_);
    } elsif(s/^mkdir\s+//) {
	$tool = "mkdir";
	($read_files, $write_files) = mkdir_command($_);
    } elsif(s/^ranlib\s+//) {
	$tool = "ranlib";
	($read_files, $write_files) = ranlib_command($_);
    } elsif(s/^rm\s+//) {
	$tool = "rm";
	($read_files, $write_files, $remove_files) = rm_command($_);
    } elsif(s/^sed\s+//) {
	$tool = "sed";
	($read_files, $write_files) = sed_command($_);
    } elsif(s/^strip\s+//) {
	$tool = "sed";
	($read_files, $write_files) = strip_command($_);
    } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/winebuild\/winebuild\s+//) {
	$tool = "winebuild";
	($read_files, $write_files) = winebuild_command($_);
    } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wmc\/wmc\s+//) {
	$tool = "wmc";
	($read_files, $write_files) = wmc_command($_);
    } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wrc\/wrc\s+//) {
	$tool = "wrc";
	($read_files, $write_files) = wrc_command($_);
    }

    return ($tool, $read_files, $write_files, $remove_files);
}

########################################################################
# line
########################################################################

sub line($) {
    local $_ = shift;

    $file = "";
    $line = "";
    $message = "";

    $current = $_;

    my ($new_tool, $read_files, $write_files, $remove_files) = command($_);
    if(defined($new_tool)) {
	$tool = $new_tool;

	$function = "";

	my $progress = "";
	if($directory && $directory ne ".") {
	    $progress .= "$directory: ";
	}
	if($tool) {
	    $progress .= "$tool: ";
	}

	if($tool =~ /^(?:cd|make)$/) {
	    # Nothing
	} elsif($tool eq "ld"/) {
	    foreach my $file (@{$read_files}) {
		$output->lazy_progress("${progress}reading '$file'");
	    }
	    my $file = $$write_files[0];
	    $output->progress("$progress: writing '$file'");
	} elsif($tool eq "rm") {
	    foreach my $file (@{$remove_files}) {
		$output->lazy_progress("${progress}removing '$file'");
	    }
	} else {
	    if($#$read_files >= 0) {
		$progress .= "read[" . join(" ", @{$read_files}) . "]";
	    }
	    if($#$write_files >= 0) {
		if($#$read_files >= 0) {
		    $progress .= ", ";
		}
		$progress .= "write[" . join(" ", @{$write_files}) . "]";
	    }
	    if($#$remove_files >= 0) {
		if($#$read_files >= 0 || $#$write_files >= 0) {
		    $progress .= ", ";
		}
		$progress .= "remove[" . join(" ", @{$remove_files}) . "]";
	    }

	    $output->progress($progress);
	}

	return 0;
    }

    my $make = $options->make;

    if(/^Wine build complete\.$/) {
	# Nothing
    } elsif(/^(.*?) is newer than (.*?), please rerun (.*?)\!$/) {
	$message = "$_";
    } elsif(/^(.*?) is older than (.*?), please rerun (.*?)$/) {
	$message = "$_";
    } elsif(/^\`(.*?)\' is up to date.$/) {
	$tool = "make";
	make_output($1, $_);
    } elsif(s/^$make(?:\[(\d+)\])?:\s*//) {
	$tool = "make";
	make_output($1, $_);
    } elsif(!defined($tool)) {
	error("line");
    } elsif($tool eq "make") {
	make_output($1, $_);
    } elsif($tool eq "bison" && /^conflicts:\s+\d+\s+shift\/reduce$/) {
	# Nothing
    } elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) {
	# Nothing
    } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
	$tool = "ld";
	ld_output($1, $_)
    } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.*?)ld:\s*//) {
	$tool = "ld";
	ld_output("", $_)
    } elsif($tool =~ /^(?:gcc|ld)$/ && s/^collect2:\s*//) {
	$tool = "ld";
	ld_output("collect2", $_);
    } elsif($tool eq "gcc" && s/^(.+?\.[chly]):\s*//) {
	gcc_output($1, $_);
    } elsif($tool eq "ld" && s/^(.+?\.c):(?:\d+:)?\s*//) {
	ld_output($1, $_);
    } elsif($tool eq "winebuild" && s/^(.+?\.spec):\s*//) {
	winebuild_output($1, $_);
    } elsif($tool eq "wmc" && s/^(.+?\.mc):\s*//) {
        wmc_output($1, $_);
    } elsif($tool eq "wrc" && s/^(.+?\.rc):\s*//) {
	wrc_output($1, $_);
    } elsif($tool eq "cd" && s/^\/bin\/sh:\s*cd:\s*//) {
	parse_cd_output($_);
    } elsif(/^\s*$/) {
	# Nothing
    } else {
	error("line");
    }

    $file =~ s/^\.\///;

    return 1;
}

823
1;