#!/usr/bin/perl -w #use strict; sub read_makefile($) { my $filename=$_[0]; my $module=[]; my $perl_tests=[]; my $c_tests=[]; my $subdirs=[]; if (open(MAKEFILE,$filename)) { my $current_list; my $dirname=$filename; if (!($dirname =~ s+/[^/]*$++)) { $dirname="."; } while () { if (s/^\s*MODULE\s*=//) { $current_list=$module; } elsif (s/^\s*(INSTALL)?SUBDIRS\s*=\s*//) { $current_list=$subdirs; } elsif (s/^\s*PLTESTS\s*=//) { $current_list=$perl_tests; } elsif (s/^\s*CTESTS\s*=\s*//) { $current_list=$c_tests; } if (defined $current_list) { my $continue=(s/\\$//?1:0); s/^\s*//; push @$current_list, split /\s+/; undef $current_list if (!$continue); } } close(MAKEFILE); } return ($module,$perl_tests,$c_tests,$subdirs); } sub generate_list($) { my $list=$_[0]; foreach $item (@$list) { print MAKEFILE " \\\r\n\t$item"; } print MAKEFILE "\n" if (@$list); } sub write_win32_makefile($$$$) { my $filename=$_[0]; my $module=$_[1]; my $perl_tests=$_[2]; my $c_tests=$_[3]; open(MAKEFILE,">$filename") || die "Could not write to $filename\n"; print MAKEFILE "TOTOP = ..\\..\r\n"; # todo print MAKEFILE "\r\n"; print MAKEFILE "MODULE=@$module[0]\r\n"; print MAKEFILE "\r\n"; print MAKEFILE "PLTESTS = "; generate_list($perl_tests); print MAKEFILE "\r\n"; print MAKEFILE "CTESTS = "; generate_list($c_tests); print MAKEFILE "\r\n"; print MAKEFILE "LIBRARIES = \r\n"; # todo print MAKEFILE "\r\n"; print MAKEFILE "CC = cl -nologo -c\r\n"; print MAKEFILE "CFLAGS = -DWIN32 -D_X86_ -D__i386__\r\n"; print MAKEFILE "INCLUDE=\$(INCLUDE);\$(TOTOP)\\\$(TOPSRCDIR)\\include\r\n"; print MAKEFILE "\r\n"; print MAKEFILE "RUNTEST = \$(TOTOP)\\\$(TOPSRCDIR)\\programs\\winetest\\runtest.bat\r\n"; print MAKEFILE "RUNTESTFLAGS = -q\r\n"; print MAKEFILE "TESTRESULTS = \$(CTESTS:.c=.wok)\r\n"; print MAKEFILE "TESTPROGRAM = tests\\\$(MODULE)_test\r\n"; print MAKEFILE "TESTLIST = tests\\testlist.c\r\n"; print MAKEFILE "TESTOBJS = \$(TESTMAIN) \$(TESTLIST:.c=.obj) \$(CTESTS:.c=.obj)\r\n"; print MAKEFILE "TESTMAIN = \$(TOTOP)\\programs\\winetest\\wtmain.obj\r\n"; print MAKEFILE "\r\n"; print MAKEFILE "ctest: \$(CTESTS:.c=.wok)\r\n"; print MAKEFILE "\r\n"; print MAKEFILE "\$(CTESTS:.c=.wok): \$(TESTPROGRAM).exe\r\n"; print MAKEFILE "\r\n"; print MAKEFILE ".c.wok:\r\n"; print MAKEFILE " \$(RUNTEST) \$(TESTPROGRAM).exe \$< \$\@ \$(RUNTESTFLAGS)\r\n"; print MAKEFILE "\r\n"; print MAKEFILE ".c.obj:\r\n"; print MAKEFILE " \$(CC) \$(CFLAGS) -Fo\$*.obj \$<\r\n"; print MAKEFILE "\r\n"; print MAKEFILE "\$(TESTPROGRAM).exe: \$(TESTOBJS)\r\n"; print MAKEFILE " link -nologo -out:\$\@ \$(LDFLAGS) \$(TESTOBJS) \$(LIBRARIES)\r\n"; close(MAKEFILE); } #my ($perl_tests,$c_tests)=read_makefile($ARGV[0]); #print "perl_tests=@$perl_tests\n"; #print "c_tests=", join(",",@$c_tests),"\n"; sub convert_makefile { my $test_dirs=$_[0]; my $filename=$_[1]; my $dirname=$filename; $dirname =~ s+/[^/]*$++; print "converting $filename (in $dirname)\n"; my ($module,$perl_tests,$c_tests,$subdirs)=read_makefile($filename); if (@$perl_tests || @$c_tests) { print "$dirname has tests\n"; push @$test_dirs,$dirname; write_win32_makefile("$dirname/win32_tests.mak",$module,$perl_tests,$c_tests); } foreach $subdir (@$subdirs) { print "$dirname/$subdir/Makefile.in\n"; if (-e "$dirname/$subdir/Makefile.in") { convert_makefile($test_dirs,"$dirname/$subdir/Makefile.in"); } } } # # Main # if (-e "./Makefile.in") { my $test_dirs=[]; convert_makefile($test_dirs,"./Makefile.in"); #if (@$test_dirs) }