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\.]+)$/) {
183 } elsif (/^\@MAKE_IMPLIB_RULES\@/) {
185 } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
187 } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
189 } elsif (/^IMPORTS\s*=\s*/) {
190 push @imports, grep !/^ntdll$/, split /\s+/s, $';
191 } elsif (/^DELAYIMPORTS\s*=\s*/) {
193 } elsif (/^EXTRALIBS\s*=\s*/) {
194 push @imports, map { /^-l(dxerr8|dxerr9|dxguid|strmiids|uuid)$/ ? $1 : () } split /\s+/s, $';
195 } elsif (/^CTESTS\s*=\s*/ || ( ($makefile_in_file =~ /\/tests\
/Makefile\.in$/) && /^C_SRCS\s*=\s*/ ) ) {
196 my @files = split /\s+/s, $';
198 my $dir = $makefile_in_file;
199 $dir =~ s/\/Makefile\.in$//;
201 my $dsp_file = $testdll;
202 $dsp_file =~ s/\.(dll|drv)$/_test.dsp/;
203 $dsp_file = "$dir/$dsp_file";
205 $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
206 $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
207 } elsif(/^(\w+)\s*=\s*/) {
209 my @files = split /\s+/s, $';
212 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
213 my @list = @
{$vars{$1}};
216 foreach my $item (@list) {
217 $item = "$prefix$item$suffix";
220 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
223 print STDERR
"unknown variable '$_'\n" if 0;
230 $vars{$var} = \
@files;
237 if ($makefile_in_file eq "libs/wine/Makefile.in") {
238 $module = "wine.lib";
239 } elsif ($makefile_in_file eq "tools/winebuild/Makefile.in") {
240 $module = "winebuild.exe";
247 my $source_files = [];
248 if(exists($vars{C_SRCS
})) {
249 $c_srcs = [sort(@
{$vars{C_SRCS
}})];
250 $source_files = [sort(@
{$vars{C_SRCS
}})];
253 my $header_files = [];
254 if(exists($vars{H_SRCS
})) {
255 $header_files = [sort(@
{$vars{H_SRCS
}})];
258 my $resource_files = [];
259 if(exists($vars{RC_SRCS
})) {
260 $resource_files = [sort(@
{$vars{RC_SRCS
}})];
263 my $idl_h_files = [];
264 if(exists($vars{IDL_H_SRCS
})) {
265 $idl_h_files = [sort(@
{$vars{IDL_H_SRCS
}})];
268 my $idl_c_files = [];
269 if(exists($vars{IDL_C_SRCS
})) {
270 $idl_c_files = [sort(@
{$vars{IDL_C_SRCS
}})];
273 my $idl_s_files = [];
274 if(exists($vars{IDL_S_SRCS
})) {
275 $idl_s_files = [sort(@
{$vars{IDL_S_SRCS
}})];
278 my $idl_p_files = [];
279 if(exists($vars{IDL_P_SRCS
})) {
280 $idl_p_files = [sort(@
{$vars{IDL_P_SRCS
}})];
283 my $idl_tlb_files = [];
284 if(exists($vars{IDL_TLB_SRCS
})) {
285 $idl_tlb_files = [sort(@
{$vars{IDL_TLB_SRCS
}})];
289 if(exists($vars{EXTRADEFS
})) {
290 $extradefs = $vars{EXTRADEFS
};
293 my $project = $module;
294 $project =~ s/\.(?:dll|exe|lib)$//;
297 if($module =~ /\.exe$/) {
299 } elsif($module =~ /\.lib$/) {
305 my $dsp_file = $makefile_in_file;
306 $dsp_file =~ s/Makefile.in$/$project.dsp/;
308 if($module eq "gdi32.dll") {
309 foreach my $dir (@gdi32_dirs) {
311 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
313 my $module = "gdi32_$dir2.lib";
316 my $project = "gdi32_$dir2";
320 my $dsp_file = "$dir/$project.dsp";
322 ($source_files, my $local_source_files) = filter_files
($source_files, "$dir2/");
323 ($header_files, my $local_header_files) = filter_files
($header_files, "$dir2/");
324 ($resource_files, my $local_resource_files) = filter_files
($resource_files, "$dir2/");
325 ($idl_h_files, my $local_idl_h_files) = filter_files
($idl_h_files, "$dir2/");
327 $modules{$module}{wine
} = 1;
328 $modules{$module}{winetest
} = 0;
329 $modules{$module}{project
} = $project;
330 $modules{$module}{type
} = $type;
331 $modules{$module}{dsp_file
} = $dsp_file;
332 $modules{$module}{c_srcs
} = $c_srcs;
333 $modules{$module}{source_files
} = $local_source_files;
334 $modules{$module}{header_files
} = $local_header_files;
335 $modules{$module}{resource_files
} = $local_resource_files;
336 $modules{$module}{imports
} = [];
337 $modules{$module}{idl_h_files
} = $local_idl_h_files;
338 $modules{$module}{idl_c_files
} = [];
339 $modules{$module}{idl_s_files
} = [];
340 $modules{$module}{idl_p_files
} = [];
341 $modules{$module}{idl_tlb_files
} = [];
342 $modules{$module}{extradefs
} = $extradefs if $extradefs;
346 $modules{$module}{wine
} = 1;
347 $modules{$module}{winetest
} = 0;
348 $modules{$module}{project
} = $project;
349 $modules{$module}{type
} = $type;
350 $modules{$module}{dsp_file
} = $dsp_file;
351 $modules{$module}{c_srcs
} = $c_srcs;
352 $modules{$module}{source_files
} = $source_files;
353 $modules{$module}{header_files
} = $header_files;
354 $modules{$module}{resource_files
} = $resource_files;
355 $modules{$module}{imports
} = [@imports];
356 $modules{$module}{idl_h_files
} = $idl_h_files;
357 $modules{$module}{idl_c_files
} = $idl_c_files;
358 $modules{$module}{idl_s_files
} = $idl_s_files;
359 $modules{$module}{idl_p_files
} = $idl_p_files;
360 $modules{$module}{idl_tlb_files
} = $idl_tlb_files;
361 $modules{$module}{extradefs
} = $extradefs if $extradefs;
364 $wine_test_dsp_files{"wineruntests.dsp"}{files
} = ["runtests.c"];
365 $wine_test_dsp_files{"wineruntests.dsp"}{imports
} = [];
367 $wine_test_dsp_files{"winetest.dsp"}{files
} = [
368 'include/wine/exception.h',
369 'include/wine/test.h',
370 'include/wine/unicode.h',
373 $wine_test_dsp_files{"winetest.dsp"}{imports
} = [];
377 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
378 my $project = $dsp_file;
379 $project =~ s
%^(?
:.*?
/)?([^/]+)\
.dsp
$%$1%;
381 my @files = @
{$wine_test_dsp_files{$dsp_file}{files
}};
382 my @imports = @
{$wine_test_dsp_files{$dsp_file}{imports
}};
386 my $source_files = [];
387 my $header_files = [];
388 my $resource_files = [];
389 my $idl_h_files = [];
393 if ($project eq "winetest") {
396 $source_files = [@files];
398 $resource_files = [];
399 } elsif ($project eq "wineruntests") {
402 $source_files = [@files];
404 $resource_files = [];
408 $source_files = [@files];
410 $resource_files = [];
413 if (/^testlist\.c$/) {
421 $runtests{$dsp_file} = [@tests];
423 my $module = "$project.$type";
425 $modules{$module}{wine
} = 0;
426 $modules{$module}{winetest
} = 1;
428 $modules{$module}{project
} = $project;
429 $modules{$module}{type
} = $type;
430 $modules{$module}{dsp_file
} = $dsp_file;
431 $modules{$module}{c_srcs
} = $c_srcs;
432 $modules{$module}{source_files
} = $source_files;
433 $modules{$module}{header_files
} = $header_files;
434 $modules{$module}{resource_files
} = $resource_files;
435 $modules{$module}{imports
} = [@imports];
436 $modules{$module}{idl_h_files
} = [];
437 $modules{$module}{idl_c_files
} = [];
438 $modules{$module}{idl_s_files
} = [];
439 $modules{$module}{idl_p_files
} = [];
440 $modules{$module}{idl_tlb_files
} = [];
442 $modules{$module}{tests
} = [@tests];
445 foreach my $module (sort(keys(%modules))) {
446 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
447 delete $modules{$module};
452 foreach my $module (sort(keys(%modules))) {
453 if (($options->wine && $modules{$module}{wine
}) ||
454 ($options->winetest && $modules{$module}{winetest
}))
456 push @modules, $module;
461 my $progress_current = 0;
462 my $progress_max = scalar(@modules);
464 foreach my $module (@modules) {
465 my $dsp_file = $modules{$module}{dsp_file
};
466 replace_file
("$wine_dir/$dsp_file", \
&_generate_dsp
, $module);
469 sub output_dsp_idl_rules
($$$) {
470 my $wine_include_dir = shift;
472 my @idl_src_files = @
{(shift)};
474 foreach my $idl_src_file (@idl_src_files) {
475 $idl_src_file =~ s
%/%\\%g;
476 if($idl_src_file !~ /^\./) {
477 $idl_src_file = ".\\$idl_src_file";
480 print OUT
"# Begin Source File\r\n";
483 print OUT
"SOURCE=$idl_src_file\r\n";
485 my $basename = $idl_src_file;
486 $basename =~ s/\.idl$//;
488 print OUT
"# PROP Ignore_Default_Tool 1\r\n";
489 print OUT
"# Begin Custom Build\r\n";
490 print OUT
"InputPath=$idl_src_file\r\n";
492 print OUT
"BuildCmds= \\\r\n";
493 print OUT
"\tmidl /nologo /I $wine_include_dir $idl_src_file ";
495 print OUT
"/client none /server none /notlb /h ";
496 } elsif ($ext eq "_c.c") {
497 print OUT
"/server none /notlb /cstub ";
498 } elsif ($ext eq "_s.c") {
499 print OUT
"/client none /notlb /sstub ";
500 } elsif ($ext eq "_p.c") {
501 print OUT
"/client none /server none /notlb /proxy ";
502 } elsif ($ext eq ".tlb") {
503 print OUT
"/client none /server none /tlb ";
505 print OUT
"$basename$ext\r\n";
507 print OUT
"\"$basename$ext\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
508 print OUT
" \$(BuildCmds)\r\n";
509 print OUT
"# End Custom Build\r\n";
511 print OUT
"# End Source File\r\n";
515 sub _generate_dsp
($$) {
520 my $dsp_file = $modules{$module}{dsp_file
};
521 my $project = $modules{$module}{project
};
522 my @imports = @
{$modules{$module}{imports
}};
524 my $lib = ($modules{$module}{type
} eq "lib");
525 my $dll = ($modules{$module}{type
} eq "dll");
526 my $exe = ($modules{$module}{type
} eq "exe");
528 my $console = $exe; # FIXME: Not always correct
530 my $msvc_wine_dir = do {
531 my @parts = split(m
%/%, $dsp_file);
534 } elsif($#parts == 2) {
540 my $wine_include_dir = "$msvc_wine_dir\\include";
543 $output->progress("$dsp_file (file $progress_current of $progress_max)");
545 my $base_module = $module;
546 $base_module =~ s/\.(?:dll)$//;
548 my @c_srcs = @
{$modules{$module}{c_srcs
}};
549 my @source_files = @
{$modules{$module}{source_files
}};
550 my @header_files = @
{$modules{$module}{header_files
}};
551 my @resource_files = @
{$modules{$module}{resource_files
}};
552 my @idl_h_files = @
{$modules{$module}{idl_h_files
}};
553 my @idl_c_files = @
{$modules{$module}{idl_c_files
}};
554 my @idl_s_files = @
{$modules{$module}{idl_s_files
}};
555 my @idl_p_files = @
{$modules{$module}{idl_p_files
}};
556 my @idl_tlb_files = @
{$modules{$module}{idl_tlb_files
}};
558 if ($project !~ /^wine(?:build|runtests|test)?$/ &&
559 $project !~ /^(?:gdi32)_.+?$/ &&
560 $project !~ /_test$/ &&
563 push @source_files, "$base_module.spec";
564 @source_files = sort(@source_files);
568 my $no_msvc_headers = 1;
569 if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
570 $no_msvc_headers = 0;
575 push @cfgs, "$project - Win32";
579 foreach my $cfg (@cfgs) {
580 push @_cfgs, "$cfg C";
581 push @_cfgs, "$cfg C++";
588 foreach my $cfg (@cfgs) {
589 push @_cfgs, "$cfg Debug";
590 push @_cfgs, "$cfg Release";
595 foreach my $cfg (@cfgs) {
596 push @_cfgs, "$cfg Debug";
601 if (!$no_msvc_headers) {
603 foreach my $cfg (@cfgs) {
604 push @_cfgs, "$cfg MSVC Headers";
605 push @_cfgs, "$cfg Wine Headers";
610 my $default_cfg = $cfgs[$#cfgs];
612 print OUT
"# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
613 print OUT
"# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
614 print OUT
"# ** DO NOT EDIT **\r\n";
618 print OUT
"# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
620 print OUT
"# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
622 print OUT
"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
626 print OUT
"CFG=$default_cfg\r\n";
627 print OUT
"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
628 print OUT
"!MESSAGE use the Export Makefile command and run\r\n";
629 print OUT
"!MESSAGE \r\n";
630 print OUT
"!MESSAGE NMAKE /f \"$project.mak\".\r\n";
631 print OUT
"!MESSAGE \r\n";
632 print OUT
"!MESSAGE You can specify a configuration when running NMAKE\r\n";
633 print OUT
"!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
634 print OUT
"!MESSAGE \r\n";
635 print OUT
"!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
636 print OUT
"!MESSAGE \r\n";
637 print OUT
"!MESSAGE Possible choices for configuration are:\r\n";
638 print OUT
"!MESSAGE \r\n";
639 foreach my $cfg (@cfgs) {
641 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
643 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
645 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
648 print OUT
"!MESSAGE \r\n";
651 print OUT
"# Begin Project\r\n";
652 print OUT
"# PROP AllowPerConfigDependencies 0\r\n";
653 print OUT
"# PROP Scc_ProjName \"\"\r\n";
654 print OUT
"# PROP Scc_LocalPath \"\"\r\n";
655 print OUT
"CPP=cl.exe\r\n";
656 print OUT
"MTL=midl.exe\r\n" if !$lib && !$exe;
657 print OUT
"RSC=rc.exe\r\n";
663 foreach my $cfg (@cfgs) {
667 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
671 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
675 my $debug = ($cfg !~ /Release/);
676 my $msvc_headers = ($cfg =~ /MSVC Headers/);
678 print OUT
"# PROP BASE Use_MFC 0\r\n";
681 print OUT
"# PROP BASE Use_Debug_Libraries 1\r\n";
683 print OUT
"# PROP BASE Use_Debug_Libraries 0\r\n";
687 $output_dir =~ s/^$project - //;
688 $output_dir =~ s/ /_/g;
689 $output_dir =~ s/C\+\+/Cxx/g;
690 if($output_prefix_dir) {
691 $output_dir = "$output_prefix_dir\\$output_dir";
694 print OUT
"# PROP BASE Output_Dir \"$output_dir\"\r\n";
695 print OUT
"# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
697 print OUT
"# PROP BASE Target_Dir \"\"\r\n";
699 print OUT
"# PROP Use_MFC 0\r\n";
701 print OUT
"# PROP Use_Debug_Libraries 1\r\n";
703 print OUT
"# PROP Use_Debug_Libraries 0\r\n";
705 print OUT
"# PROP Output_Dir \"$output_dir\"\r\n";
706 print OUT
"# PROP Intermediate_Dir \"$output_dir\"\r\n";
708 print OUT
"# PROP Ignore_Export_Lib 0\r\n" if $dll;
709 print OUT
"# PROP Target_Dir \"\"\r\n";
711 print OUT
"# ADD BASE CPP /nologo ";
712 my @defines = qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 WIN32);
715 push @defines, qw(_DEBUG _MBCS _LIB);
718 push @defines, qw(_DEBUG _WINDOWS _MBCS _USRDLL);
720 print OUT
"/W3 /Gm /GX /Zi /Od";
723 push @defines, qw(NDEBUG _MBCS _LIB);
726 push @defines, qw(NDEBUG _WINDOWS _MBCS _USRDLL);
728 print OUT
"/W3 /GX /O2";
731 foreach my $define (@defines) {
732 if ($define !~ /=/) {
733 print OUT
" /D \"$define\"";
735 print OUT
" /D $define";
738 print OUT
" /YX" if $lib || $exe;
740 print OUT
" /GZ" if $debug;
744 my @defines2 = qw(_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
745 USE_COMPILER_EXCEPTIONS _USE_MATH_DEFINES
746 WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700);
749 print OUT
"# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
750 push @defines2, qw(WIN32 _DEBUG _WINDOWS _MBCS _LIB);
752 print OUT
"# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
753 push @defines2, qw(_DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
757 print OUT
"# ADD CPP /nologo /MD /W3 /GX /O2";
758 push @defines2, qw(WIN32 NDEBUG _WINDOWS _MBCS _LIB);
760 print OUT
"# ADD CPP /nologo /MD /W3 /GX /O2";
761 push @defines2, qw(NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
767 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
769 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
771 my $output_dir2 = $output_dir;
772 $output_dir2 =~ s/\\/\\\\/g;
773 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir2\\\"";
774 push @defines2, qw(__i386__ _X86_);
776 if ($project eq "wine") {
777 push @defines2, "WINE_UNICODE_API=";
780 if ($project =~ /_test$/) {
781 push @includes, "$msvc_wine_dir\\$output_dir";
784 if (!$msvc_headers || $project eq "winetest") {
785 push @includes, $wine_include_dir;
790 foreach my $include (@includes) {
791 print OUT
" /I \"$include\"";
795 foreach my $define (@defines2) {
796 if ($define !~ /=/) {
797 print OUT
" /D \"$define\"";
799 print OUT
" /D $define";
802 print OUT
" /D inline=__inline" if $wine;
803 print OUT
" /D \"__STDC__\"" if 0 && $wine;
805 if(exists($modules{$module}{extradefs
})) {
806 print OUT
" @{$modules{$module}{extradefs}} ";
809 print OUT
" /YX" if $lib;
810 print OUT
" /FR" if !$lib;
812 print OUT
" /GZ" if $debug;
814 print OUT
" /TP" if !$no_cpp;
818 print OUT
"# SUBTRACT CPP /X /YX\r\n" if $dll;
819 print OUT
"# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
820 print OUT
"# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
821 print OUT
"# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
822 print OUT
"# ADD RSC /l 0x41d";
824 foreach my $include (@includes) {
825 print OUT
" /i \"$include\"";
828 print OUT
" /d \"_DEBUG\"\r\n";
830 print OUT
"# SUBTRACT CPP /YX\r\n" if $dll;
831 print OUT
"# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
832 print OUT
"# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
833 print OUT
"# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
834 print OUT
"# ADD RSC /l 0x41d";
836 foreach my $include (@includes) {
837 print OUT
" /i \"$include\"";
840 print OUT
"/d \"NDEBUG\"\r\n";
842 print OUT
"BSC32=bscmake.exe\r\n";
843 print OUT
"# ADD BASE BSC32 /nologo\r\n";
844 print OUT
"# ADD BSC32 /nologo\r\n";
847 print OUT
"LINK32=link.exe\r\n";
848 print OUT
"# ADD BASE LINK32";
849 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
850 comdlg32.lib advapi32.lib shell32.lib ole32.lib
851 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
852 foreach my $library (@libraries) {
853 print OUT
" $library";
855 print OUT
" /nologo";
856 print OUT
" /dll" if $dll;
857 print OUT
" /subsystem:console" if $console;
858 print OUT
" /debug" if $debug;
859 print OUT
" /machine:I386";
860 print OUT
" /pdbtype:sept" if $debug;
863 print OUT
"# ADD LINK32";
864 print OUT
" libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
865 foreach my $import (@imports) {
866 print OUT
" $import.lib" if ($import ne "msvcrt");
868 print OUT
" /nologo";
869 print OUT
" /dll" if $dll;
870 print OUT
" /subsystem:console" if $console;
871 print OUT
" /debug" if $debug;
872 print OUT
" /machine:I386";
873 print OUT
" /nodefaultlib" if $project =~ /^ntdll
$/; # FIXME: Kludge
874 print OUT
" /def:\"$project.def\"" if $dll;
875 print OUT
" /pdbtype:sept" if $debug;
878 print OUT
"LIB32=link.exe -lib\r\n";
879 print OUT
"# ADD BASE LIB32 /nologo\r\n";
880 print OUT
"# ADD LIB32 /nologo\r\n";
888 print OUT
"!ENDIF \r\n";
892 print OUT
"# Begin Target\r\n";
894 foreach my $cfg (@cfgs) {
895 print OUT
"# Name \"$cfg\"\r\n";
898 print OUT
"# Begin Group \"Source Files\"\r\n";
900 print OUT
"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
902 if ($project eq "winebuild") {
903 for my $ source_file
("getopt.c", "getopt1.c", "mkstemps.c")
905 print OUT
"# Begin Source File\r\n";
907 print OUT
"SOURCE=..\\..\\libs\\port\\$source_file\r\n";
908 print OUT
"# End Source File\r\n";
912 foreach my $source_file (@source_files) {
913 $source_file =~ s
%/%\\%g;
914 if($source_file !~ /^\./) {
915 $source_file = ".\\$source_file";
918 print OUT
"# Begin Source File\r\n";
921 print OUT
"SOURCE=$source_file\r\n";
923 if ($project eq "wine" && $source_file eq ".\\config.c") {
924 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";
927 if($source_file =~ /^(.*?)\.spec$/) {
930 my $spec_file = $source_file;
931 my $def_file = "$basename.def";
933 my $srcdir = "."; # FIXME: Is this really always correct?
935 print OUT
"# Begin Custom Build\r\n";
936 print OUT
"InputPath=$spec_file\r\n";
938 print OUT
"BuildCmds= \\\r\n";
939 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe -w --def -k -o $def_file --export $spec_file\r\n";
941 print OUT
"\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
942 print OUT
" \$(BuildCmds)\r\n";
943 print OUT
"# End Custom Build\r\n";
944 } elsif($source_file =~ /([^\\]*?\.h)$/) {
947 foreach my $cfg (@cfgs) {
951 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
955 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
960 $output_dir =~ s/^$project - //;
961 $output_dir =~ s/ /_/g;
962 $output_dir =~ s/C\+\+/Cxx/g;
963 if($output_prefix_dir) {
964 $output_dir = "$output_prefix_dir\\$output_dir";
967 print OUT
"# Begin Custom Build\r\n";
968 print OUT
"OutDir=$output_dir\r\n";
969 print OUT
"InputPath=$source_file\r\n";
971 print OUT
"\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
972 print OUT
"\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
974 print OUT
"# End Custom Build\r\n";
979 print OUT
"!ENDIF \r\n";
984 print OUT
"# End Source File\r\n";
987 output_dsp_idl_rules
$wine_include_dir, ".h", \
@idl_h_files;
988 output_dsp_idl_rules
$wine_include_dir, "_c.c", \
@idl_c_files;
989 output_dsp_idl_rules
$wine_include_dir, "_s.c", \
@idl_s_files;
990 output_dsp_idl_rules
$wine_include_dir, "_p.c", \
@idl_p_files;
991 # Hack - stdole2.idl cannot be compiled with midl
992 if($project ne "include") {
993 output_dsp_idl_rules
$wine_include_dir, ".tlb", \
@idl_tlb_files;
996 print OUT
"# End Group\r\n";
998 print OUT
"# Begin Group \"Header Files\"\r\n";
1000 print OUT
"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
1001 foreach my $header_file (@header_files) {
1002 print OUT
"# Begin Source File\r\n";
1004 print OUT
"SOURCE=.\\$header_file\r\n";
1005 print OUT
"# End Source File\r\n";
1007 print OUT
"# End Group\r\n";
1011 print OUT
"# Begin Group \"Resource Files\"\r\n";
1013 print OUT
"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
1014 foreach my $resource_file (@resource_files) {
1015 print OUT
"# Begin Source File\r\n";
1017 print OUT
"SOURCE=.\\$resource_file\r\n";
1018 print OUT
"# End Source File\r\n";
1020 print OUT
"# End Group\r\n";
1022 print OUT
"# End Target\r\n";
1023 print OUT
"# End Project\r\n";
1028 sub _generate_dsw_header
($) {
1031 print OUT
"Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
1032 print OUT
"# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
1036 sub _generate_dsw_project
($$$$) {
1039 my $project = shift;
1040 my $dsp_file = shift;
1041 my @dependencies = @
{(shift)};
1043 $dsp_file = "./$dsp_file";
1044 $dsp_file =~ y
%/%\\%;
1046 @dependencies = sort(@dependencies);
1048 print OUT
"###############################################################################\r\n";
1050 print OUT
"Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
1052 print OUT
"Package=<5>\r\n";
1053 print OUT
"{{{\r\n";
1054 print OUT
"}}}\r\n";
1056 print OUT
"Package=<4>\r\n";
1057 print OUT
"{{{\r\n";
1058 foreach my $dependency (@dependencies) {
1059 print OUT
" Begin Project Dependency\r\n";
1060 print OUT
" Project_Dep_Name $dependency\r\n";
1061 print OUT
" End Project Dependency\r\n";
1063 print OUT
"}}}\r\n";
1067 sub _generate_dsw_footer
($) {
1070 print OUT
"###############################################################################\r\n";
1072 print OUT
"Global:\r\n";
1074 print OUT
"Package=<5>\r\n";
1075 print OUT
"{{{\r\n";
1076 print OUT
"}}}\r\n";
1078 print OUT
"Package=<3>\r\n";
1079 print OUT
"{{{\r\n";
1080 print OUT
"}}}\r\n";
1082 print OUT
"###############################################################################\r\n";
1086 if ($options->wine) {
1087 my $dsw_file = "wine.dsw";
1088 $output->progress("$dsw_file");
1089 replace_file
("$wine_dir/$dsw_file", \
&_generate_wine_dsw
);
1092 sub _generate_wine_dsw
($) {
1095 _generate_dsw_header
(\
*OUT
);
1096 foreach my $module (sort(keys(%modules))) {
1097 next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1099 my $project = $modules{$module}{project
};
1100 my $dsp_file = $modules{$module}{dsp_file
};
1103 if($project eq "wine") {
1105 } elsif($project eq "winebuild") {
1106 @dependencies = ("wine");
1107 } elsif($project =~ /^(?:gdi32)_.+?$/) {
1110 @dependencies = ("wine", "include", "winebuild");
1113 if($project =~ /^gdi32$/) {
1114 foreach my $dir (@gdi32_dirs) {
1116 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
1118 my $module = "gdi32_$dir2";
1120 push @dependencies, $module;
1124 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1126 _generate_dsw_footer
(\
*OUT
);
1131 if ($options->winetest) {
1132 my $dsw_file = "winetest.dsw";
1133 $output->progress("$dsw_file");
1134 replace_file
("$wine_dir/$dsw_file", \
&_generate_winetest_dsw
);
1137 sub _generate_winetest_dsw
($) {
1140 _generate_dsw_header
(\
*OUT
);
1142 my @runtests_dependencies = ();
1143 foreach my $module (sort(keys(%modules))) {
1144 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1145 next if $module eq "wineruntests";
1147 my $project = $modules{$module}{project
};
1149 push @runtests_dependencies, $project;
1152 foreach my $module (sort(keys(%modules))) {
1153 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1155 my $project = $modules{$module}{project
};
1156 my $dsp_file = $modules{$module}{dsp_file
};
1159 if($project =~ /^winetest$/) {
1161 } elsif($project =~ /^wineruntests$/) {
1162 @dependencies = @runtests_dependencies;
1164 @dependencies = ("winetest");
1167 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1170 _generate_dsw_footer
(\
*OUT
);
1173 if ($options->winetest) {
1174 foreach my $module (sort(keys(%modules))) {
1175 next if $module !~ /_test\.exe$/;
1177 my $project = $modules{$module}{project
};
1178 my $dsp_file = $modules{$module}{dsp_file
};
1179 my @tests = @
{$modules{$module}{tests
}};
1181 my $testlist_c = $dsp_file;
1182 $testlist_c =~ s
%[^/]*\
.dsp
$%testlist.c
%;
1184 replace_file
("$wine_dir/$testlist_c", \
&_generate_testlist_c
, \
@tests);
1188 # ***** Keep in sync with tools/make_ctests *****
1189 sub _generate_testlist_c
($$) {
1192 my @tests = @
{(shift)};
1194 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1196 print OUT
"/* stdarg.h is needed for Winelib */\n";
1197 print OUT
"#include <stdarg.h>\n";
1198 print OUT
"#include <stdio.h>\n";
1199 print OUT
"#include <stdlib.h>\n";
1200 print OUT
"#include \"windef.h\"\n";
1201 print OUT
"#include \"winbase.h\"\n";
1203 print OUT
"#define STANDALONE\n";
1204 print OUT
"#include \"wine/test.h\"\n";
1206 foreach my $test (@tests) {
1207 print OUT
"extern void func_$test(void);\n";
1210 print OUT
"const struct test winetest_testlist[] =\n";
1212 foreach my $test (@tests) {
1213 print OUT
" { \"$test\", func_$test },\n";
1215 print OUT
" { 0, 0 }\n";
1219 if ($options->winetest) {
1220 replace_file
("$wine_dir/runtests.c", \
&_generate_runtests_c
);
1223 sub _generate_runtests_c
($) {
1226 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1229 print OUT
"#include <stdio.h>\n";
1230 print OUT
"#include <stdlib.h>\n";
1233 print OUT
"int main(int argc, char *argv[])\n";
1235 print OUT
" char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1236 print OUT
" char command[4096];\n";
1238 foreach my $dsp_file (keys(%runtests)) {
1239 my @tests = @
{$runtests{$dsp_file}};
1241 my $project = $dsp_file;
1242 $project =~ s
%^(.*?
)/?([^/]+)\
.dsp
$%$2%;
1246 foreach my $test (@tests) {
1247 print OUT
" sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1248 print OUT
" system(command);\n";
1252 print OUT
" return 0;\n";
1256 if ($options->winetest) {
1257 replace_file
("$wine_dir/winetest.c", \
&_generate_winetest_c
);
1260 sub _generate_winetest_c
($) {
1263 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n\n";
1265 print OUT
"/* Force the linker to generate a .lib file */\n";
1266 print OUT
"void __wine_dummy_lib_function(void)\n{\n}\n\n";
1269 if ($options->wine) {
1270 my $config_h = "include/config.h";
1272 $output->progress("$config_h");
1274 replace_file
("$wine_dir/$config_h", \
&_generate_config_h
);
1277 sub _generate_config_h
($) {
1281 print OUT
"#define __WINE_CONFIG_H\n";
1284 my @headers = qw(direct.h float.h memory.h io.h stdlib.h string.h process.h sys/stat.h sys/types.h);
1285 foreach my $header (@headers) {
1286 $header =~ y/\.\//__
/;
1287 push @defines, "HAVE_\U$header\E 1";
1291 _pclose _popen _snprintf _spawnvp _stricmp _strnicmp _strdup
1292 _strtoi64 _strtoui64 _vsnprintf
1293 chsize memmove strdup spawnvp strerror vsnprintf
1295 foreach my $function (@functions) {
1296 push @defines, "HAVE_\U$function\E 1";
1300 long_long off_t size_t
1302 foreach my $type (@types) {
1303 push @defines, "HAVE_\U$type\E 1";
1306 foreach my $define (sort(@defines)) {
1307 print OUT
"#define $define\n";
1311 print OUT
"/* Define to the address where bug reports for this package should be sent. */\n";
1312 print OUT
"#define PACKAGE_BUGREPORT \"\"\n";
1315 print OUT
"/* Define to the full name of this package. */\n";
1316 print OUT
"#define PACKAGE_NAME \"Wine\"\n";
1319 print OUT
"/* Define to the full name and version of this package. */\n";
1320 print OUT
"#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1323 print OUT
"/* Define to the one symbol short name of this package. */\n";
1324 print OUT
"#define PACKAGE_TARNAME \"wine\"\n";
1327 print OUT
"/* Define to the version of this package. */\n";
1328 print OUT
"#define PACKAGE_VERSION \"YYYYMMDD\"\n";
1331 print OUT
"#define X_DISPLAY_MISSING 1\n";
1334 print OUT
"/* Define to a macro to generate an assembly function directive */\n";
1335 print OUT
"#define __ASM_FUNC(name) \"\"\n";
1338 print OUT
"/* Define to a macro to generate an assembly name from a C symbol */\n";
1339 print OUT
"#define __ASM_NAME(name) name\n";