3 # Copyright 2002 Patrik Stridvall
8 $0 =~ m%^(.*?/?tools)/winapi/msvcmaker$%;
9 require "$1/winapi/setup.pm";
12 use setup qw($current_dir $wine_dir);
13 use lib $setup::winapi_dir;
14 use config qw(get_spec_files get_makefile_in_files);
15 use output qw($output);
16 use util qw(replace_file);
18 use msvcmaker_options qw($options);
20 if($options->progress) {
21 $output->enable_progress;
23 $output->disable_progress;
26 ########################################################################
29 my @spec_files = get_spec_files("winelib");
30 my @makefile_in_files = get_makefile_in_files("winelib");
34 my $output_prefix_dir = "Output";
39 sub read_spec_file($) {
40 my $spec_file = shift;
42 my $module = $spec_file;
43 $module =~ s%^.*?([^/]+)\.spec$%$1%;
44 $module .= ".dll" if $module !~ /\./;
48 open(IN, "< $wine_dir/$spec_file") || die "Error: Can't open $wine_dir/$spec_file: $!\n";
52 while($lookahead || defined($_ = <IN>)) {
55 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
56 s/^(.*?)\s*#.*$/$1/; # remove comments
57 /^$/ && next; # skip empty lines
67 if(/^(\d+|@)\s+pascal(?:16)?/) {
75 if($module =~ /^(?:(?:imm|ole2conv|ole2prox|ole2thk|rasapi16|msacm|windebug)\.dll|comm\.drv)$/) {
79 if($type eq "win32") {
80 $modules{$module}{module} = $module;
81 $modules{$module}{type} = $type;
82 $modules{$module}{spec_file} = $spec_file;
86 if ($options->wine || $options->winetest) {
87 foreach my $spec_file (@spec_files) {
88 read_spec_file($spec_file);
92 my @gdi32_dirs = qw(dlls/gdi/enhmfdrv dlls/gdi/mfdrv);
94 push @makefile_in_files, "libs/wine/Makefile.in";
95 push @makefile_in_files, "tools/winebuild/Makefile.in";
97 sub filter_files($$) {
101 my $filtered_files = [];
102 my $rest_of_files = [];
103 foreach my $file (@$files) {
104 if($file =~ /$filter/) {
105 $file =~ s%.*?([^/]+)$%./$1%; # FIXME: Kludge
106 push @$filtered_files, $file;
108 push @$rest_of_files, $file;
111 return ($rest_of_files, $filtered_files);
114 my %wine_test_dsp_files;
116 MAKEFILE_IN: foreach my $makefile_in_file (@makefile_in_files) {
117 open(IN, "< $wine_dir/$makefile_in_file") || die "Error: Can't open $wine_dir/$makefile_in_file: $!\n";
129 if($makefile_in_file eq "loader/Makefile.in") {
133 while($again || defined(my $line = <IN>)) {
146 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
147 s/^(.*?)\s*#.*$/$1/; # remove comments
148 /^$/ && next; # skip empty lines
155 if(/^MODULE\s*=\s*([\w\.]+)$/) {
158 if($module eq "none") {
159 if($makefile_in_file eq "tools/winebuild/Makefile.in") {
160 $module = "winebuild.exe";
165 } elsif(/^LIBRARY\s*=\s*(\S+)\s*$/) {
166 $module = $1 . "\.lib";
167 } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
169 } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
171 } elsif (/^IMPORTS\s*=\s*/) {
172 push @imports, grep !/^ntdll$/, split /\s+/s, $';
173 } elsif (/^EXTRALIBS\s*=\s*/) {
174 push @imports, map { /^-l(dxerr8|dxerr9|dxguid|strmiids|uuid)$/ ? $1 : () } split /\s+/s, $';
175 } elsif (/^CTESTS\s*=\s*/) {
176 my @files = split /\s+/s, $';
178 my $dir = $makefile_in_file;
179 $dir =~ s/\/Makefile\.in$//;
181 my $dsp_file = $testdll;
182 $dsp_file =~ s/\.(dll|drv)$/_test.dsp/;
183 $dsp_file = "$dir/$dsp_file";
185 $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
186 $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
187 } elsif(/^(\w+)\s*=\s*/) {
189 my @files = split /\s+/s, $';
192 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
193 my @list = @{$vars{$1}};
196 foreach my $item (@list) {
197 $item = "$prefix$item$suffix";
200 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
203 print STDERR "unknown variable '$_'\n" if 0;
210 $vars{$var} = \@files;
219 my $source_files = [];
220 if(exists($vars{C_SRCS})) {
221 $c_srcs = [sort(@{$vars{C_SRCS}})];
222 $source_files = [sort(@{$vars{C_SRCS}})];
225 my $header_files = [];
226 if(exists($vars{H_SRCS})) {
227 $header_files = [sort(@{$vars{H_SRCS}})];
230 my $resource_files = [];
231 if(exists($vars{RC_SRCS})) {
232 $resource_files = [sort(@{$vars{RC_SRCS}})];
235 my $project = $module;
236 $project =~ s/\.(?:dll|exe|lib)$//;
240 if($module =~ /\.exe$/) {
242 } elsif($module =~ /\.lib$/) {
248 my $dsp_file = $makefile_in_file;
249 $dsp_file =~ s/Makefile.in$/$project.dsp/;
251 if($module eq "gdi32.dll") {
252 foreach my $dir (@gdi32_dirs) {
254 $dir2 =~ s%^.*?/([^/]+)$%$1%;
256 my $module = "gdi32_$dir2.lib";
259 my $project = "gdi32_$dir2";
263 my $dsp_file = "$dir/$project.dsp";
265 ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
266 ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
267 ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
269 $modules{$module}{wine} = 1;
270 $modules{$module}{winetest} = 0;
271 $modules{$module}{project} = $project;
272 $modules{$module}{type} = $type;
273 $modules{$module}{dsp_file} = $dsp_file;
274 $modules{$module}{c_srcs} = $c_srcs;
275 $modules{$module}{source_files} = $local_source_files;
276 $modules{$module}{header_files} = $local_header_files;
277 $modules{$module}{resource_files} = $local_resource_files;
278 $modules{$module}{imports} = [];
282 $modules{$module}{wine} = 1;
283 $modules{$module}{winetest} = 0;
284 $modules{$module}{project} = $project;
285 $modules{$module}{type} = $type;
286 $modules{$module}{dsp_file} = $dsp_file;
287 $modules{$module}{c_srcs} = $c_srcs;
288 $modules{$module}{source_files} = $source_files;
289 $modules{$module}{header_files} = $header_files;
290 $modules{$module}{resource_files} = $resource_files;
291 $modules{$module}{imports} = [];
294 $wine_test_dsp_files{"wineruntests.dsp"}{files} = ["runtests.c"];
295 $wine_test_dsp_files{"wineruntests.dsp"}{imports} = [];
297 $wine_test_dsp_files{"winetest.dsp"}{files} = [
298 'include/wine/exception.h',
299 'include/wine/test.h',
300 'include/wine/unicode.h',
303 $wine_test_dsp_files{"winetest.dsp"}{imports} = [];
307 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
308 my $project = $dsp_file;
309 $project =~ s%^(?:.*?/)?([^/]+)\.dsp$%$1%;
311 my @files = @{$wine_test_dsp_files{$dsp_file}{files}};
312 my @imports = @{$wine_test_dsp_files{$dsp_file}{imports}};
316 my $source_files = [];
317 my $header_files = [];
318 my $resource_files = [];
322 if ($project eq "winetest") {
325 $source_files = [@files];
327 $resource_files = [];
328 } elsif ($project eq "wineruntests") {
331 $source_files = [@files];
333 $resource_files = [];
337 $source_files = [@files];
339 $resource_files = [];
342 if (/^testlist\.c$/) {
350 $runtests{$dsp_file} = [@tests];
352 my $module = "$project.$type";
354 $modules{$module}{wine} = 0;
355 $modules{$module}{winetest} = 1;
357 $modules{$module}{project} = $project;
358 $modules{$module}{type} = $type;
359 $modules{$module}{dsp_file} = $dsp_file;
360 $modules{$module}{c_srcs} = $c_srcs;
361 $modules{$module}{source_files} = $source_files;
362 $modules{$module}{header_files} = $header_files;
363 $modules{$module}{resource_files} = $resource_files;
364 $modules{$module}{imports} = [@imports];
366 $modules{$module}{tests} = [@tests];
369 foreach my $module (sort(keys(%modules))) {
370 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
371 delete $modules{$module};
376 foreach my $module (sort(keys(%modules))) {
377 if (($options->wine && $modules{$module}{wine}) ||
378 ($options->winetest && $modules{$module}{winetest}))
380 push @modules, $module;
385 my $progress_current = 0;
386 my $progress_max = scalar(@modules);
388 foreach my $module (@modules) {
389 my $dsp_file = $modules{$module}{dsp_file};
390 replace_file("$wine_dir/$dsp_file", \&_generate_dsp, $module);
393 sub _generate_dsp($$) {
398 my $dsp_file = $modules{$module}{dsp_file};
399 my $project = $modules{$module}{project};
400 my @imports = @{$modules{$module}{imports}};
402 my $lib = ($modules{$module}{type} eq "lib");
403 my $dll = ($modules{$module}{type} eq "dll");
404 my $exe = ($modules{$module}{type} eq "exe");
406 my $console = $exe; # FIXME: Not always correct
408 my $msvc_wine_dir = do {
409 my @parts = split(m%/%, $dsp_file);
412 } elsif($#parts == 2) {
418 my $wine_include_dir = "$msvc_wine_dir\\include";
421 $output->progress("$dsp_file (file $progress_current of $progress_max)");
423 my @c_srcs = @{$modules{$module}{c_srcs}};
424 my @source_files = @{$modules{$module}{source_files}};
425 my @header_files = @{$modules{$module}{header_files}};
426 my @resource_files = @{$modules{$module}{resource_files}};
428 if ($project !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
429 $project !~ /^(?:gdi32)_.+?$/ &&
430 $project !~ /_test$/)
432 push @source_files, "$project.spec";
433 # push @source_files, "$project.spec.c";
434 @source_files = sort(@source_files);
438 my $no_msvc_headers = 1;
439 if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
440 $no_msvc_headers = 0;
445 push @cfgs, "$project - Win32";
449 foreach my $cfg (@cfgs) {
450 push @_cfgs, "$cfg C";
451 push @_cfgs, "$cfg C++";
458 foreach my $cfg (@cfgs) {
459 push @_cfgs, "$cfg Debug";
460 push @_cfgs, "$cfg Release";
465 if (!$no_msvc_headers) {
467 foreach my $cfg (@cfgs) {
468 push @_cfgs, "$cfg MSVC Headers";
469 push @_cfgs, "$cfg Wine Headers";
474 my $default_cfg = $cfgs[$#cfgs];
476 print OUT "# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
477 print OUT "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
478 print OUT "# ** DO NOT EDIT **\r\n";
482 print OUT "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
484 print OUT "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
486 print OUT "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
490 print OUT "CFG=$default_cfg\r\n";
491 print OUT "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
492 print OUT "!MESSAGE use the Export Makefile command and run\r\n";
493 print OUT "!MESSAGE \r\n";
494 print OUT "!MESSAGE NMAKE /f \"$project.mak\".\r\n";
495 print OUT "!MESSAGE \r\n";
496 print OUT "!MESSAGE You can specify a configuration when running NMAKE\r\n";
497 print OUT "!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
498 print OUT "!MESSAGE \r\n";
499 print OUT "!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
500 print OUT "!MESSAGE \r\n";
501 print OUT "!MESSAGE Possible choices for configuration are:\r\n";
502 print OUT "!MESSAGE \r\n";
503 foreach my $cfg (@cfgs) {
505 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
507 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
509 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
512 print OUT "!MESSAGE \r\n";
515 print OUT "# Begin Project\r\n";
516 print OUT "# PROP AllowPerConfigDependencies 0\r\n";
517 print OUT "# PROP Scc_ProjName \"\"\r\n";
518 print OUT "# PROP Scc_LocalPath \"\"\r\n";
519 print OUT "CPP=cl.exe\r\n";
520 print OUT "MTL=midl.exe\r\n" if !$lib && !$exe;
521 print OUT "RSC=rc.exe\r\n";
526 foreach my $cfg (@cfgs) {
530 print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
534 print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
538 my $debug = ($cfg !~ /Release/);
539 my $msvc_headers = ($cfg =~ /MSVC Headers/);
541 print OUT "# PROP BASE Use_MFC 0\r\n";
544 print OUT "# PROP BASE Use_Debug_Libraries 1\r\n";
546 print OUT "# PROP BASE Use_Debug_Libraries 0\r\n";
550 $output_dir =~ s/^$project - //;
551 $output_dir =~ s/ /_/g;
552 $output_dir =~ s/C\+\+/Cxx/g;
553 if($output_prefix_dir) {
554 $output_dir = "$output_prefix_dir\\$output_dir";
557 print OUT "# PROP BASE Output_Dir \"$output_dir\"\r\n";
558 print OUT "# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
560 print OUT "# PROP BASE Target_Dir \"\"\r\n";
562 print OUT "# PROP Use_MFC 0\r\n";
564 print OUT "# PROP Use_Debug_Libraries 1\r\n";
566 print OUT "# PROP Use_Debug_Libraries 0\r\n";
568 print OUT "# PROP Output_Dir \"$output_dir\"\r\n";
569 print OUT "# PROP Intermediate_Dir \"$output_dir\"\r\n";
571 print OUT "# PROP Ignore_Export_Lib 0\r\n" if $dll;
572 print OUT "# PROP Target_Dir \"\"\r\n";
577 print OUT "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od";
578 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _MBCS _LIB));
580 print OUT "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
581 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
585 print OUT "# ADD BASE CPP /nologo /W3 /GX /O2";
586 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _MBCS _LIB));
588 print OUT "# ADD BASE CPP /nologo /MT /W3 /GX /O2";
589 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
593 foreach my $define (@defines) {
594 print OUT " /D \"$define\"";
596 print OUT " /YX" if $lib || $exe;
598 print OUT " /GZ" if $debug;
599 print OUT " " if $debug && ($lib || $exe);
606 print OUT "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
607 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _LIB);
609 print OUT "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
610 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 _DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
614 print OUT "# ADD CPP /nologo /MT /W3 /GX /O2";
615 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _WINDOWS _MBCS _LIB);
617 print OUT "# ADD CPP /nologo /MT /W3 /GX /O2";
618 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
624 push @defines2, "_\U${project}\E_";
625 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
627 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
629 my $output_dir2 = $output_dir;
630 $output_dir =~ s/\\/\\\\/g;
631 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\"";
632 push @defines2, qw(__i386__ _X86_);
634 if($project =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
635 push @includes, "..";
638 if ($project =~ /_test$/) {
639 push @includes, "$msvc_wine_dir\\$output_dir";
642 if (!$msvc_headers || $project eq "winetest") {
643 push @includes, $wine_include_dir;
648 foreach my $include (@includes) {
649 if ($include !~ /[\\\"]/) {
650 print OUT " /I \"$include\"";
652 print OUT " /I $include";
657 foreach my $define (@defines2) {
658 if ($define !~ /[\\\"]/) {
659 print OUT " /D \"$define\"";
661 print OUT " /D $define";
664 print OUT " /D inline=__inline" if $wine;
665 print OUT " /D \"__STDC__\"" if 0 && $wine;
667 print OUT " /YX" if $lib;
668 print OUT " /FR" if !$lib;
670 print OUT " /GZ" if $debug;
671 print OUT " " if $debug && $lib;
673 print OUT " /TP" if !$no_cpp;
677 print OUT "# SUBTRACT CPP /X /YX\r\n" if $dll;
678 print OUT "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
679 print OUT "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
680 print OUT "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
681 print OUT "# ADD RSC /l 0x41d";
683 foreach my $include (@includes) {
684 print OUT " /i \"$include\"";
687 print OUT " /d \"_DEBUG\"\r\n";
689 print OUT "# SUBTRACT CPP /YX\r\n" if $dll;
690 print OUT "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
691 print OUT "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
692 print OUT "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
693 print OUT "# ADD RSC /l 0x41d";
695 foreach my $include (@includes) {
696 print OUT " /i \"$include\"";
699 print OUT "/d \"NDEBUG\"\r\n";
701 print OUT "BSC32=bscmake.exe\r\n";
702 print OUT "# ADD BASE BSC32 /nologo\r\n";
703 print OUT "# ADD BSC32 /nologo\r\n";
706 print OUT "LINK32=link.exe\r\n";
707 print OUT "# ADD BASE LINK32 ";
708 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
709 comdlg32.lib advapi32.lib shell32.lib ole32.lib
710 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
711 foreach my $library (@libraries) {
712 print OUT "$library ";
714 print OUT " /nologo";
715 print OUT " /dll" if $dll;
716 print OUT " /subsystem:console" if $console;
717 print OUT " /debug" if $debug;
718 print OUT " /machine:I386";
719 print OUT " /pdbtype:sept" if $debug;
722 print OUT "# ADD LINK32";
723 print OUT " /nologo";
724 print OUT " libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
725 foreach my $import (@imports) {
726 print OUT " $import.lib" if ($import ne "msvcrt");
728 print OUT " /dll" if $dll;
729 print OUT " /subsystem:console" if $console;
730 print OUT " /debug" if $debug;
731 print OUT " /machine:I386";
732 print OUT " /nodefaultlib" if $project =~ /^ntdll$/; # FIXME: Kludge
733 print OUT " /def:\"$project.def\"" if $dll;
734 print OUT " /pdbtype:sept" if $debug;
737 print OUT "LIB32=link.exe -lib\r\n";
738 print OUT "# ADD BASE LIB32 /nologo\r\n";
739 print OUT "# ADD LIB32 /nologo\r\n";
747 print OUT "!ENDIF \r\n";
751 if ($project eq "winebuild") {
752 print OUT "# Begin Special Build Tool\r\n";
753 print OUT "SOURCE=\"\$(InputPath)\"\r\n";
754 print OUT "PostBuild_Desc=Copying wine.lib and wine_unicode.lib ...\r\n";
755 print OUT "PostBuild_Cmds=";
756 print OUT "copy ..\\..\\libs\\wine\\$output_dir\\wine.lib \$(OutDir)\t";
757 print OUT "copy ..\\..\\libs\\unicode\\$output_dir\\wine_unicode.lib \$(OutDir)\r\n";
758 print OUT "# End Special Build Tool\r\n";
760 print OUT "# Begin Target\r\n";
762 foreach my $cfg (@cfgs) {
763 print OUT "# Name \"$cfg\"\r\n";
766 print OUT "# Begin Group \"Source Files\"\r\n";
768 print OUT "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
770 foreach my $source_file (@source_files) {
771 $source_file =~ s%/%\\%g;
772 if($source_file !~ /^\./) {
773 $source_file = ".\\$source_file";
776 if($source_file =~ /^(.*?)\.spec$/) {
779 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
780 my $dbg_c_file = "$basename.dbg.c";
782 print OUT "# Begin Source File\r\n";
784 print OUT "SOURCE=$dbg_c_file\r\n";
785 print OUT "# End Source File\r\n";
788 print OUT "# Begin Source File\r\n";
791 print OUT "SOURCE=$source_file\r\n";
793 if($source_file =~ /^(.*?)\.spec$/) {
796 my $spec_file = $source_file;
797 my $def_file = "$basename.def";
799 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
800 my $dbg_file = "$basename.dbg";
801 my $dbg_c_file = "$basename.dbg.c";
803 my $srcdir = "."; # FIXME: Is this really always correct?
805 print OUT "# Begin Custom Build\r\n";
806 print OUT "InputPath=$spec_file\r\n";
808 print OUT "BuildCmds= \\\r\n";
809 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe --def $spec_file > $def_file \\\r\n";
811 if($project =~ /^ntdll$/) {
813 foreach my $c_src (@c_srcs) {
815 print OUT "\techo $c_src >> $dbg_file \\\r\n";
817 print OUT "\techo $c_src > $dbg_file \\\r\n";
820 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
821 print OUT " -o $dbg_c_file --debug -C$srcdir $dbg_file \\\r\n";
823 my $c_srcs = join(" ", grep(/\.c$/, @c_srcs));
825 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
826 print OUT " -o $dbg_c_file --debug -C$srcdir $c_srcs \\\r\n";
831 print OUT "\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
832 print OUT " \$(BuildCmds)\r\n";
834 print OUT "\"$dbg_c_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
835 print OUT " \$(BuildCmds)\r\n";
836 print OUT "# End Custom Build\r\n";
837 } elsif($source_file =~ /([^\\]*?\.h)$/) {
840 foreach my $cfg (@cfgs) {
844 print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
848 print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
853 $output_dir =~ s/^$project - //;
854 $output_dir =~ s/ /_/g;
855 $output_dir =~ s/C\+\+/Cxx/g;
856 if($output_prefix_dir) {
857 $output_dir = "$output_prefix_dir\\$output_dir";
860 print OUT "# Begin Custom Build\r\n";
861 print OUT "OutDir=$output_dir\r\n";
862 print OUT "InputPath=$source_file\r\n";
864 print OUT "\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
865 print OUT "\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
867 print OUT "# End Custom Build\r\n";
872 print OUT "!ENDIF \r\n";
877 print OUT "# End Source File\r\n";
879 print OUT "# End Group\r\n";
881 print OUT "# Begin Group \"Header Files\"\r\n";
883 print OUT "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
884 foreach my $header_file (@header_files) {
885 print OUT "# Begin Source File\r\n";
887 print OUT "SOURCE=.\\$header_file\r\n";
888 print OUT "# End Source File\r\n";
890 print OUT "# End Group\r\n";
894 print OUT "# Begin Group \"Resource Files\"\r\n";
896 print OUT "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
897 foreach my $resource_file (@resource_files) {
898 print OUT "# Begin Source File\r\n";
900 print OUT "SOURCE=.\\$resource_file\r\n";
901 print OUT "# End Source File\r\n";
903 print OUT "# End Group\r\n";
905 print OUT "# End Target\r\n";
906 print OUT "# End Project\r\n";
911 sub _generate_dsw_header($) {
914 print OUT "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
915 print OUT "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
919 sub _generate_dsw_project($$$$) {
923 my $dsp_file = shift;
924 my @dependencies = @{(shift)};
926 $dsp_file = "./$dsp_file";
927 $dsp_file =~ y%/%\\%;
929 @dependencies = sort(@dependencies);
931 print OUT "###############################################################################\r\n";
933 print OUT "Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
935 print OUT "Package=<5>\r\n";
939 print OUT "Package=<4>\r\n";
941 foreach my $dependency (@dependencies) {
942 print OUT " Begin Project Dependency\r\n";
943 print OUT " Project_Dep_Name $dependency\r\n";
944 print OUT " End Project Dependency\r\n";
950 sub _generate_dsw_footer($) {
953 print OUT "###############################################################################\r\n";
955 print OUT "Global:\r\n";
957 print OUT "Package=<5>\r\n";
961 print OUT "Package=<3>\r\n";
965 print OUT "###############################################################################\r\n";
969 if ($options->wine) {
970 my $dsw_file = "wine.dsw";
971 $output->progress("$dsw_file");
972 replace_file("$wine_dir/$dsw_file", \&_generate_wine_dsw);
975 sub _generate_wine_dsw($) {
978 _generate_dsw_header(\*OUT);
979 foreach my $module (sort(keys(%modules))) {
980 next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
982 my $project = $modules{$module}{project};
983 my $dsp_file = $modules{$module}{dsp_file};
986 if($project =~ /^wine(?:_unicode)?$/) {
988 } elsif($project =~ /^winebuild$/) {
989 @dependencies = ("wine", "wine_unicode");
990 } elsif($project =~ /^(?:gdi32)_.+?$/) {
993 @dependencies = ("wine", "wine_unicode", "winebuild");
996 if($project =~ /^gdi32$/) {
997 foreach my $dir (@gdi32_dirs) {
999 $dir2 =~ s%^.*?/([^/]+)$%$1%;
1001 my $module = "gdi32_$dir2";
1003 push @dependencies, $module;
1007 _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
1009 _generate_dsw_footer(\*OUT);
1014 if ($options->winetest) {
1015 my $dsw_file = "winetest.dsw";
1016 $output->progress("$dsw_file");
1017 replace_file("$wine_dir/$dsw_file", \&_generate_winetest_dsw);
1020 sub _generate_winetest_dsw($) {
1023 _generate_dsw_header(\*OUT);
1025 my @runtests_dependencies = ();
1026 foreach my $module (sort(keys(%modules))) {
1027 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1028 next if $module eq "wineruntests";
1030 my $project = $modules{$module}{project};
1032 push @runtests_dependencies, $project;
1035 foreach my $module (sort(keys(%modules))) {
1036 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1038 my $project = $modules{$module}{project};
1039 my $dsp_file = $modules{$module}{dsp_file};
1042 if($project =~ /^winetest$/) {
1044 } elsif($project =~ /^wineruntests$/) {
1045 @dependencies = @runtests_dependencies;
1047 @dependencies = ("winetest");
1050 _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
1053 _generate_dsw_footer(\*OUT);
1056 if ($options->winetest) {
1057 foreach my $module (sort(keys(%modules))) {
1058 next if $module !~ /_test\.exe$/;
1060 my $project = $modules{$module}{project};
1061 my $dsp_file = $modules{$module}{dsp_file};
1062 my @tests = @{$modules{$module}{tests}};
1064 my $testlist_c = $dsp_file;
1065 $testlist_c =~ s%[^/]*\.dsp$%testlist.c%;
1067 replace_file("$wine_dir/$testlist_c", \&_generate_testlist_c, \@tests);
1071 # ***** Keep in sync with tools/make_ctests *****
1072 sub _generate_testlist_c($$) {
1075 my @tests = @{(shift)};
1077 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1079 print OUT "/* stdarg.h is needed for Winelib */\n";
1080 print OUT "#include <stdarg.h>\n";
1081 print OUT "#include <stdio.h>\n";
1082 print OUT "#include <stdlib.h>\n";
1083 print OUT "#include \"windef.h\"\n";
1084 print OUT "#include \"winbase.h\"\n";
1086 print OUT "#define STANDALONE\n";
1087 print OUT "#include \"wine/test.h\"\n";
1089 foreach my $test (@tests) {
1090 print OUT "extern void func_$test(void);\n";
1093 print OUT "const struct test winetest_testlist[] =\n";
1095 foreach my $test (@tests) {
1096 print OUT " { \"$test\", func_$test },\n";
1098 print OUT " { 0, 0 }\n";
1102 if ($options->winetest) {
1103 replace_file("$wine_dir/runtests.c", \&_generate_runtests_c);
1106 sub _generate_runtests_c($) {
1109 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1112 print OUT "#include <stdio.h>\n";
1113 print OUT "#include <stdlib.h>\n";
1116 print OUT "int main(int argc, char *argv[])\n";
1118 print OUT " char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1119 print OUT " char command[4096];\n";
1121 foreach my $dsp_file (keys(%runtests)) {
1122 my @tests = @{$runtests{$dsp_file}};
1124 my $project = $dsp_file;
1125 $project =~ s%^(.*?)/?([^/]+)\.dsp$%$2%;
1129 foreach my $test (@tests) {
1130 print OUT " sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1131 print OUT " system(command);\n";
1135 print OUT " return 0;\n";
1139 if ($options->winetest) {
1140 replace_file("$wine_dir/winetest.c", \&_generate_winetest_c);
1143 sub _generate_winetest_c($) {
1146 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n\n";
1148 print OUT "/* Force the linker to generate a .lib file */\n";
1149 print OUT "void __wine_dummy_lib_function()\n{\n}\n\n";
1152 if ($options->wine) {
1153 my $config_h = "include/config.h";
1155 $output->progress("$config_h");
1157 replace_file("$wine_dir/$config_h", \&_generate_config_h);
1160 sub _generate_config_h($) {
1163 print OUT "#define __WINE_CONFIG_H\n";
1166 my @headers = qw(direct.h fcntl.h io.h string.h process.h);
1167 foreach my $header (@headers) {
1168 $header =~ y/\.\//__/;
1169 print OUT "#define HAVE_\U$header\E\n";
1174 _alldiv _allmul _allrem _aulldiv _aullrem
1175 _access _chdir _close _lseek _mkdir _open _pclose _popen _read _rmdir _write _stat
1176 _snprintf _spawnvp _stricmp _strnicmp _vsnprintf _wcsicmp
1182 foreach my $function (@functions) {
1183 print OUT "#define HAVE_\U$function\E 1\n";
1188 print OUT "#define NEED_STDCALL_DECORATION 1\n";
1192 print OUT "#define X_DISPLAY_MISSING 1\n";
1195 print OUT "/* Define to a macro to generate an assembly function directive */\n";
1196 print OUT "#define __ASM_FUNC(name) \"\"\n";
1199 print OUT "/* Define to a macro to generate an assembly name from a C symbol */\n";
1200 print OUT "#define __ASM_NAME(name) name\n";
1203 print OUT "/* Define to the assembler keyword used to specify a word value */\n";
1204 print OUT "#define __ASM_SHORT \".short\"\n";
1207 print OUT "/* Define to the assembler keyword used to specify an ASCII string */\n";
1208 print OUT "#define __ASM_STRING \".string\"\n";
1211 print OUT "/* Define to the address where bug reports for this package should be sent. */\n";
1212 print OUT "#define PACKAGE_BUGREPORT \"\"\n";
1215 print OUT "/* Define to the full name of this package. */\n";
1216 print OUT "#define PACKAGE_NAME \"Wine\"\n";
1219 print OUT "/* Define to the full name and version of this package. */\n";
1220 print OUT "#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1223 print OUT "/* Define to the one symbol short name of this package. */\n";
1224 print OUT "#define PACKAGE_TARNAME \"wine\"\n";
1227 print OUT "/* Define to the version of this package. */\n";
1228 print OUT "#define PACKAGE_VERSION \"YYYYMMDD\"\n";