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 $idl_c_files = [];
275 if(exists($vars{IDL_C_SRCS
})) {
276 $idl_c_files = [sort(@
{$vars{IDL_C_SRCS
}})];
279 my $idl_s_files = [];
280 if(exists($vars{IDL_S_SRCS
})) {
281 $idl_s_files = [sort(@
{$vars{IDL_S_SRCS
}})];
284 my $idl_p_files = [];
285 if(exists($vars{IDL_P_SRCS
})) {
286 $idl_p_files = [sort(@
{$vars{IDL_P_SRCS
}})];
289 my $idl_tlb_files = [];
290 if(exists($vars{IDL_TLB_SRCS
})) {
291 $idl_tlb_files = [sort(@
{$vars{IDL_TLB_SRCS
}})];
295 if(exists($vars{EXTRADEFS
})) {
296 $extradefs = $vars{EXTRADEFS
};
299 my $project = $module;
300 $project =~ s/\.(?:dll|exe|lib)$//;
303 if($module =~ /\.exe$/) {
305 } elsif($module =~ /\.lib$/) {
311 my $dsp_file = $makefile_in_file;
312 $dsp_file =~ s/Makefile.in$/$project.dsp/;
314 if($module eq "gdi32.dll") {
315 foreach my $dir (@gdi32_dirs) {
317 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
319 my $module = "gdi32_$dir2.lib";
322 my $project = "gdi32_$dir2";
326 my $dsp_file = "$dir/$project.dsp";
328 ($source_files, my $local_source_files) = filter_files
($source_files, "$dir2/");
329 ($header_files, my $local_header_files) = filter_files
($header_files, "$dir2/");
330 ($resource_files, my $local_resource_files) = filter_files
($resource_files, "$dir2/");
331 ($idl_h_files, my $local_idl_h_files) = filter_files
($idl_h_files, "$dir2/");
333 $modules{$module}{wine
} = 1;
334 $modules{$module}{winetest
} = 0;
335 $modules{$module}{project
} = $project;
336 $modules{$module}{type
} = $type;
337 $modules{$module}{dsp_file
} = $dsp_file;
338 $modules{$module}{c_srcs
} = $c_srcs;
339 $modules{$module}{source_files
} = $local_source_files;
340 $modules{$module}{header_files
} = $local_header_files;
341 $modules{$module}{resource_files
} = $local_resource_files;
342 $modules{$module}{imports
} = [];
343 $modules{$module}{idl_h_files
} = $local_idl_h_files;
344 $modules{$module}{idl_c_files
} = [];
345 $modules{$module}{idl_s_files
} = [];
346 $modules{$module}{idl_p_files
} = [];
347 $modules{$module}{idl_tlb_files
} = [];
348 $modules{$module}{extradefs
} = $extradefs if $extradefs;
352 $modules{$module}{wine
} = 1;
353 $modules{$module}{winetest
} = 0;
354 $modules{$module}{project
} = $project;
355 $modules{$module}{type
} = $type;
356 $modules{$module}{dsp_file
} = $dsp_file;
357 $modules{$module}{c_srcs
} = $c_srcs;
358 $modules{$module}{source_files
} = $source_files;
359 $modules{$module}{header_files
} = $header_files;
360 $modules{$module}{resource_files
} = $resource_files;
361 $modules{$module}{imports
} = [@imports];
362 $modules{$module}{idl_h_files
} = $idl_h_files;
363 $modules{$module}{idl_c_files
} = $idl_c_files;
364 $modules{$module}{idl_s_files
} = $idl_s_files;
365 $modules{$module}{idl_p_files
} = $idl_p_files;
366 $modules{$module}{idl_tlb_files
} = $idl_tlb_files;
367 $modules{$module}{extradefs
} = $extradefs if $extradefs;
370 $wine_test_dsp_files{"wineruntests.dsp"}{files
} = ["runtests.c"];
371 $wine_test_dsp_files{"wineruntests.dsp"}{imports
} = [];
373 $wine_test_dsp_files{"winetest.dsp"}{files
} = [
374 'include/wine/exception.h',
375 'include/wine/test.h',
376 'include/wine/unicode.h',
379 $wine_test_dsp_files{"winetest.dsp"}{imports
} = [];
383 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
384 my $project = $dsp_file;
385 $project =~ s
%^(?
:.*?
/)?([^/]+)\
.dsp
$%$1%;
387 my @files = @
{$wine_test_dsp_files{$dsp_file}{files
}};
388 my @imports = @
{$wine_test_dsp_files{$dsp_file}{imports
}};
392 my $source_files = [];
393 my $header_files = [];
394 my $resource_files = [];
395 my $idl_h_files = [];
399 if ($project eq "winetest") {
402 $source_files = [@files];
404 $resource_files = [];
405 } elsif ($project eq "wineruntests") {
408 $source_files = [@files];
410 $resource_files = [];
414 $source_files = [@files];
416 $resource_files = [];
419 if (/^testlist\.c$/) {
427 $runtests{$dsp_file} = [@tests];
429 my $module = "$project.$type";
431 $modules{$module}{wine
} = 0;
432 $modules{$module}{winetest
} = 1;
434 $modules{$module}{project
} = $project;
435 $modules{$module}{type
} = $type;
436 $modules{$module}{dsp_file
} = $dsp_file;
437 $modules{$module}{c_srcs
} = $c_srcs;
438 $modules{$module}{source_files
} = $source_files;
439 $modules{$module}{header_files
} = $header_files;
440 $modules{$module}{resource_files
} = $resource_files;
441 $modules{$module}{imports
} = [@imports];
442 $modules{$module}{idl_h_files
} = [];
443 $modules{$module}{idl_c_files
} = [];
444 $modules{$module}{idl_s_files
} = [];
445 $modules{$module}{idl_p_files
} = [];
446 $modules{$module}{idl_tlb_files
} = [];
448 $modules{$module}{tests
} = [@tests];
451 foreach my $module (sort(keys(%modules))) {
452 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
453 delete $modules{$module};
458 foreach my $module (sort(keys(%modules))) {
459 if (($options->wine && $modules{$module}{wine
}) ||
460 ($options->winetest && $modules{$module}{winetest
}))
462 push @modules, $module;
467 my $progress_current = 0;
468 my $progress_max = scalar(@modules);
470 foreach my $module (@modules) {
471 my $dsp_file = $modules{$module}{dsp_file
};
472 replace_file
("$wine_dir/$dsp_file", \
&_generate_dsp
, $module);
475 sub output_dsp_idl_rules
($$$) {
476 my $wine_include_dir = shift;
478 my @idl_src_files = @
{(shift)};
480 foreach my $idl_src_file (@idl_src_files) {
481 $idl_src_file =~ s
%/%\\%g;
482 if($idl_src_file !~ /^\./) {
483 $idl_src_file = ".\\$idl_src_file";
486 print OUT
"# Begin Source File\r\n";
489 print OUT
"SOURCE=$idl_src_file\r\n";
491 my $basename = $idl_src_file;
492 $basename =~ s/\.idl$//;
494 print OUT
"# PROP Ignore_Default_Tool 1\r\n";
495 print OUT
"# Begin Custom Build\r\n";
496 print OUT
"InputPath=$idl_src_file\r\n";
498 print OUT
"BuildCmds= \\\r\n";
499 print OUT
"\tmidl /nologo /I $wine_include_dir $idl_src_file ";
501 print OUT
"/client none /server none /notlb /h ";
502 } elsif ($ext eq "_c.c") {
503 print OUT
"/server none /notlb /cstub ";
504 } elsif ($ext eq "_s.c") {
505 print OUT
"/client none /notlb /sstub ";
506 } elsif ($ext eq "_p.c") {
507 print OUT
"/client none /server none /notlb /proxy ";
508 } elsif ($ext eq ".tlb") {
509 print OUT
"/client none /server none /tlb ";
511 print OUT
"$basename$ext\r\n";
513 print OUT
"\"$basename$ext\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
514 print OUT
" \$(BuildCmds)\r\n";
515 print OUT
"# End Custom Build\r\n";
517 print OUT
"# End Source File\r\n";
521 sub _generate_dsp
($$) {
526 my $dsp_file = $modules{$module}{dsp_file
};
527 my $project = $modules{$module}{project
};
528 my @imports = @
{$modules{$module}{imports
}};
530 my $lib = ($modules{$module}{type
} eq "lib");
531 my $dll = ($modules{$module}{type
} eq "dll");
532 my $exe = ($modules{$module}{type
} eq "exe");
534 my $console = $exe; # FIXME: Not always correct
536 my $msvc_wine_dir = do {
537 my @parts = split(m
%/%, $dsp_file);
540 } elsif($#parts == 2) {
546 my $wine_include_dir = "$msvc_wine_dir\\include";
549 $output->progress("$dsp_file (file $progress_current of $progress_max)");
551 my $base_module = $module;
552 $base_module =~ s/\.(?:dll)$//;
554 my @c_srcs = @
{$modules{$module}{c_srcs
}};
555 my @source_files = @
{$modules{$module}{source_files
}};
556 my @header_files = @
{$modules{$module}{header_files
}};
557 my @resource_files = @
{$modules{$module}{resource_files
}};
558 my @idl_h_files = @
{$modules{$module}{idl_h_files
}};
559 my @idl_c_files = @
{$modules{$module}{idl_c_files
}};
560 my @idl_s_files = @
{$modules{$module}{idl_s_files
}};
561 my @idl_p_files = @
{$modules{$module}{idl_p_files
}};
562 my @idl_tlb_files = @
{$modules{$module}{idl_tlb_files
}};
564 if ($project !~ /^wine(?:build|runtests|test)?$/ &&
565 $project !~ /^(?:gdi32)_.+?$/ &&
566 $project !~ /_test$/ &&
569 push @source_files, "$base_module.spec";
570 @source_files = sort(@source_files);
574 my $no_msvc_headers = 1;
575 if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
576 $no_msvc_headers = 0;
581 push @cfgs, "$project - Win32";
585 foreach my $cfg (@cfgs) {
586 push @_cfgs, "$cfg C";
587 push @_cfgs, "$cfg C++";
594 foreach my $cfg (@cfgs) {
595 push @_cfgs, "$cfg Debug";
596 push @_cfgs, "$cfg Release";
601 foreach my $cfg (@cfgs) {
602 push @_cfgs, "$cfg Debug";
607 if (!$no_msvc_headers) {
609 foreach my $cfg (@cfgs) {
610 push @_cfgs, "$cfg MSVC Headers";
611 push @_cfgs, "$cfg Wine Headers";
616 my $default_cfg = $cfgs[$#cfgs];
618 print OUT
"# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
619 print OUT
"# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
620 print OUT
"# ** DO NOT EDIT **\r\n";
624 print OUT
"# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
626 print OUT
"# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
628 print OUT
"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
632 print OUT
"CFG=$default_cfg\r\n";
633 print OUT
"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
634 print OUT
"!MESSAGE use the Export Makefile command and run\r\n";
635 print OUT
"!MESSAGE \r\n";
636 print OUT
"!MESSAGE NMAKE /f \"$project.mak\".\r\n";
637 print OUT
"!MESSAGE \r\n";
638 print OUT
"!MESSAGE You can specify a configuration when running NMAKE\r\n";
639 print OUT
"!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
640 print OUT
"!MESSAGE \r\n";
641 print OUT
"!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
642 print OUT
"!MESSAGE \r\n";
643 print OUT
"!MESSAGE Possible choices for configuration are:\r\n";
644 print OUT
"!MESSAGE \r\n";
645 foreach my $cfg (@cfgs) {
647 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
649 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
651 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
654 print OUT
"!MESSAGE \r\n";
657 print OUT
"# Begin Project\r\n";
658 print OUT
"# PROP AllowPerConfigDependencies 0\r\n";
659 print OUT
"# PROP Scc_ProjName \"\"\r\n";
660 print OUT
"# PROP Scc_LocalPath \"\"\r\n";
661 print OUT
"CPP=cl.exe\r\n";
662 print OUT
"MTL=midl.exe\r\n" if !$lib && !$exe;
663 print OUT
"RSC=rc.exe\r\n";
669 foreach my $cfg (@cfgs) {
673 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
677 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
681 my $debug = ($cfg !~ /Release/);
682 my $msvc_headers = ($cfg =~ /MSVC Headers/);
684 print OUT
"# PROP BASE Use_MFC 0\r\n";
687 print OUT
"# PROP BASE Use_Debug_Libraries 1\r\n";
689 print OUT
"# PROP BASE Use_Debug_Libraries 0\r\n";
693 $output_dir =~ s/^$project - //;
694 $output_dir =~ s/ /_/g;
695 $output_dir =~ s/C\+\+/Cxx/g;
696 if($output_prefix_dir) {
697 $output_dir = "$output_prefix_dir\\$output_dir";
700 print OUT
"# PROP BASE Output_Dir \"$output_dir\"\r\n";
701 print OUT
"# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
703 print OUT
"# PROP BASE Target_Dir \"\"\r\n";
705 print OUT
"# PROP Use_MFC 0\r\n";
707 print OUT
"# PROP Use_Debug_Libraries 1\r\n";
709 print OUT
"# PROP Use_Debug_Libraries 0\r\n";
711 print OUT
"# PROP Output_Dir \"$output_dir\"\r\n";
712 print OUT
"# PROP Intermediate_Dir \"$output_dir\"\r\n";
714 print OUT
"# PROP Ignore_Export_Lib 0\r\n" if $dll;
715 print OUT
"# PROP Target_Dir \"\"\r\n";
717 print OUT
"# ADD BASE CPP /nologo ";
718 my @defines = qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 WIN32);
721 push @defines, qw(_DEBUG _MBCS _LIB);
724 push @defines, qw(_DEBUG _WINDOWS _MBCS _USRDLL);
726 print OUT
"/W3 /Gm /GX /Zi /Od";
729 push @defines, qw(NDEBUG _MBCS _LIB);
732 push @defines, qw(NDEBUG _WINDOWS _MBCS _USRDLL);
734 print OUT
"/W3 /GX /O2";
737 foreach my $define (@defines) {
738 if ($define !~ /=/) {
739 print OUT
" /D \"$define\"";
741 print OUT
" /D $define";
744 print OUT
" /YX" if $lib || $exe;
746 print OUT
" /GZ" if $debug;
750 my @defines2 = qw(_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
751 USE_COMPILER_EXCEPTIONS _USE_MATH_DEFINES
752 WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700);
755 print OUT
"# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
756 push @defines2, qw(WIN32 _DEBUG _WINDOWS _MBCS _LIB);
758 print OUT
"# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
759 push @defines2, qw(_DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
763 print OUT
"# ADD CPP /nologo /MD /W3 /GX /O2";
764 push @defines2, qw(WIN32 NDEBUG _WINDOWS _MBCS _LIB);
766 print OUT
"# ADD CPP /nologo /MD /W3 /GX /O2";
767 push @defines2, qw(NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
773 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
775 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
777 my $output_dir2 = $output_dir;
778 $output_dir2 =~ s/\\/\\\\/g;
779 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir2\\\"";
780 push @defines2, qw(__i386__ _X86_);
782 if ($project eq "wine") {
783 push @defines2, "WINE_UNICODE_API=";
786 if ($project =~ /_test$/) {
787 push @includes, "$msvc_wine_dir\\$output_dir";
790 if (!$msvc_headers || $project eq "winetest") {
791 push @includes, $wine_include_dir;
796 foreach my $include (@includes) {
797 print OUT
" /I \"$include\"";
801 foreach my $define (@defines2) {
802 if ($define !~ /=/) {
803 print OUT
" /D \"$define\"";
805 print OUT
" /D $define";
808 print OUT
" /D inline=__inline" if $wine;
809 print OUT
" /D \"__STDC__\"" if 0 && $wine;
811 if(exists($modules{$module}{extradefs
})) {
812 print OUT
" @{$modules{$module}{extradefs}} ";
815 print OUT
" /YX" if $lib;
816 print OUT
" /FR" if !$lib;
818 print OUT
" /GZ" if $debug;
820 print OUT
" /TP" if !$no_cpp;
824 print OUT
"# SUBTRACT CPP /X /YX\r\n" if $dll;
825 print OUT
"# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
826 print OUT
"# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
827 print OUT
"# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
828 print OUT
"# ADD RSC /l 0x41d";
830 foreach my $include (@includes) {
831 print OUT
" /i \"$include\"";
834 print OUT
" /d \"_DEBUG\"\r\n";
836 print OUT
"# SUBTRACT CPP /YX\r\n" if $dll;
837 print OUT
"# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
838 print OUT
"# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
839 print OUT
"# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
840 print OUT
"# ADD RSC /l 0x41d";
842 foreach my $include (@includes) {
843 print OUT
" /i \"$include\"";
846 print OUT
"/d \"NDEBUG\"\r\n";
848 print OUT
"BSC32=bscmake.exe\r\n";
849 print OUT
"# ADD BASE BSC32 /nologo\r\n";
850 print OUT
"# ADD BSC32 /nologo\r\n";
853 print OUT
"LINK32=link.exe\r\n";
854 print OUT
"# ADD BASE LINK32";
855 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
856 comdlg32.lib advapi32.lib shell32.lib ole32.lib
857 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
858 foreach my $library (@libraries) {
859 print OUT
" $library";
861 print OUT
" /nologo";
862 print OUT
" /dll" if $dll;
863 print OUT
" /subsystem:console" if $console;
864 print OUT
" /debug" if $debug;
865 print OUT
" /machine:I386";
866 print OUT
" /pdbtype:sept" if $debug;
869 print OUT
"# ADD LINK32";
870 print OUT
" libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
871 foreach my $import (@imports) {
872 print OUT
" $import.lib" if ($import ne "msvcrt");
874 print OUT
" /nologo";
875 print OUT
" /dll" if $dll;
876 print OUT
" /subsystem:console" if $console;
877 print OUT
" /debug" if $debug;
878 print OUT
" /machine:I386";
879 print OUT
" /nodefaultlib" if $project =~ /^ntdll
$/; # FIXME: Kludge
880 print OUT
" /def:\"$project.def\"" if $dll;
881 print OUT
" /pdbtype:sept" if $debug;
884 print OUT
"LIB32=link.exe -lib\r\n";
885 print OUT
"# ADD BASE LIB32 /nologo\r\n";
886 print OUT
"# ADD LIB32 /nologo\r\n";
894 print OUT
"!ENDIF \r\n";
898 print OUT
"# Begin Target\r\n";
900 foreach my $cfg (@cfgs) {
901 print OUT
"# Name \"$cfg\"\r\n";
904 print OUT
"# Begin Group \"Source Files\"\r\n";
906 print OUT
"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
908 if ($project eq "winebuild") {
909 for my $ source_file
("getopt.c", "getopt1.c", "mkstemps.c")
911 print OUT
"# Begin Source File\r\n";
913 print OUT
"SOURCE=..\\..\\libs\\port\\$source_file\r\n";
914 print OUT
"# End Source File\r\n";
918 foreach my $source_file (@source_files) {
919 $source_file =~ s
%/%\\%g;
920 if($source_file !~ /^\./) {
921 $source_file = ".\\$source_file";
924 print OUT
"# Begin Source File\r\n";
927 print OUT
"SOURCE=$source_file\r\n";
929 if ($project eq "wine" && $source_file eq ".\\config.c") {
930 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";
933 if($source_file =~ /^(.*?)\.spec$/) {
936 my $spec_file = $source_file;
937 my $def_file = "$basename.def";
939 my $srcdir = "."; # FIXME: Is this really always correct?
941 print OUT
"# Begin Custom Build\r\n";
942 print OUT
"InputPath=$spec_file\r\n";
944 print OUT
"BuildCmds= \\\r\n";
945 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe -w --def -k -o $def_file --export $spec_file\r\n";
947 print OUT
"\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
948 print OUT
" \$(BuildCmds)\r\n";
949 print OUT
"# End Custom Build\r\n";
950 } elsif($source_file =~ /([^\\]*?\.h)$/) {
953 foreach my $cfg (@cfgs) {
957 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
961 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
966 $output_dir =~ s/^$project - //;
967 $output_dir =~ s/ /_/g;
968 $output_dir =~ s/C\+\+/Cxx/g;
969 if($output_prefix_dir) {
970 $output_dir = "$output_prefix_dir\\$output_dir";
973 print OUT
"# Begin Custom Build\r\n";
974 print OUT
"OutDir=$output_dir\r\n";
975 print OUT
"InputPath=$source_file\r\n";
977 print OUT
"\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
978 print OUT
"\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
980 print OUT
"# End Custom Build\r\n";
985 print OUT
"!ENDIF \r\n";
990 print OUT
"# End Source File\r\n";
993 output_dsp_idl_rules
$wine_include_dir, ".h", \
@idl_h_files;
994 output_dsp_idl_rules
$wine_include_dir, "_c.c", \
@idl_c_files;
995 output_dsp_idl_rules
$wine_include_dir, "_s.c", \
@idl_s_files;
996 output_dsp_idl_rules
$wine_include_dir, "_p.c", \
@idl_p_files;
997 # Hack - stdole2.idl cannot be compiled with midl
998 if($project ne "include") {
999 output_dsp_idl_rules
$wine_include_dir, ".tlb", \
@idl_tlb_files;
1002 print OUT
"# End Group\r\n";
1004 print OUT
"# Begin Group \"Header Files\"\r\n";
1006 print OUT
"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
1007 foreach my $header_file (@header_files) {
1008 print OUT
"# Begin Source File\r\n";
1010 print OUT
"SOURCE=.\\$header_file\r\n";
1011 print OUT
"# End Source File\r\n";
1013 print OUT
"# End Group\r\n";
1017 print OUT
"# Begin Group \"Resource Files\"\r\n";
1019 print OUT
"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
1020 foreach my $resource_file (@resource_files) {
1021 print OUT
"# Begin Source File\r\n";
1023 print OUT
"SOURCE=.\\$resource_file\r\n";
1024 print OUT
"# End Source File\r\n";
1026 print OUT
"# End Group\r\n";
1028 print OUT
"# End Target\r\n";
1029 print OUT
"# End Project\r\n";
1034 sub _generate_dsw_header
($) {
1037 print OUT
"Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
1038 print OUT
"# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
1042 sub _generate_dsw_project
($$$$) {
1045 my $project = shift;
1046 my $dsp_file = shift;
1047 my @dependencies = @
{(shift)};
1049 $dsp_file = "./$dsp_file";
1050 $dsp_file =~ y
%/%\\%;
1052 @dependencies = sort(@dependencies);
1054 print OUT
"###############################################################################\r\n";
1056 print OUT
"Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
1058 print OUT
"Package=<5>\r\n";
1059 print OUT
"{{{\r\n";
1060 print OUT
"}}}\r\n";
1062 print OUT
"Package=<4>\r\n";
1063 print OUT
"{{{\r\n";
1064 foreach my $dependency (@dependencies) {
1065 print OUT
" Begin Project Dependency\r\n";
1066 print OUT
" Project_Dep_Name $dependency\r\n";
1067 print OUT
" End Project Dependency\r\n";
1069 print OUT
"}}}\r\n";
1073 sub _generate_dsw_footer
($) {
1076 print OUT
"###############################################################################\r\n";
1078 print OUT
"Global:\r\n";
1080 print OUT
"Package=<5>\r\n";
1081 print OUT
"{{{\r\n";
1082 print OUT
"}}}\r\n";
1084 print OUT
"Package=<3>\r\n";
1085 print OUT
"{{{\r\n";
1086 print OUT
"}}}\r\n";
1088 print OUT
"###############################################################################\r\n";
1092 if ($options->wine) {
1093 my $dsw_file = "wine.dsw";
1094 $output->progress("$dsw_file");
1095 replace_file
("$wine_dir/$dsw_file", \
&_generate_wine_dsw
);
1098 sub _generate_wine_dsw
($) {
1101 _generate_dsw_header
(\
*OUT
);
1102 foreach my $module (sort(keys(%modules))) {
1103 next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1105 my $project = $modules{$module}{project
};
1106 my $dsp_file = $modules{$module}{dsp_file
};
1109 if($project eq "wine") {
1111 } elsif($project eq "winebuild") {
1112 @dependencies = ("wine");
1113 } elsif($project =~ /^(?:gdi32)_.+?$/) {
1116 @dependencies = ("wine", "include", "winebuild");
1119 if($project =~ /^gdi32$/) {
1120 foreach my $dir (@gdi32_dirs) {
1122 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
1124 my $module = "gdi32_$dir2";
1126 push @dependencies, $module;
1130 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1132 _generate_dsw_footer
(\
*OUT
);
1137 if ($options->winetest) {
1138 my $dsw_file = "winetest.dsw";
1139 $output->progress("$dsw_file");
1140 replace_file
("$wine_dir/$dsw_file", \
&_generate_winetest_dsw
);
1143 sub _generate_winetest_dsw
($) {
1146 _generate_dsw_header
(\
*OUT
);
1148 my @runtests_dependencies = ();
1149 foreach my $module (sort(keys(%modules))) {
1150 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1151 next if $module eq "wineruntests";
1153 my $project = $modules{$module}{project
};
1155 push @runtests_dependencies, $project;
1158 foreach my $module (sort(keys(%modules))) {
1159 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1161 my $project = $modules{$module}{project
};
1162 my $dsp_file = $modules{$module}{dsp_file
};
1165 if($project =~ /^winetest$/) {
1167 } elsif($project =~ /^wineruntests$/) {
1168 @dependencies = @runtests_dependencies;
1170 @dependencies = ("winetest");
1173 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1176 _generate_dsw_footer
(\
*OUT
);
1179 if ($options->winetest) {
1180 foreach my $module (sort(keys(%modules))) {
1181 next if $module !~ /_test\.exe$/;
1183 my $project = $modules{$module}{project
};
1184 my $dsp_file = $modules{$module}{dsp_file
};
1185 my @tests = @
{$modules{$module}{tests
}};
1187 my $testlist_c = $dsp_file;
1188 $testlist_c =~ s
%[^/]*\
.dsp
$%testlist.c
%;
1190 replace_file
("$wine_dir/$testlist_c", \
&_generate_testlist_c
, \
@tests);
1194 # ***** Keep in sync with tools/make_ctests *****
1195 sub _generate_testlist_c
($$) {
1198 my @tests = @
{(shift)};
1200 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1202 print OUT
"/* stdarg.h is needed for Winelib */\n";
1203 print OUT
"#include <stdarg.h>\n";
1204 print OUT
"#include <stdio.h>\n";
1205 print OUT
"#include <stdlib.h>\n";
1206 print OUT
"#include \"windef.h\"\n";
1207 print OUT
"#include \"winbase.h\"\n";
1209 print OUT
"#define STANDALONE\n";
1210 print OUT
"#include \"wine/test.h\"\n";
1212 foreach my $test (@tests) {
1213 print OUT
"extern void func_$test(void);\n";
1216 print OUT
"const struct test winetest_testlist[] =\n";
1218 foreach my $test (@tests) {
1219 print OUT
" { \"$test\", func_$test },\n";
1221 print OUT
" { 0, 0 }\n";
1225 if ($options->winetest) {
1226 replace_file
("$wine_dir/runtests.c", \
&_generate_runtests_c
);
1229 sub _generate_runtests_c
($) {
1232 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1235 print OUT
"#include <stdio.h>\n";
1236 print OUT
"#include <stdlib.h>\n";
1239 print OUT
"int main(int argc, char *argv[])\n";
1241 print OUT
" char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1242 print OUT
" char command[4096];\n";
1244 foreach my $dsp_file (keys(%runtests)) {
1245 my @tests = @
{$runtests{$dsp_file}};
1247 my $project = $dsp_file;
1248 $project =~ s
%^(.*?
)/?([^/]+)\
.dsp
$%$2%;
1252 foreach my $test (@tests) {
1253 print OUT
" sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1254 print OUT
" system(command);\n";
1258 print OUT
" return 0;\n";
1262 if ($options->winetest) {
1263 replace_file
("$wine_dir/winetest.c", \
&_generate_winetest_c
);
1266 sub _generate_winetest_c
($) {
1269 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n\n";
1271 print OUT
"/* Force the linker to generate a .lib file */\n";
1272 print OUT
"void __wine_dummy_lib_function(void)\n{\n}\n\n";
1275 if ($options->wine) {
1276 my $config_h = "include/config.h";
1278 $output->progress("$config_h");
1280 replace_file
("$wine_dir/$config_h", \
&_generate_config_h
);
1283 sub _generate_config_h
($) {
1287 print OUT
"#define __WINE_CONFIG_H\n";
1290 my @headers = qw(direct.h float.h memory.h io.h stdlib.h string.h process.h sys/stat.h sys/types.h);
1291 foreach my $header (@headers) {
1292 $header =~ y/\.\//__
/;
1293 push @defines, "HAVE_\U$header\E 1";
1297 _pclose _popen _snprintf _spawnvp _stricmp _strnicmp _strdup
1298 _strtoi64 _strtoui64 _vsnprintf
1299 chsize memmove strdup spawnvp strerror vsnprintf
1301 foreach my $function (@functions) {
1302 push @defines, "HAVE_\U$function\E 1";
1306 long_long off_t size_t
1308 foreach my $type (@types) {
1309 push @defines, "HAVE_\U$type\E 1";
1312 foreach my $define (sort(@defines)) {
1313 print OUT
"#define $define\n";
1317 print OUT
"/* Define to the address where bug reports for this package should be sent. */\n";
1318 print OUT
"#define PACKAGE_BUGREPORT \"\"\n";
1321 print OUT
"/* Define to the full name of this package. */\n";
1322 print OUT
"#define PACKAGE_NAME \"Wine\"\n";
1325 print OUT
"/* Define to the full name and version of this package. */\n";
1326 print OUT
"#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1329 print OUT
"/* Define to the one symbol short name of this package. */\n";
1330 print OUT
"#define PACKAGE_TARNAME \"wine\"\n";
1333 print OUT
"/* Define to the version of this package. */\n";
1334 print OUT
"#define PACKAGE_VERSION \"YYYYMMDD\"\n";
1337 print OUT
"#define X_DISPLAY_MISSING 1\n";
1340 print OUT
"/* Define to a macro to generate an assembly function directive */\n";
1341 print OUT
"#define __ASM_FUNC(name) \"\"\n";
1344 print OUT
"/* Define to a macro to generate an assembly name from a C symbol */\n";
1345 print OUT
"#define __ASM_NAME(name) name\n";