3 # Copyright 2002 Patrik Stridvall
8 $0 =~ m%^(.*?/?tools)/winapi/msvcmaker$%;
9 require "$1/winapi/setup.pm";
12 use config qw(&file_directory &get_spec_files &get_makefile_in_files $current_dir $wine_dir);
13 use output qw($output);
15 ########################################################################
24 return -1 if !open(IN, "< $file1");
28 return 1 if !open(IN, "< $file2");
35 ########################################################################
42 open(OUT, "> $filename.tmp") || die "Can't open file '$filename.tmp'";
44 my $result = &$function(\*OUT, @_);
48 if($result && _compare_files($filename, "$filename.tmp")) {
50 rename("$filename.tmp", $filename);
52 unlink("$filename.tmp");
58 ########################################################################
61 my @spec_files = get_spec_files("winelib");
62 my @makefile_in_files = get_makefile_in_files("winelib");
66 my $output_prefix_dir = "Output";
68 my $no_msvc_headers = 1;
72 foreach my $spec_file (@spec_files) {
73 my $module = $spec_file;
74 $module =~ s%^.*?([^/]+)\.spec$%$1%;
75 $module .= ".dll" if $module !~ /\./;
79 open(IN, "< $wine_dir/$spec_file");
83 while($lookahead || defined($_ = <IN>)) {
86 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begining and end of line
87 s/^(.*?)\s*#.*$/$1/; # remove comments
88 /^$/ && next; # skip empty lines
98 if(/^(\d+|@)\s+pascal(?:16)?/) {
106 if($module =~ /^(?:comm|imm|ole2conv|ole2prox|ole2thk|rasapi16|windebug)\.dll$/) {
110 if($type eq "win32") {
111 $modules{$module}{module} = $module;
112 $modules{$module}{type} = $type;
113 $modules{$module}{spec_file} = $spec_file;
117 my @gdi32_dirs = qw(dlls/gdi/enhmfdrv dlls/gdi/mfdrv dlls/gdi/win16drv graphics objects);
118 my @ntdll_dirs = qw(files if1632 loader/ne loader memory misc msdos ole relay32 scheduler win32);
119 my @user32_dirs = qw(controls dlls/user/dde windows);
121 push @makefile_in_files, "library/Makefile.in";
122 push @makefile_in_files, "unicode/Makefile.in";
123 push @makefile_in_files, "tools/winebuild/Makefile.in";
129 my $filtered_files = [];
130 my $rest_of_files = [];
131 foreach my $file (@$files) {
132 if($file =~ /$filter/) {
133 $file =~ s%.*?([^/]+)$%./$1%; # FIXME: Kludge
134 push @$filtered_files, $file;
136 push @$rest_of_files, $file;
139 return ($rest_of_files, $filtered_files);
142 MAKEFILE_IN: foreach my $makefile_in_file (@makefile_in_files) {
143 open(IN, "< $wine_dir/$makefile_in_file");
152 while($again || defined(my $line = <IN>)) {
165 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begining and end of line
166 s/^(.*?)\s*#.*$/$1/; # remove comments
167 /^$/ && next; # skip empty lines
174 if(/^MODULE\s*=\s*([\w\.]+)$/) {
177 if($module eq "none") {
178 if($makefile_in_file eq "library/Makefile.in") {
179 $module = "wine.dll";
180 } elsif($makefile_in_file eq "unicode/Makefile.in") {
181 $module = "wine_unicode.dll";
182 } elsif($makefile_in_file eq "tools/winebuild/Makefile.in") {
183 $module = "winebuild.exe";
188 } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
190 } elsif(/^(\w+)\s*=\s*/) {
192 my @files = split /\s+/s, $';
197 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
198 my @list = @{$vars{$1}};
201 foreach my $item (@list) {
202 $item = "$prefix$item$suffix";
205 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
208 print STDERR "unknown variable '$_'\n" if 0;
215 $vars{$var} = \@files;
224 my $source_files = [];
225 if(exists($vars{C_SRCS})) {
226 $c_srcs = [sort(@{$vars{C_SRCS}})];
227 $source_files = [sort(@{$vars{C_SRCS}})];
230 my $header_files = [];
231 if(exists($vars{H_SRCS})) {
232 $header_files = [sort(@{$vars{H_SRCS}})];
235 my $resource_files = [];
236 if(exists($vars{RC_SRCS})) {
237 $resource_files = [sort(@{$vars{RC_SRCS}})];
240 my $project = $module;
241 $project =~ s/\.(?:dll|exe|lib)$//;
245 if($module =~ /\.exe$/) {
247 } elsif($module =~ /\.lib$/) {
253 my $dsp_file = $makefile_in_file;
254 $dsp_file =~ s/Makefile.in$/$project.dsp/;
256 if($module eq "gdi32.dll") {
257 foreach my $dir (@gdi32_dirs) {
259 $dir2 =~ s%^.*?/([^/]+)$%$1%;
261 my $module = "gdi32_$dir2.lib";
264 my $project = "gdi32_$dir2";
268 my $dsp_file = "$dir/$project.dsp";
270 ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
271 ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
272 ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
274 $modules{$module}{project} = $project;
275 $modules{$module}{type} = $type;
276 $modules{$module}{dsp_file} = $dsp_file;
277 $modules{$module}{c_srcs} = $c_srcs;
278 $modules{$module}{source_files} = $local_source_files;
279 $modules{$module}{header_files} = $local_header_files;
280 $modules{$module}{resource_files} = $local_resource_files;
282 } elsif($module eq "ntdll.dll") {
283 foreach my $dir (@ntdll_dirs) {
284 my $module = "ntdll_$dir.lib";
287 my $project = "ntdll_$dir";
291 my $dsp_file = "$dir/$project.dsp";
293 ($source_files, my $local_source_files) = filter_files($source_files, "/$dir/");
294 ($header_files, my $local_header_files) = filter_files($header_files, "/$dir/");
295 ($resource_files, my $local_resource_files) = filter_files($resource_files, "/$dir/");
297 $modules{$module}{project} = $project;
298 $modules{$module}{type} = $type;
299 $modules{$module}{dsp_file} = $dsp_file;
300 $modules{$module}{c_srcs} = $c_srcs;
301 $modules{$module}{source_files} = $local_source_files;
302 $modules{$module}{header_files} = $local_header_files;
303 $modules{$module}{resource_files} = $local_resource_files;
305 } elsif($module eq "user32.dll") {
306 foreach my $dir (@user32_dirs) {
308 $dir2 =~ s%^.*?/([^/]+)$%$1%;
310 my $module = "user32_$dir2.lib";
313 my $project = "user32_$dir2";
317 my $dsp_file = "$dir/$project.dsp";
319 ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
320 ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
321 ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
323 $modules{$module}{project} = $project;
324 $modules{$module}{type} = $type;
325 $modules{$module}{dsp_file} = $dsp_file;
326 $modules{$module}{c_srcs} = $c_srcs;
327 $modules{$module}{source_files} = $local_source_files;
328 $modules{$module}{header_files} = $local_header_files;
329 $modules{$module}{resource_files} = $local_resource_files;
333 $modules{$module}{project} = $project;
334 $modules{$module}{type} = $type;
335 $modules{$module}{dsp_file} = $dsp_file;
336 $modules{$module}{c_srcs} = $c_srcs;
337 $modules{$module}{source_files} = $source_files;
338 $modules{$module}{header_files} = $header_files;
339 $modules{$module}{resource_files} = $resource_files;
342 # FIMXE: Parse the Makefile.in's instead.
344 my @wine_test_dsp_files = (
345 "dlls/gdi/tests/gdi32_test.dsp",
346 "dlls/kernel/tests/kernel32_test.dsp",
347 "dlls/ntdll/tests/ntdll_test.dsp",
348 "dlls/user/tests/user32_test.dsp",
349 "programs/winetest/winetest.dsp",
352 foreach my $dsp_file (@wine_test_dsp_files) {
353 my $project = $dsp_file;
354 $project =~ s%^.*?/([^/]+)\.dsp$%$1%;
358 my $source_files = [];
359 my $header_files = [];
360 my $resource_files = [];
362 if ($project eq "winetest") {
364 $c_srcs = ["wtmain.c"];
365 $source_files = ["wtmain.c"];
367 $resource_files = [];
370 $c_srcs = ["generated.c", "testlist.c"];
371 $source_files = ["generated.c", "testlist.c"];
373 $resource_files = [];
375 my $module = "$project.$type";
377 $modules{$module}{project} = $project;
378 $modules{$module}{type} = $type;
379 $modules{$module}{dsp_file} = $dsp_file;
380 $modules{$module}{c_srcs} = $c_srcs;
381 $modules{$module}{source_files} = $source_files;
382 $modules{$module}{header_files} = $header_files;
383 $modules{$module}{resource_files} = $resource_files;
386 foreach my $module (sort(keys(%modules))) {
387 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
388 delete $modules{$module};
393 my $progress_current = 0;
394 my $progress_max = scalar(keys(%modules));
396 foreach my $module (sort(keys(%modules))) {
397 my $dsp_file = $modules{$module}{dsp_file};
399 replace_file("$wine_dir/$dsp_file", \&_generate_dsp, $module);
407 my $dsp_file = $modules{$module}{dsp_file};
408 my $project = $modules{$module}{project};
410 my $lib = ($modules{$module}{type} eq "lib");
411 my $dll = ($modules{$module}{type} eq "dll");
412 my $exe = ($modules{$module}{type} eq "exe");
414 my $console = $exe; # FIXME: Not always correct
416 my $wine_include_dir = do {
417 my @parts = split(m%/%, $dsp_file);
420 } elsif($#parts == 2) {
423 "..\\..\\..\\include";
428 $output->progress("$dsp_file (file $progress_current of $progress_max)");
430 my @c_srcs = @{$modules{$module}{c_srcs}};
431 my @source_files = @{$modules{$module}{source_files}};
432 my @header_files = @{$modules{$module}{header_files}};
433 my @resource_files = @{$modules{$module}{resource_files}};
435 if ($project !~ /^(?:wine(?:_unicode)?|wine(?:build|test))$/ &&
436 $project !~ /^(?:gdi32|ntdll|user32)_.+?$/ &&
437 $project !~ /_test$/)
439 push @source_files, "$project.spec";
440 # push @source_files, "$project.spec.c";
441 @source_files = sort(@source_files);
445 if($no_release && $no_msvc_headers) {
446 push @cfgs, "$project - Win32";
447 } elsif($no_release && !$no_msvc_headers) {
448 push @cfgs, "$project - Win32 MS Headers";
449 push @cfgs, "$project - Win32 Wine Headers";
450 } elsif(!$no_release && $no_msvc_headers) {
451 push @cfgs, "$project - Win32 Release";
452 push @cfgs, "$project - Win32 Debug";
454 push @cfgs, "$project - Win32 Release MS Headers";
455 push @cfgs, "$project - Win32 Debug MS Headers";
456 push @cfgs, "$project - Win32 Release Wine Headers";
457 push @cfgs, "$project - Win32 Debug Wine Headers";
459 my $default_cfg = $cfgs[$#cfgs];
461 my $msvc_include = "d:\\program files\\microsoft visual studio\\vc98\\include";
463 print OUT "# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
464 print OUT "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
465 print OUT "# ** DO NOT EDIT **\r\n";
469 print OUT "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
471 print OUT "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
473 print OUT "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
477 print OUT "CFG=$default_cfg\r\n";
478 print OUT "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
479 print OUT "!MESSAGE use the Export Makefile command and run\r\n";
480 print OUT "!MESSAGE \r\n";
481 print OUT "!MESSAGE NMAKE /f \"$project.mak\".\r\n";
482 print OUT "!MESSAGE \r\n";
483 print OUT "!MESSAGE You can specify a configuration when running NMAKE\r\n";
484 print OUT "!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
485 print OUT "!MESSAGE \r\n";
486 print OUT "!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
487 print OUT "!MESSAGE \r\n";
488 print OUT "!MESSAGE Possible choices for configuration are:\r\n";
489 print OUT "!MESSAGE \r\n";
490 foreach my $cfg (@cfgs) {
492 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
494 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
496 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
499 print OUT "!MESSAGE \r\n";
502 print OUT "# Begin Project\r\n";
503 print OUT "# PROP AllowPerConfigDependencies 0\r\n";
504 print OUT "# PROP Scc_ProjName \"\"\r\n";
505 print OUT "# PROP Scc_LocalPath \"\"\r\n";
506 print OUT "CPP=cl.exe\r\n";
507 print OUT "MTL=midl.exe\r\n" if !$lib && !$exe;
508 print OUT "RSC=rc.exe\r\n";
513 foreach my $cfg (@cfgs) {
517 print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
521 print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
525 my $debug = ($cfg !~ /Release/);
526 my $msvc_headers = ($cfg =~ /MS Headers/);
528 print OUT "# PROP BASE Use_MFC 0\r\n";
531 print OUT "# PROP BASE Use_Debug_Libraries 1\r\n";
533 print OUT "# PROP BASE Use_Debug_Libraries 0\r\n";
537 $output_dir =~ s/^$project -//;
538 $output_dir =~ s/ //g;
539 if($output_prefix_dir) {
540 $output_dir = "$output_prefix_dir\\$output_dir";
543 print OUT "# PROP BASE Output_Dir \"$output_dir\"\r\n";
544 print OUT "# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
546 print OUT "# PROP BASE Target_Dir \"\"\r\n";
548 print OUT "# PROP Use_MFC 0\r\n";
550 print OUT "# PROP Use_Debug_Libraries 1\r\n";
552 print OUT "# PROP Use_Debug_Libraries 0\r\n";
554 print OUT "# PROP Output_Dir \"$output_dir\"\r\n";
555 print OUT "# PROP Intermediate_Dir \"$output_dir\"\r\n";
557 print OUT "# PROP Ignore_Export_Lib 0\r\n" if $dll;
558 print OUT "# PROP Target_Dir \"\"\r\n";
563 print OUT "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od";
564 @defines = (qw(WIN32 _DEBUG _MBCS _LIB));
566 print OUT "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od";
567 @defines = (qw(WIN32 _DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
571 print OUT "# ADD BASE CPP /nologo /W3 /GX /O2";
572 @defines = (qw(WIN32 NDEBUG _MBCS _LIB));
574 print OUT "# ADD BASE CPP /nologo /MT /W3 /GX /O2";
575 @defines = (qw(WIN32 NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
579 foreach my $define (@defines) {
580 print OUT " /D \"$define\"";
582 print OUT " /YX" if $lib || $exe;
584 print OUT " /GZ" if $debug;
585 print OUT " " if $debug && ($lib || $exe);
592 print OUT "# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od";
593 @defines2 = qw(WIN32 _DEBUG _WINDOWS _MBCS _LIB);
595 print OUT "# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od";
596 @defines2 = qw(_DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
600 print OUT "# ADD CPP /nologo /MT /W3 /GX /O2";
601 @defines2 = qw(WIN32 NDEBUG _WINDOWS _MBCS _LIB);
603 print OUT "# ADD CPP /nologo /MT /W3 /GX /O2";
604 @defines2 = qw(NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
610 push @defines2, "_\U${project}\E_";
611 push @defines2, "__WINE__" if $module !~ /^winebuild\.exe$/;
612 push @defines2, qw(__i386__ _X86_);
615 push @includes, $msvc_include;
618 if($project =~ /^gdi32_(?:enhmfdrv|mfdrv|win16drv)$/) {
619 push @includes, "..";
622 if($project =~ /^user32_(?:controls|windows)$/) {
623 push @includes, "..\\dlls\\user";
626 if($project =~ /^user32_dde$/) {
627 push @includes, "..";
630 push @includes, $wine_include_dir;
634 print OUT " /X" if $msvc_headers;
636 foreach my $include (@includes) {
637 print OUT " /I \"$include\"";
641 foreach my $define (@defines2) {
642 print OUT " /D \"$define\"";
644 print OUT " /D inline=__inline" if $wine;
645 print OUT " /D \"__STDC__\"" if 0 && $wine;
647 print OUT " /YX" if $lib;
648 print OUT " /FR" if !$lib;
650 print OUT " /GZ" if $debug;
651 print OUT " " if $debug && $lib;
656 print OUT "# SUBTRACT CPP /X /YX\r\n" if $dll;
657 print OUT "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
658 print OUT "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
659 print OUT "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
660 print OUT "# ADD RSC /l 0x41d";
662 foreach my $include (@includes) {
663 print OUT " /i \"$include\"";
666 print OUT " /d \"_DEBUG\"\r\n";
668 print OUT "# SUBTRACT CPP /YX\r\n" if $dll;
669 print OUT "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
670 print OUT "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
671 print OUT "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
672 print OUT "# ADD RSC /l 0x41d";
674 foreach my $include (@includes) {
675 print OUT " /i \"$include\"";
678 print OUT "/d \"NDEBUG\"\r\n";
680 print OUT "BSC32=bscmake.exe\r\n";
681 print OUT "# ADD BASE BSC32 /nologo\r\n";
682 print OUT "# ADD BSC32 /nologo\r\n";
685 print OUT "LINK32=link.exe\r\n";
686 print OUT "# ADD BASE LINK32 ";
687 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
688 comdlg32.lib advapi32.lib shell32.lib ole32.lib
689 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
690 foreach my $library (@libraries) {
691 print OUT "$library ";
693 print OUT " /nologo";
694 print OUT " /dll" if $dll;
695 print OUT " /subsystem:console" if $console;
696 print OUT " /debug" if $debug;
697 print OUT " /machine:I386";
698 print OUT " /pdbtype:sept" if $debug;
701 print OUT "# ADD LINK32";
702 print OUT " /nologo";
703 print OUT " libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
704 print OUT " /dll" if $dll;
705 print OUT " /subsystem:console" if $console;
706 print OUT " /debug" if $debug;
707 print OUT " /machine:I386";
708 print OUT " /nodefaultlib" if $project =~ /^ntdll$/; # FIXME: Kludge
709 print OUT " /def:\"$project.def\"" if $dll;
710 print OUT " /pdbtype:sept" if $debug;
713 print OUT "LIB32=link.exe -lib\r\n";
714 print OUT "# ADD BASE LIB32 /nologo\r\n";
715 print OUT "# ADD LIB32 /nologo\r\n";
723 print OUT "!ENDIF \r\n";
727 if($project eq "winebuild") {
728 print OUT "# Begin Special Build Tool\r\n";
729 print OUT "SOURCE=\"\$(InputPath)\"\r\n";
730 print OUT "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n";
731 print OUT "PostBuild_Cmds=";
732 print OUT "copy ..\\..\\library\\$output_dir\\wine.dll \$(OutDir)\t";
733 print OUT "copy ..\\..\\unicode\\$output_dir\\wine_unicode.dll \$(OutDir)\r\n";
734 print OUT "# End Special Build Tool\r\n";
736 print OUT "# Begin Target\r\n";
738 foreach my $cfg (@cfgs) {
739 print OUT "# Name \"$cfg\"\r\n";
742 print OUT "# Begin Group \"Source Files\"\r\n";
744 print OUT "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
746 foreach my $source_file (@source_files) {
747 $source_file =~ s%/%\\%g;
748 if($source_file !~ /^\./) {
749 $source_file = ".\\$source_file";
752 if($source_file =~ /^(.*?)\.spec$/) {
755 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
756 my $dbg_c_file = "$basename.dbg.c";
758 print OUT "# Begin Source File\r\n";
760 print OUT "SOURCE=$dbg_c_file\r\n";
761 print OUT "# End Source File\r\n";
764 print OUT "# Begin Source File\r\n";
767 print OUT "SOURCE=$source_file\r\n";
769 if($source_file =~ /^(.*?)\.spec$/) {
772 my $spec_file = $source_file;
773 my $def_file = "$basename.def";
775 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
776 my $dbg_file = "$basename.dbg";
777 my $dbg_c_file = "$basename.dbg.c";
779 my $srcdir = "."; # FIXME: Is this really always correct?
781 print OUT "# Begin Custom Build\r\n";
782 print OUT "InputPath=$spec_file\r\n";
784 print OUT "BuildCmds= \\\r\n";
785 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe -def $spec_file > $def_file \\\r\n";
787 if($project =~ /^ntdll$/) {
789 foreach my $c_src (@c_srcs) {
791 print OUT "\techo $c_src >> $dbg_file \\\r\n";
793 print OUT "\techo $c_src > $dbg_file \\\r\n";
796 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
797 print OUT " -o $dbg_c_file -debug -C$srcdir $dbg_file \\\r\n";
799 my $c_srcs = join(" ", grep(/\.c$/, @c_srcs));
801 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
802 print OUT " -o $dbg_c_file -debug -C$srcdir $c_srcs \\\r\n";
807 print OUT "\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
808 print OUT " \$(BuildCmds)\r\n";
810 print OUT "\"$dbg_c_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
811 print OUT " \$(BuildCmds)\r\n";
812 print OUT "# End Custom Build\r\n";
815 print OUT "# End Source File\r\n";
817 print OUT "# End Group\r\n";
819 print OUT "# Begin Group \"Header Files\"\r\n";
821 print OUT "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
822 foreach my $header_file (@header_files) {
823 print OUT "# Begin Source File\r\n";
825 print OUT "SOURCE=.\\$header_file\r\n";
826 print OUT "# End Source File\r\n";
828 print OUT "# End Group\r\n";
832 print OUT "# Begin Group \"Resource Files\"\r\n";
834 print OUT "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
835 foreach my $resource_file (@resource_files) {
836 print OUT "# Begin Source File\r\n";
838 print OUT "SOURCE=.\\$resource_file\r\n";
839 print OUT "# End Source File\r\n";
841 print OUT "# End Group\r\n";
843 print OUT "# End Target\r\n";
844 print OUT "# End Project\r\n";
849 sub _generate_dsw_header {
852 print OUT "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
853 print OUT "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
857 sub _generate_dsw_project {
861 my $dsp_file = shift;
862 my @dependencies = @{(shift)};
864 $dsp_file = "./$dsp_file";
865 $dsp_file =~ y%/%\\%;
867 @dependencies = sort(@dependencies);
869 print OUT "###############################################################################\r\n";
871 print OUT "Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
873 print OUT "Package=<5>\r\n";
877 print OUT "Package=<4>\r\n";
879 foreach my $dependency (@dependencies) {
880 print OUT " Begin Project Dependency\r\n";
881 print OUT " Project_Dep_Name $dependency\r\n";
882 print OUT " End Project Dependency\r\n";
888 sub _generate_dsw_footer {
891 print OUT "###############################################################################\r\n";
893 print OUT "Global:\r\n";
895 print OUT "Package=<5>\r\n";
899 print OUT "Package=<3>\r\n";
903 print OUT "###############################################################################\r\n";
908 my $dsw_file = "wine.dsw";
909 $output->progress("$dsw_file");
910 replace_file("$wine_dir/$dsw_file", \&_generate_wine_dsw);
913 sub _generate_wine_dsw {
916 _generate_dsw_header(\*OUT);
917 foreach my $module (sort(keys(%modules))) {
918 next if $module =~ /(?:winetest\.lib|_test\.exe)$/;
920 my $project = $modules{$module}{project};
921 my $dsp_file = $modules{$module}{dsp_file};
924 if($project =~ /^wine(?:_unicode)?$/) {
926 } elsif($project =~ /^winebuild$/) {
927 @dependencies = ("wine", "wine_unicode");
928 } elsif($project =~ /^(?:gdi32|ntdll|user32)_.+?$/) {
931 @dependencies = ("wine", "wine_unicode", "winebuild");
934 if($project =~ /^gdi32$/) {
935 foreach my $dir (@gdi32_dirs) {
937 $dir2 =~ s%^.*?/([^/]+)$%$1%;
939 my $module = "gdi32_$dir2";
941 push @dependencies, $module;
943 } elsif($project =~ /^ntdll$/) {
944 foreach my $dir (@ntdll_dirs) {
945 my $module = "ntdll_$dir";
947 push @dependencies, $module;
949 } elsif($project =~ /^user32$/) {
950 foreach my $dir (@user32_dirs) {
952 $dir2 =~ s%^.*?/([^/]+)$%$1%;
954 my $module = "user32_$dir2";
956 push @dependencies, $module;
960 _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
962 _generate_dsw_footer(\*OUT);
968 my $dsw_file = "winetest.dsw";
969 $output->progress("$dsw_file");
970 replace_file("$wine_dir/$dsw_file", \&_generate_winetest_dsw);
973 sub _generate_winetest_dsw {
976 _generate_dsw_header(\*OUT);
978 foreach my $module (sort(keys(%modules))) {
979 next if $module !~ /(?:winetest\.lib|_test\.exe)$/;
981 my $project = $modules{$module}{project};
982 my $dsp_file = $modules{$module}{dsp_file};
985 if($project =~ /^winetest$/) {
988 @dependencies = ("winetest");
991 _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
994 _generate_dsw_footer(\*OUT);
998 foreach my $module (sort(keys(%modules))) {
999 next if $module !~ /_test\.exe$/;
1001 my $project = $modules{$module}{project};
1002 my $dsp_file = $modules{$module}{dsp_file};
1004 my $testlist_c = $dsp_file;
1005 $testlist_c =~ s%[^/]*\.dsp$%testlist.c%;
1007 replace_file("$wine_dir/$testlist_c", \&_generate_testlist_c);
1011 sub _generate_testlist_c {
1014 my @tests = qw(generated); # FIXME: Not alway correct
1016 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1018 foreach my $test (@tests) {
1019 print OUT "extern void func_$test(void);\n";
1022 print OUT "const struct\n";
1024 print OUT " const char *name;\n";
1025 print OUT " void (*func)(void);\n";
1026 print OUT "} winetest_testlist[] =\n";
1028 foreach my $test (@tests) {
1029 print OUT " { \"$test\", func_$test },\n";
1031 print OUT " { 0, 0 }\n";
1036 my $config_h = "include/config.h";
1038 $output->progress("$config_h");
1040 replace_file("$wine_dir/$config_h", \&_generate_config_h);
1043 sub _generate_config_h {
1046 print OUT "#define __WINE_CONFIG_H\n";
1049 my @headers = qw(direct.h io.h);
1050 foreach my $header (@headers) {
1051 $header =~ y/\.\//__/;
1052 print OUT "#define HAVE_\U$header\E\n";
1057 _alldiv _allmul _allrem _aulldiv _aullrem
1058 _access _chdir _close _lseek _mkdir _open _pclose _popen _read _rmdir _write _stat
1059 _snprintf _stricmp _strnicmp _vsnprintf _wcsicmp wcslen
1063 foreach my $function (@functions) {
1064 print OUT "#define HAVE_\U$function\E 1\n";
1069 print OUT "#define NEED_STDCALL_DECORATION 1\n";
1073 print OUT "#define X_DISPLAY_MISSING 1\n";
1076 print OUT "/* Define to a macro to generate an assembly function directive */\n";
1077 print OUT "#define __ASM_FUNC(name) \"\"\n";
1080 print OUT "/* Define to a macro to generate an assembly name from a C symbol */\n";
1081 print OUT "#define __ASM_NAME(name) name\n";
1084 print OUT "/* Define to the address where bug reports for this package should be sent. */\n";
1085 print OUT "#define PACKAGE_BUGREPORT \"\"\n";
1088 print OUT "/* Define to the full name of this package. */\n";
1089 print OUT "#define PACKAGE_NAME \"Wine\"\n";
1092 print OUT "/* Define to the full name and version of this package. */\n";
1093 print OUT "#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1096 print OUT "/* Define to the one symbol short name of this package. */\n";
1097 print OUT "#define PACKAGE_TARNAME \"wine\"\n";
1100 print OUT "/* Define to the version of this package. */\n";
1101 print OUT "#define PACKAGE_VERSION \"YYYYMMDD\"\n";