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 # These DLLs don't have a hope of compiling properly
40 my @unix_dependent_dlls = qw(iphlpapi mountmgr.sys ntdll mswsock opengl32
41 secur32 winex11 wnaspi32 ws2_32);
43 sub is_unix_dependent_dll($) {
46 foreach my $unix_only_dll (@unix_dependent_dlls) {
47 if($dll eq $unix_only_dll) {
55 sub read_spec_file($) {
56 my $spec_file = shift;
58 my $module = $spec_file;
59 $module =~ s%^.*?([^/]+)\.spec$%$1%;
60 $module .= ".dll" if $module !~ /\./;
64 open(IN, "< $wine_dir/$spec_file") || die "Error: Can't open $wine_dir/$spec_file: $!\n";
68 while($lookahead || defined($_ = <IN>)) {
71 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
72 s/^(.*?)\s*#.*$/$1/; # remove comments
73 /^$/ && next; # skip empty lines
83 if(/^(\d+|@)\s+pascal(?:16)?/) {
91 if($module =~ /^(?:(?:imm|ole2conv|ole2prox|ole2thk|rasapi16|msacm|windebug)\.dll|comm\.drv)$/) {
95 if($type eq "win32") {
96 $modules{$module}{module} = $module;
97 $modules{$module}{type} = $type;
98 $modules{$module}{spec_file} = $spec_file;
102 if ($options->wine || $options->winetest) {
103 foreach my $spec_file (@spec_files) {
104 my $dll = $spec_file;
105 $dll =~ s%dlls/([^/]+)/[^/]+\.spec%$1%;
106 if(!is_unix_dependent_dll($dll)) {
107 read_spec_file($spec_file);
112 my @gdi32_dirs = qw(dlls/gdi32/enhmfdrv dlls/gdi32/mfdrv);
114 push @makefile_in_files, "libs/wine/Makefile.in";
115 push @makefile_in_files, "tools/winebuild/Makefile.in";
117 sub filter_files($$) {
121 my $filtered_files = [];
122 my $rest_of_files = [];
123 foreach my $file (@$files) {
124 if($file =~ /$filter/) {
125 $file =~ s%.*?([^/]+)$%./$1%; # FIXME: Kludge
126 push @$filtered_files, $file;
128 push @$rest_of_files, $file;
131 return ($rest_of_files, $filtered_files);
134 my %wine_test_dsp_files;
136 MAKEFILE_IN: foreach my $makefile_in_file (@makefile_in_files) {
137 open(IN, "< $wine_dir/$makefile_in_file") || die "Error: Can't open $wine_dir/$makefile_in_file: $!\n";
151 $dll = $makefile_in_file;
152 $dll =~ s%dlls/([^/]+)/Makefile\.in%$1%;
154 if($makefile_in_file eq "loader/Makefile.in" ||
155 is_unix_dependent_dll($dll)) {
159 while($again || defined(my $line = <IN>)) {
172 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
173 s/^(.*?)\s*#.*$/$1/; # remove comments
174 /^$/ && next; # skip empty lines
181 if(/^MODULE\s*=\s*([\w\.]+)$/) {
184 if($module eq "none") {
185 if($makefile_in_file eq "tools/winebuild/Makefile.in") {
186 $module = "winebuild.exe";
187 } elsif ($makefile_in_file eq "include/Makefile.in") {
188 $module = "include.lib";
193 } elsif (/^\@MAKE_IMPLIB_RULES\@/) {
195 } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
197 } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
199 } elsif (/^IMPORTS\s*=\s*/) {
200 push @imports, grep !/^ntdll$/, split /\s+/s, $';
201 } elsif (/^DELAYIMPORTS\s*=\s*/) {
203 } elsif (/^EXTRALIBS\s*=\s*/) {
204 push @imports, map { /^-l(dxerr8|dxerr9|dxguid|strmiids|uuid)$/ ? $1 : () } split /\s+/s, $';
205 } elsif (/^CTESTS\s*=\s*/) {
206 my @files = split /\s+/s, $';
208 my $dir = $makefile_in_file;
209 $dir =~ s/\/Makefile\.in$//;
211 my $dsp_file = $testdll;
212 $dsp_file =~ s/\.(dll|drv)$/_test.dsp/;
213 $dsp_file = "$dir/$dsp_file";
215 $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
216 $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
217 } elsif(/^(\w+)\s*=\s*/) {
219 my @files = split /\s+/s, $';
222 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
223 my @list = @{$vars{$1}};
226 foreach my $item (@list) {
227 $item = "$prefix$item$suffix";
230 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
233 print STDERR "unknown variable '$_'\n" if 0;
240 $vars{$var} = \@files;
246 if (!$module && $makefile_in_file eq "libs/wine/Makefile.in") {
247 $module = "wine.lib";
253 my $source_files = [];
254 if(exists($vars{C_SRCS})) {
255 $c_srcs = [sort(@{$vars{C_SRCS}})];
256 $source_files = [sort(@{$vars{C_SRCS}})];
259 my $header_files = [];
260 if(exists($vars{H_SRCS})) {
261 $header_files = [sort(@{$vars{H_SRCS}})];
264 my $resource_files = [];
265 if(exists($vars{RC_SRCS})) {
266 $resource_files = [sort(@{$vars{RC_SRCS}})];
269 my $idl_h_files = [];
270 if(exists($vars{IDL_H_SRCS})) {
271 $idl_h_files = [sort(@{$vars{IDL_H_SRCS}})];
274 my $project = $module;
275 $project =~ s/\.(?:dll|exe|lib)$//;
278 if($module =~ /\.exe$/) {
280 } elsif($module =~ /\.lib$/) {
286 my $dsp_file = $makefile_in_file;
287 $dsp_file =~ s/Makefile.in$/$project.dsp/;
289 if($module eq "gdi32.dll") {
290 foreach my $dir (@gdi32_dirs) {
292 $dir2 =~ s%^.*?/([^/]+)$%$1%;
294 my $module = "gdi32_$dir2.lib";
297 my $project = "gdi32_$dir2";
301 my $dsp_file = "$dir/$project.dsp";
303 ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
304 ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
305 ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
306 ($idl_h_files, my $local_idl_h_files) = filter_files($idl_h_files, "$dir2/");
308 $modules{$module}{wine} = 1;
309 $modules{$module}{winetest} = 0;
310 $modules{$module}{project} = $project;
311 $modules{$module}{type} = $type;
312 $modules{$module}{dsp_file} = $dsp_file;
313 $modules{$module}{c_srcs} = $c_srcs;
314 $modules{$module}{source_files} = $local_source_files;
315 $modules{$module}{header_files} = $local_header_files;
316 $modules{$module}{resource_files} = $local_resource_files;
317 $modules{$module}{imports} = [];
318 $modules{$module}{idl_h_files} = $local_idl_h_files;
322 $modules{$module}{wine} = 1;
323 $modules{$module}{winetest} = 0;
324 $modules{$module}{project} = $project;
325 $modules{$module}{type} = $type;
326 $modules{$module}{dsp_file} = $dsp_file;
327 $modules{$module}{c_srcs} = $c_srcs;
328 $modules{$module}{source_files} = $source_files;
329 $modules{$module}{header_files} = $header_files;
330 $modules{$module}{resource_files} = $resource_files;
331 $modules{$module}{imports} = [@imports];
332 $modules{$module}{idl_h_files} = $idl_h_files;
335 $wine_test_dsp_files{"wineruntests.dsp"}{files} = ["runtests.c"];
336 $wine_test_dsp_files{"wineruntests.dsp"}{imports} = [];
338 $wine_test_dsp_files{"winetest.dsp"}{files} = [
339 'include/wine/exception.h',
340 'include/wine/test.h',
341 'include/wine/unicode.h',
344 $wine_test_dsp_files{"winetest.dsp"}{imports} = [];
348 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
349 my $project = $dsp_file;
350 $project =~ s%^(?:.*?/)?([^/]+)\.dsp$%$1%;
352 my @files = @{$wine_test_dsp_files{$dsp_file}{files}};
353 my @imports = @{$wine_test_dsp_files{$dsp_file}{imports}};
357 my $source_files = [];
358 my $header_files = [];
359 my $resource_files = [];
360 my $idl_h_files = [];
364 if ($project eq "winetest") {
367 $source_files = [@files];
369 $resource_files = [];
370 } elsif ($project eq "wineruntests") {
373 $source_files = [@files];
375 $resource_files = [];
379 $source_files = [@files];
381 $resource_files = [];
384 if (/^testlist\.c$/) {
392 $runtests{$dsp_file} = [@tests];
394 my $module = "$project.$type";
396 $modules{$module}{wine} = 0;
397 $modules{$module}{winetest} = 1;
399 $modules{$module}{project} = $project;
400 $modules{$module}{type} = $type;
401 $modules{$module}{dsp_file} = $dsp_file;
402 $modules{$module}{c_srcs} = $c_srcs;
403 $modules{$module}{source_files} = $source_files;
404 $modules{$module}{header_files} = $header_files;
405 $modules{$module}{resource_files} = $resource_files;
406 $modules{$module}{imports} = [@imports];
407 $modules{$module}{idl_h_files} = [];
409 $modules{$module}{tests} = [@tests];
412 foreach my $module (sort(keys(%modules))) {
413 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
414 delete $modules{$module};
419 foreach my $module (sort(keys(%modules))) {
420 if (($options->wine && $modules{$module}{wine}) ||
421 ($options->winetest && $modules{$module}{winetest}))
423 push @modules, $module;
428 my $progress_current = 0;
429 my $progress_max = scalar(@modules);
431 foreach my $module (@modules) {
432 my $dsp_file = $modules{$module}{dsp_file};
433 replace_file("$wine_dir/$dsp_file", \&_generate_dsp, $module);
436 sub _generate_dsp($$) {
441 my $dsp_file = $modules{$module}{dsp_file};
442 my $project = $modules{$module}{project};
443 my @imports = @{$modules{$module}{imports}};
445 my $lib = ($modules{$module}{type} eq "lib");
446 my $dll = ($modules{$module}{type} eq "dll");
447 my $exe = ($modules{$module}{type} eq "exe");
449 my $console = $exe; # FIXME: Not always correct
451 my $msvc_wine_dir = do {
452 my @parts = split(m%/%, $dsp_file);
455 } elsif($#parts == 2) {
461 my $wine_include_dir = "$msvc_wine_dir\\include";
464 $output->progress("$dsp_file (file $progress_current of $progress_max)");
466 my $base_module = $module;
467 $base_module =~ s/\.(?:dll)$//;
469 my @c_srcs = @{$modules{$module}{c_srcs}};
470 my @source_files = @{$modules{$module}{source_files}};
471 my @header_files = @{$modules{$module}{header_files}};
472 my @resource_files = @{$modules{$module}{resource_files}};
473 my @idl_h_files = @{$modules{$module}{idl_h_files}};
475 if ($project !~ /^wine(?:build|runtests|test)?$/ &&
476 $project !~ /^(?:gdi32)_.+?$/ &&
477 $project !~ /_test$/ &&
480 push @source_files, "$base_module.spec";
481 @source_files = sort(@source_files);
485 my $no_msvc_headers = 1;
486 if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
487 $no_msvc_headers = 0;
492 push @cfgs, "$project - Win32";
496 foreach my $cfg (@cfgs) {
497 push @_cfgs, "$cfg C";
498 push @_cfgs, "$cfg C++";
505 foreach my $cfg (@cfgs) {
506 push @_cfgs, "$cfg Debug";
507 push @_cfgs, "$cfg Release";
512 if (!$no_msvc_headers) {
514 foreach my $cfg (@cfgs) {
515 push @_cfgs, "$cfg MSVC Headers";
516 push @_cfgs, "$cfg Wine Headers";
521 my $default_cfg = $cfgs[$#cfgs];
523 print OUT "# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
524 print OUT "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
525 print OUT "# ** DO NOT EDIT **\r\n";
529 print OUT "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
531 print OUT "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
533 print OUT "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
537 print OUT "CFG=$default_cfg\r\n";
538 print OUT "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
539 print OUT "!MESSAGE use the Export Makefile command and run\r\n";
540 print OUT "!MESSAGE \r\n";
541 print OUT "!MESSAGE NMAKE /f \"$project.mak\".\r\n";
542 print OUT "!MESSAGE \r\n";
543 print OUT "!MESSAGE You can specify a configuration when running NMAKE\r\n";
544 print OUT "!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
545 print OUT "!MESSAGE \r\n";
546 print OUT "!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
547 print OUT "!MESSAGE \r\n";
548 print OUT "!MESSAGE Possible choices for configuration are:\r\n";
549 print OUT "!MESSAGE \r\n";
550 foreach my $cfg (@cfgs) {
552 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
554 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
556 print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
559 print OUT "!MESSAGE \r\n";
562 print OUT "# Begin Project\r\n";
563 print OUT "# PROP AllowPerConfigDependencies 0\r\n";
564 print OUT "# PROP Scc_ProjName \"\"\r\n";
565 print OUT "# PROP Scc_LocalPath \"\"\r\n";
566 print OUT "CPP=cl.exe\r\n";
567 print OUT "MTL=midl.exe\r\n" if !$lib && !$exe;
568 print OUT "RSC=rc.exe\r\n";
574 foreach my $cfg (@cfgs) {
578 print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
582 print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
586 my $debug = ($cfg !~ /Release/);
587 my $msvc_headers = ($cfg =~ /MSVC Headers/);
589 print OUT "# PROP BASE Use_MFC 0\r\n";
592 print OUT "# PROP BASE Use_Debug_Libraries 1\r\n";
594 print OUT "# PROP BASE Use_Debug_Libraries 0\r\n";
598 $output_dir =~ s/^$project - //;
599 $output_dir =~ s/ /_/g;
600 $output_dir =~ s/C\+\+/Cxx/g;
601 if($output_prefix_dir) {
602 $output_dir = "$output_prefix_dir\\$output_dir";
605 print OUT "# PROP BASE Output_Dir \"$output_dir\"\r\n";
606 print OUT "# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
608 print OUT "# PROP BASE Target_Dir \"\"\r\n";
610 print OUT "# PROP Use_MFC 0\r\n";
612 print OUT "# PROP Use_Debug_Libraries 1\r\n";
614 print OUT "# PROP Use_Debug_Libraries 0\r\n";
616 print OUT "# PROP Output_Dir \"$output_dir\"\r\n";
617 print OUT "# PROP Intermediate_Dir \"$output_dir\"\r\n";
619 print OUT "# PROP Ignore_Export_Lib 0\r\n" if $dll;
620 print OUT "# PROP Target_Dir \"\"\r\n";
622 print OUT "# ADD BASE CPP /nologo ";
623 my @defines = qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 WIN32);
626 push @defines, qw(_DEBUG _MBCS _LIB);
629 push @defines, (qw(_DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
631 print OUT "/W3 /Gm /GX /Zi /Od";
634 push @defines, qw(NDEBUG _MBCS _LIB);
637 push @defines, (qw(NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
639 print OUT "/W3 /GX /O2";
642 foreach my $define (@defines) {
643 if ($define !~ /=/) {
644 print OUT " /D \"$define\"";
646 print OUT " /D $define";
649 print OUT " /YX" if $lib || $exe;
651 print OUT " /GZ" if $debug;
655 my @defines2 = qw(_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE USE_COMPILER_EXCEPTIONS _USE_MATH_DEFINES);
658 print OUT "# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
659 push @defines2, qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 WIN32 _DEBUG _WINDOWS _MBCS _LIB);
661 print OUT "# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
662 push @defines2, qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x700 _DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
666 print OUT "# ADD CPP /nologo /MD /W3 /GX /O2";
667 push @defines2, qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 WIN32 NDEBUG _WINDOWS _MBCS _LIB);
669 print OUT "# ADD CPP /nologo /MD /W3 /GX /O2";
670 push @defines2, qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
676 push @defines2, "_\U${project}\E_";
677 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
679 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
681 my $output_dir2 = $output_dir;
682 $output_dir2 =~ s/\\/\\\\/g;
683 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir2\\\"";
684 push @defines2, qw(__i386__ _X86_);
686 if ($project eq "wine") {
687 push @defines2, "WINE_UNICODE_API=";
690 if ($project =~ /_test$/) {
691 push @includes, "$msvc_wine_dir\\$output_dir";
694 if (!$msvc_headers || $project eq "winetest") {
695 push @includes, $wine_include_dir;
700 foreach my $include (@includes) {
701 print OUT " /I \"$include\"";
705 foreach my $define (@defines2) {
706 if ($define !~ /=/) {
707 print OUT " /D \"$define\"";
709 print OUT " /D $define";
712 print OUT " /D inline=__inline" if $wine;
713 print OUT " /D \"__STDC__\"" if 0 && $wine;
715 print OUT " /YX" if $lib;
716 print OUT " /FR" if !$lib;
718 print OUT " /GZ" if $debug;
720 print OUT " /TP" if !$no_cpp;
724 print OUT "# SUBTRACT CPP /X /YX\r\n" if $dll;
725 print OUT "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
726 print OUT "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
727 print OUT "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
728 print OUT "# ADD RSC /l 0x41d";
730 foreach my $include (@includes) {
731 print OUT " /i \"$include\"";
734 print OUT " /d \"_DEBUG\"\r\n";
736 print OUT "# SUBTRACT CPP /YX\r\n" if $dll;
737 print OUT "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
738 print OUT "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
739 print OUT "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
740 print OUT "# ADD RSC /l 0x41d";
742 foreach my $include (@includes) {
743 print OUT " /i \"$include\"";
746 print OUT "/d \"NDEBUG\"\r\n";
748 print OUT "BSC32=bscmake.exe\r\n";
749 print OUT "# ADD BASE BSC32 /nologo\r\n";
750 print OUT "# ADD BSC32 /nologo\r\n";
753 print OUT "LINK32=link.exe\r\n";
754 print OUT "# ADD BASE LINK32";
755 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
756 comdlg32.lib advapi32.lib shell32.lib ole32.lib
757 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
758 foreach my $library (@libraries) {
759 print OUT " $library";
761 print OUT " /nologo";
762 print OUT " /dll" if $dll;
763 print OUT " /subsystem:console" if $console;
764 print OUT " /debug" if $debug;
765 print OUT " /machine:I386";
766 print OUT " /pdbtype:sept" if $debug;
769 print OUT "# ADD LINK32";
770 print OUT " libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
771 foreach my $import (@imports) {
772 print OUT " $import.lib" if ($import ne "msvcrt");
774 print OUT " /nologo";
775 print OUT " /dll" if $dll;
776 print OUT " /subsystem:console" if $console;
777 print OUT " /debug" if $debug;
778 print OUT " /machine:I386";
779 print OUT " /nodefaultlib" if $project =~ /^ntdll$/; # FIXME: Kludge
780 print OUT " /def:\"$project.def\"" if $dll;
781 print OUT " /pdbtype:sept" if $debug;
784 print OUT "LIB32=link.exe -lib\r\n";
785 print OUT "# ADD BASE LIB32 /nologo\r\n";
786 print OUT "# ADD LIB32 /nologo\r\n";
794 print OUT "!ENDIF \r\n";
798 print OUT "# Begin Target\r\n";
800 foreach my $cfg (@cfgs) {
801 print OUT "# Name \"$cfg\"\r\n";
804 print OUT "# Begin Group \"Source Files\"\r\n";
806 print OUT "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
808 if ($project eq "winebuild") {
809 for my $ source_file ("getopt.c", "getopt1.c", "mkstemps.c")
811 print OUT "# Begin Source File\r\n";
813 print OUT "SOURCE=..\\..\\libs\\port\\$source_file\r\n";
814 print OUT "# End Source File\r\n";
818 foreach my $source_file (@source_files) {
819 $source_file =~ s%/%\\%g;
820 if($source_file !~ /^\./) {
821 $source_file = ".\\$source_file";
824 print OUT "# Begin Source File\r\n";
827 print OUT "SOURCE=$source_file\r\n";
829 if ($project eq "wine" && $source_file eq ".\\config.c") {
830 print OUT "# ADD CPP /D BINDIR=\\\"\\\" /D DLLDIR=\\\"\\\" /D LIB_TO_BINDIR=\\\"\\\" /D LIB_TO_DLLDIR=\\\"\\\" /D BIN_TO_DLLDIR=\\\"\\\" /D LIB_TO_DATADIR=\\\"\\\" /D BIN_TO_DATADIR=\\\"\\\"\r\n";
833 if($source_file =~ /^(.*?)\.spec$/) {
836 my $spec_file = $source_file;
837 my $def_file = "$basename.def";
839 my $srcdir = "."; # FIXME: Is this really always correct?
841 print OUT "# Begin Custom Build\r\n";
842 print OUT "InputPath=$spec_file\r\n";
844 print OUT "BuildCmds= \\\r\n";
845 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe -w --def -k -o $def_file --export $spec_file\r\n";
847 print OUT "\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
848 print OUT " \$(BuildCmds)\r\n";
849 print OUT "# End Custom Build\r\n";
850 } elsif($source_file =~ /([^\\]*?\.h)$/) {
853 foreach my $cfg (@cfgs) {
857 print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
861 print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
866 $output_dir =~ s/^$project - //;
867 $output_dir =~ s/ /_/g;
868 $output_dir =~ s/C\+\+/Cxx/g;
869 if($output_prefix_dir) {
870 $output_dir = "$output_prefix_dir\\$output_dir";
873 print OUT "# Begin Custom Build\r\n";
874 print OUT "OutDir=$output_dir\r\n";
875 print OUT "InputPath=$source_file\r\n";
877 print OUT "\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
878 print OUT "\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
880 print OUT "# End Custom Build\r\n";
885 print OUT "!ENDIF \r\n";
890 print OUT "# End Source File\r\n";
893 foreach my $idl_h_file (@idl_h_files) {
894 $idl_h_file =~ s%/%\\%g;
895 if($idl_h_file !~ /^\./) {
896 $idl_h_file = ".\\$idl_h_file";
899 print OUT "# Begin Source File\r\n";
902 print OUT "SOURCE=$idl_h_file\r\n";
904 my $basename = $idl_h_file;
905 $basename =~ s/\.idl$//;
907 print OUT "# PROP Ignore_Default_Tool 1\r\n";
908 print OUT "# Begin Custom Build\r\n";
909 print OUT "InputPath=$idl_h_file\r\n";
911 print OUT "BuildCmds= \\\r\n";
912 print OUT "\tmidl /nologo /I $wine_include_dir /client none /server none /notlb $idl_h_file /h $basename.h\r\n";
914 print OUT "\"$basename.h\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
915 print OUT " \$(BuildCmds)\r\n";
916 print OUT "# End Custom Build\r\n";
918 print OUT "# End Source File\r\n";
921 print OUT "# End Group\r\n";
923 print OUT "# Begin Group \"Header Files\"\r\n";
925 print OUT "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
926 foreach my $header_file (@header_files) {
927 print OUT "# Begin Source File\r\n";
929 print OUT "SOURCE=.\\$header_file\r\n";
930 print OUT "# End Source File\r\n";
932 print OUT "# End Group\r\n";
936 print OUT "# Begin Group \"Resource Files\"\r\n";
938 print OUT "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
939 foreach my $resource_file (@resource_files) {
940 print OUT "# Begin Source File\r\n";
942 print OUT "SOURCE=.\\$resource_file\r\n";
943 print OUT "# End Source File\r\n";
945 print OUT "# End Group\r\n";
947 print OUT "# End Target\r\n";
948 print OUT "# End Project\r\n";
953 sub _generate_dsw_header($) {
956 print OUT "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
957 print OUT "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
961 sub _generate_dsw_project($$$$) {
965 my $dsp_file = shift;
966 my @dependencies = @{(shift)};
968 $dsp_file = "./$dsp_file";
969 $dsp_file =~ y%/%\\%;
971 @dependencies = sort(@dependencies);
973 print OUT "###############################################################################\r\n";
975 print OUT "Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
977 print OUT "Package=<5>\r\n";
981 print OUT "Package=<4>\r\n";
983 foreach my $dependency (@dependencies) {
984 print OUT " Begin Project Dependency\r\n";
985 print OUT " Project_Dep_Name $dependency\r\n";
986 print OUT " End Project Dependency\r\n";
992 sub _generate_dsw_footer($) {
995 print OUT "###############################################################################\r\n";
997 print OUT "Global:\r\n";
999 print OUT "Package=<5>\r\n";
1000 print OUT "{{{\r\n";
1001 print OUT "}}}\r\n";
1003 print OUT "Package=<3>\r\n";
1004 print OUT "{{{\r\n";
1005 print OUT "}}}\r\n";
1007 print OUT "###############################################################################\r\n";
1011 if ($options->wine) {
1012 my $dsw_file = "wine.dsw";
1013 $output->progress("$dsw_file");
1014 replace_file("$wine_dir/$dsw_file", \&_generate_wine_dsw);
1017 sub _generate_wine_dsw($) {
1020 _generate_dsw_header(\*OUT);
1021 foreach my $module (sort(keys(%modules))) {
1022 next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1024 my $project = $modules{$module}{project};
1025 my $dsp_file = $modules{$module}{dsp_file};
1028 if($project eq "wine") {
1030 } elsif($project eq "winebuild") {
1031 @dependencies = ("wine");
1032 } elsif($project =~ /^(?:gdi32)_.+?$/) {
1035 @dependencies = ("wine", "include", "winebuild");
1038 if($project =~ /^gdi32$/) {
1039 foreach my $dir (@gdi32_dirs) {
1041 $dir2 =~ s%^.*?/([^/]+)$%$1%;
1043 my $module = "gdi32_$dir2";
1045 push @dependencies, $module;
1049 _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
1051 _generate_dsw_footer(\*OUT);
1056 if ($options->winetest) {
1057 my $dsw_file = "winetest.dsw";
1058 $output->progress("$dsw_file");
1059 replace_file("$wine_dir/$dsw_file", \&_generate_winetest_dsw);
1062 sub _generate_winetest_dsw($) {
1065 _generate_dsw_header(\*OUT);
1067 my @runtests_dependencies = ();
1068 foreach my $module (sort(keys(%modules))) {
1069 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1070 next if $module eq "wineruntests";
1072 my $project = $modules{$module}{project};
1074 push @runtests_dependencies, $project;
1077 foreach my $module (sort(keys(%modules))) {
1078 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1080 my $project = $modules{$module}{project};
1081 my $dsp_file = $modules{$module}{dsp_file};
1084 if($project =~ /^winetest$/) {
1086 } elsif($project =~ /^wineruntests$/) {
1087 @dependencies = @runtests_dependencies;
1089 @dependencies = ("winetest");
1092 _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
1095 _generate_dsw_footer(\*OUT);
1098 if ($options->winetest) {
1099 foreach my $module (sort(keys(%modules))) {
1100 next if $module !~ /_test\.exe$/;
1102 my $project = $modules{$module}{project};
1103 my $dsp_file = $modules{$module}{dsp_file};
1104 my @tests = @{$modules{$module}{tests}};
1106 my $testlist_c = $dsp_file;
1107 $testlist_c =~ s%[^/]*\.dsp$%testlist.c%;
1109 replace_file("$wine_dir/$testlist_c", \&_generate_testlist_c, \@tests);
1113 # ***** Keep in sync with tools/make_ctests *****
1114 sub _generate_testlist_c($$) {
1117 my @tests = @{(shift)};
1119 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1121 print OUT "/* stdarg.h is needed for Winelib */\n";
1122 print OUT "#include <stdarg.h>\n";
1123 print OUT "#include <stdio.h>\n";
1124 print OUT "#include <stdlib.h>\n";
1125 print OUT "#include \"windef.h\"\n";
1126 print OUT "#include \"winbase.h\"\n";
1128 print OUT "#define STANDALONE\n";
1129 print OUT "#include \"wine/test.h\"\n";
1131 foreach my $test (@tests) {
1132 print OUT "extern void func_$test(void);\n";
1135 print OUT "const struct test winetest_testlist[] =\n";
1137 foreach my $test (@tests) {
1138 print OUT " { \"$test\", func_$test },\n";
1140 print OUT " { 0, 0 }\n";
1144 if ($options->winetest) {
1145 replace_file("$wine_dir/runtests.c", \&_generate_runtests_c);
1148 sub _generate_runtests_c($) {
1151 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1154 print OUT "#include <stdio.h>\n";
1155 print OUT "#include <stdlib.h>\n";
1158 print OUT "int main(int argc, char *argv[])\n";
1160 print OUT " char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1161 print OUT " char command[4096];\n";
1163 foreach my $dsp_file (keys(%runtests)) {
1164 my @tests = @{$runtests{$dsp_file}};
1166 my $project = $dsp_file;
1167 $project =~ s%^(.*?)/?([^/]+)\.dsp$%$2%;
1171 foreach my $test (@tests) {
1172 print OUT " sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1173 print OUT " system(command);\n";
1177 print OUT " return 0;\n";
1181 if ($options->winetest) {
1182 replace_file("$wine_dir/winetest.c", \&_generate_winetest_c);
1185 sub _generate_winetest_c($) {
1188 print OUT "/* Automatically generated file; DO NOT EDIT!! */\n\n";
1190 print OUT "/* Force the linker to generate a .lib file */\n";
1191 print OUT "void __wine_dummy_lib_function(void)\n{\n}\n\n";
1194 if ($options->wine) {
1195 my $config_h = "include/config.h";
1197 $output->progress("$config_h");
1199 replace_file("$wine_dir/$config_h", \&_generate_config_h);
1202 sub _generate_config_h($) {
1206 print OUT "#define __WINE_CONFIG_H\n";
1209 my @headers = qw(direct.h float.h memory.h io.h stdlib.h string.h process.h sys/stat.h sys/types.h);
1210 foreach my $header (@headers) {
1211 $header =~ y/\.\//__/;
1212 push @defines, "HAVE_\U$header\E 1";
1216 _pclose _popen _snprintf _spawnvp _stricmp _strnicmp _strdup
1217 _strtoi64 _strtoui64 _vsnprintf
1218 chsize memmove strdup spawnvp strerror vsnprintf
1220 foreach my $function (@functions) {
1221 push @defines, "HAVE_\U$function\E 1";
1225 long_long off_t size_t
1227 foreach my $type (@types) {
1228 push @defines, "HAVE_\U$type\E 1";
1231 foreach my $define (sort(@defines)) {
1232 print OUT "#define $define\n";
1236 print OUT "/* Define to the address where bug reports for this package should be sent. */\n";
1237 print OUT "#define PACKAGE_BUGREPORT \"\"\n";
1240 print OUT "/* Define to the full name of this package. */\n";
1241 print OUT "#define PACKAGE_NAME \"Wine\"\n";
1244 print OUT "/* Define to the full name and version of this package. */\n";
1245 print OUT "#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1248 print OUT "/* Define to the one symbol short name of this package. */\n";
1249 print OUT "#define PACKAGE_TARNAME \"wine\"\n";
1252 print OUT "/* Define to the version of this package. */\n";
1253 print OUT "#define PACKAGE_VERSION \"YYYYMMDD\"\n";
1256 print OUT "#define X_DISPLAY_MISSING 1\n";
1259 print OUT "/* Define to a macro to generate an assembly function directive */\n";
1260 print OUT "#define __ASM_FUNC(name) \"\"\n";
1263 print OUT "/* Define to a macro to generate an assembly name from a C symbol */\n";
1264 print OUT "#define __ASM_NAME(name) name\n";