3 # Copyright 2002 Patrik Stridvall
8 $0 =~ m
%^(.*?
/?tools)/winapi
/msvcmaker
$%;
9 require "$1/winapi/setup.pm";
12 use config
qw(&file_directory &get_spec_files &get_makefile_in_files $current_dir $wine_dir);
13 use output qw($output);
14 use util qw(replace_file);
16 use msvcmaker_options
qw($options);
18 if($options->progress) {
19 $output->enable_progress;
21 $output->disable_progress;
24 ########################################################################
27 my @spec_files = get_spec_files("winelib");
28 my @makefile_in_files = get_makefile_in_files("winelib");
32 my $output_prefix_dir = "Output";
37 sub read_spec_file($) {
38 my $spec_file = shift;
40 my $module = $spec_file;
41 $module =~ s%^.*?([^/]+)\.spec$%$1%;
42 $module .= ".dll" if $module !~ /\./;
46 open(IN, "< $wine_dir/$spec_file");
50 while($lookahead || defined($_ = <IN>)) {
53 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begining and end of line
54 s/^(.*?)\s*#.*$/$1/; # remove comments
55 /^$/ && next; # skip empty lines
65 if(/^(\d+|@)\s+pascal(?:16)?/) {
73 if($module =~ /^(?:(?:imm|ole2conv|ole2prox|ole2thk|rasapi16|windebug)\.dll|comm\.drv)$/) {
77 if($type eq "win32") {
78 $modules{$module}{module} = $module;
79 $modules{$module}{type} = $type;
80 $modules{$module}{spec_file} = $spec_file;
84 if ($options->wine || $options->winetest) {
85 foreach my $spec_file (@spec_files) {
86 read_spec_file($spec_file);
90 my @gdi32_dirs = qw(dlls/gdi/enhmfdrv dlls/gdi/mfdrv);
91 my @ntdll_dirs = qw(misc);
92 my @user32_dirs = qw(dlls/user/dde windows);
94 push @makefile_in_files, "tools/winebuild/Makefile.in";
96 sub filter_files
($$) {
100 my $filtered_files = [];
101 my $rest_of_files = [];
102 foreach my $file (@
$files) {
103 if($file =~ /$filter/) {
104 $file =~ s
%.*?
([^/]+)$%./$1%; # FIXME: Kludge
105 push @
$filtered_files, $file;
107 push @
$rest_of_files, $file;
110 return ($rest_of_files, $filtered_files);
113 my %wine_test_dsp_files;
115 MAKEFILE_IN
: foreach my $makefile_in_file (@makefile_in_files) {
116 open(IN
, "< $wine_dir/$makefile_in_file");
127 while($again || defined(my $line = <IN
>)) {
140 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begining and end of line
141 s/^(.*?)\s*#.*$/$1/; # remove comments
142 /^$/ && next; # skip empty lines
149 if(/^MODULE\s*=\s*([\w\.]+)$/) {
152 if($module eq "none") {
153 if($makefile_in_file eq "library/Makefile.in") {
154 $module = "wine.dll";
155 } elsif($makefile_in_file eq "unicode/Makefile.in") {
156 $module = "wine_unicode.dll";
157 } elsif($makefile_in_file eq "tools/winebuild/Makefile.in") {
158 $module = "winebuild.exe";
163 } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
165 } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
167 } elsif (/^IMPORTS\s*=\s*/) {
168 push @imports, grep !/^ntdll$/, split /\s+/s, $';
169 } elsif (/^EXTRALIBS\s*=\s*/) {
170 push @imports, map { /^-l(dxerr8|dxerr9|dxguid|strmiids|uuid)$/ ? $1 : () } split /\s+/s, $';
171 } elsif (/^CTESTS\s*=\s*/) {
172 my @files = split /\s+/s, $';
174 my $dir = $makefile_in_file;
175 $dir =~ s/\/Makefile\.in$//;
177 my $dsp_file = $testdll;
178 $dsp_file =~ s/\.(dll|drv)$/_test.dsp/;
179 $dsp_file = "$dir/$dsp_file";
181 $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
182 $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
183 } elsif(/^(\w+)\s*=\s*/) {
185 my @files = split /\s+/s, $';
188 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
189 my @list = @
{$vars{$1}};
192 foreach my $item (@list) {
193 $item = "$prefix$item$suffix";
196 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
199 print STDERR
"unknown variable '$_'\n" if 0;
206 $vars{$var} = \
@files;
215 my $source_files = [];
216 if(exists($vars{C_SRCS
})) {
217 $c_srcs = [sort(@
{$vars{C_SRCS
}})];
218 $source_files = [sort(@
{$vars{C_SRCS
}})];
221 my $header_files = [];
222 if(exists($vars{H_SRCS
})) {
223 $header_files = [sort(@
{$vars{H_SRCS
}})];
226 my $resource_files = [];
227 if(exists($vars{RC_SRCS
})) {
228 $resource_files = [sort(@
{$vars{RC_SRCS
}})];
231 my $project = $module;
232 $project =~ s/\.(?:dll|exe|lib)$//;
236 if($module =~ /\.exe$/) {
238 } elsif($module =~ /\.lib$/) {
244 my $dsp_file = $makefile_in_file;
245 $dsp_file =~ s/Makefile.in$/$project.dsp/;
247 if($module eq "gdi32.dll") {
248 foreach my $dir (@gdi32_dirs) {
250 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
252 my $module = "gdi32_$dir2.lib";
255 my $project = "gdi32_$dir2";
259 my $dsp_file = "$dir/$project.dsp";
261 ($source_files, my $local_source_files) = filter_files
($source_files, "$dir2/");
262 ($header_files, my $local_header_files) = filter_files
($header_files, "$dir2/");
263 ($resource_files, my $local_resource_files) = filter_files
($resource_files, "$dir2/");
265 $modules{$module}{wine
} = 1;
266 $modules{$module}{winetest
} = 0;
267 $modules{$module}{project
} = $project;
268 $modules{$module}{type
} = $type;
269 $modules{$module}{dsp_file
} = $dsp_file;
270 $modules{$module}{c_srcs
} = $c_srcs;
271 $modules{$module}{source_files
} = $local_source_files;
272 $modules{$module}{header_files
} = $local_header_files;
273 $modules{$module}{resource_files
} = $local_resource_files;
274 $modules{$module}{imports
} = [];
276 } elsif($module eq "ntdll.dll") {
277 foreach my $dir (@ntdll_dirs) {
278 my $module = "ntdll_$dir.lib";
281 my $project = "ntdll_$dir";
285 my $dsp_file = "$dir/$project.dsp";
287 ($source_files, my $local_source_files) = filter_files
($source_files, "/$dir/");
288 ($header_files, my $local_header_files) = filter_files
($header_files, "/$dir/");
289 ($resource_files, my $local_resource_files) = filter_files
($resource_files, "/$dir/");
291 $modules{$module}{wine
} = 1;
292 $modules{$module}{winetest
} = 0;
293 $modules{$module}{project
} = $project;
294 $modules{$module}{type
} = $type;
295 $modules{$module}{dsp_file
} = $dsp_file;
296 $modules{$module}{c_srcs
} = $c_srcs;
297 $modules{$module}{source_files
} = $local_source_files;
298 $modules{$module}{header_files
} = $local_header_files;
299 $modules{$module}{resource_files
} = $local_resource_files;
300 $modules{$module}{imports
} = [];
302 } elsif($module eq "user32.dll") {
303 foreach my $dir (@user32_dirs) {
305 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
307 my $module = "user32_$dir2.lib";
310 my $project = "user32_$dir2";
314 my $dsp_file = "$dir/$project.dsp";
316 ($source_files, my $local_source_files) = filter_files
($source_files, "$dir2/");
317 ($header_files, my $local_header_files) = filter_files
($header_files, "$dir2/");
318 ($resource_files, my $local_resource_files) = filter_files
($resource_files, "$dir2/");
320 $modules{$module}{wine
} = 1;
321 $modules{$module}{winetest
} = 0;
322 $modules{$module}{project
} = $project;
323 $modules{$module}{type
} = $type;
324 $modules{$module}{dsp_file
} = $dsp_file;
325 $modules{$module}{c_srcs
} = $c_srcs;
326 $modules{$module}{source_files
} = $local_source_files;
327 $modules{$module}{header_files
} = $local_header_files;
328 $modules{$module}{resource_files
} = $local_resource_files;
329 $modules{$module}{imports
} = [];
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
} = $source_files;
340 $modules{$module}{header_files
} = $header_files;
341 $modules{$module}{resource_files
} = $resource_files;
342 $modules{$module}{imports
} = [];
345 $wine_test_dsp_files{"wineruntests.dsp"}{files
} = ["runtests.c"];
346 $wine_test_dsp_files{"wineruntests.dsp"}{imports
} = [];
348 $wine_test_dsp_files{"winetest.dsp"}{files
} = [
349 'include/wine/exception.h',
350 'include/wine/test.h',
351 'include/wine/unicode.h',
354 $wine_test_dsp_files{"winetest.dsp"}{imports
} = [];
358 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
359 my $project = $dsp_file;
360 $project =~ s
%^(?
:.*?
/)?([^/]+)\
.dsp
$%$1%;
362 my @files = @
{$wine_test_dsp_files{$dsp_file}{files
}};
363 my @imports = @
{$wine_test_dsp_files{$dsp_file}{imports
}};
367 my $source_files = [];
368 my $header_files = [];
369 my $resource_files = [];
373 if ($project eq "winetest") {
376 $source_files = [@files];
378 $resource_files = [];
379 } elsif ($project eq "wineruntests") {
382 $source_files = [@files];
384 $resource_files = [];
388 $source_files = [@files];
390 $resource_files = [];
393 if (/^testlist\.c$/) {
401 $runtests{$dsp_file} = [@tests];
403 my $module = "$project.$type";
405 $modules{$module}{wine
} = 0;
406 $modules{$module}{winetest
} = 1;
408 $modules{$module}{project
} = $project;
409 $modules{$module}{type
} = $type;
410 $modules{$module}{dsp_file
} = $dsp_file;
411 $modules{$module}{c_srcs
} = $c_srcs;
412 $modules{$module}{source_files
} = $source_files;
413 $modules{$module}{header_files
} = $header_files;
414 $modules{$module}{resource_files
} = $resource_files;
415 $modules{$module}{imports
} = [@imports];
417 $modules{$module}{tests
} = [@tests];
420 foreach my $module (sort(keys(%modules))) {
421 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
422 delete $modules{$module};
427 foreach my $module (sort(keys(%modules))) {
428 if (($options->wine && $modules{$module}{wine
}) ||
429 ($options->winetest && $modules{$module}{winetest
}))
431 push @modules, $module;
436 my $progress_current = 0;
437 my $progress_max = scalar(@modules);
439 foreach my $module (@modules) {
440 my $dsp_file = $modules{$module}{dsp_file
};
441 replace_file
("$wine_dir/$dsp_file", \
&_generate_dsp
, $module);
444 sub _generate_dsp
($$) {
449 my $dsp_file = $modules{$module}{dsp_file
};
450 my $project = $modules{$module}{project
};
451 my @imports = @
{$modules{$module}{imports
}};
453 my $lib = ($modules{$module}{type
} eq "lib");
454 my $dll = ($modules{$module}{type
} eq "dll");
455 my $exe = ($modules{$module}{type
} eq "exe");
457 my $console = $exe; # FIXME: Not always correct
459 my $msvc_wine_dir = do {
460 my @parts = split(m
%/%, $dsp_file);
463 } elsif($#parts == 2) {
469 my $wine_include_dir = "$msvc_wine_dir\\include";
472 $output->progress("$dsp_file (file $progress_current of $progress_max)");
474 my @c_srcs = @
{$modules{$module}{c_srcs
}};
475 my @source_files = @
{$modules{$module}{source_files
}};
476 my @header_files = @
{$modules{$module}{header_files
}};
477 my @resource_files = @
{$modules{$module}{resource_files
}};
479 if ($project !~ /^(?:wine(?:_unicode)?|wine(?:build|runtests|test))$/ &&
480 $project !~ /^(?:gdi32|ntdll|user32)_.+?$/ &&
481 $project !~ /_test$/)
483 push @source_files, "$project.spec";
484 # push @source_files, "$project.spec.c";
485 @source_files = sort(@source_files);
489 my $no_msvc_headers = 1;
490 if ($project =~ /^(?:wine(?:runtests|test))$/ || $project =~ /_test$/) {
491 $no_msvc_headers = 0;
496 push @cfgs, "$project - Win32";
500 foreach my $cfg (@cfgs) {
501 push @_cfgs, "$cfg C";
502 push @_cfgs, "$cfg C++";
509 foreach my $cfg (@cfgs) {
510 push @_cfgs, "$cfg Debug";
511 push @_cfgs, "$cfg Release";
516 if (!$no_msvc_headers) {
518 foreach my $cfg (@cfgs) {
519 push @_cfgs, "$cfg MSVC Headers";
520 push @_cfgs, "$cfg Wine Headers";
525 my $default_cfg = $cfgs[$#cfgs];
527 print OUT
"# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
528 print OUT
"# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
529 print OUT
"# ** DO NOT EDIT **\r\n";
533 print OUT
"# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
535 print OUT
"# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
537 print OUT
"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
541 print OUT
"CFG=$default_cfg\r\n";
542 print OUT
"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
543 print OUT
"!MESSAGE use the Export Makefile command and run\r\n";
544 print OUT
"!MESSAGE \r\n";
545 print OUT
"!MESSAGE NMAKE /f \"$project.mak\".\r\n";
546 print OUT
"!MESSAGE \r\n";
547 print OUT
"!MESSAGE You can specify a configuration when running NMAKE\r\n";
548 print OUT
"!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
549 print OUT
"!MESSAGE \r\n";
550 print OUT
"!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
551 print OUT
"!MESSAGE \r\n";
552 print OUT
"!MESSAGE Possible choices for configuration are:\r\n";
553 print OUT
"!MESSAGE \r\n";
554 foreach my $cfg (@cfgs) {
556 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
558 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
560 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
563 print OUT
"!MESSAGE \r\n";
566 print OUT
"# Begin Project\r\n";
567 print OUT
"# PROP AllowPerConfigDependencies 0\r\n";
568 print OUT
"# PROP Scc_ProjName \"\"\r\n";
569 print OUT
"# PROP Scc_LocalPath \"\"\r\n";
570 print OUT
"CPP=cl.exe\r\n";
571 print OUT
"MTL=midl.exe\r\n" if !$lib && !$exe;
572 print OUT
"RSC=rc.exe\r\n";
577 foreach my $cfg (@cfgs) {
581 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
585 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
589 my $debug = ($cfg !~ /Release/);
590 my $msvc_headers = ($cfg =~ /MSVC Headers/);
592 print OUT
"# PROP BASE Use_MFC 0\r\n";
595 print OUT
"# PROP BASE Use_Debug_Libraries 1\r\n";
597 print OUT
"# PROP BASE Use_Debug_Libraries 0\r\n";
601 $output_dir =~ s/^$project - //;
602 $output_dir =~ s/ /_/g;
603 $output_dir =~ s/C\+\+/Cxx/g;
604 if($output_prefix_dir) {
605 $output_dir = "$output_prefix_dir\\$output_dir";
608 print OUT
"# PROP BASE Output_Dir \"$output_dir\"\r\n";
609 print OUT
"# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
611 print OUT
"# PROP BASE Target_Dir \"\"\r\n";
613 print OUT
"# PROP Use_MFC 0\r\n";
615 print OUT
"# PROP Use_Debug_Libraries 1\r\n";
617 print OUT
"# PROP Use_Debug_Libraries 0\r\n";
619 print OUT
"# PROP Output_Dir \"$output_dir\"\r\n";
620 print OUT
"# PROP Intermediate_Dir \"$output_dir\"\r\n";
622 print OUT
"# PROP Ignore_Export_Lib 0\r\n" if $dll;
623 print OUT
"# PROP Target_Dir \"\"\r\n";
628 print OUT
"# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od";
629 @defines = (qw(WIN32 _DEBUG _MBCS _LIB));
631 print OUT
"# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
632 @defines = (qw(_WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
636 print OUT
"# ADD BASE CPP /nologo /W3 /GX /O2";
637 @defines = (qw(WIN32 NDEBUG _MBCS _LIB));
639 print OUT
"# ADD BASE CPP /nologo /MT /W3 /GX /O2";
640 @defines = (qw(WIN32 NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
644 foreach my $define (@defines) {
645 print OUT
" /D \"$define\"";
647 print OUT
" /YX" if $lib || $exe;
649 print OUT
" /GZ" if $debug;
650 print OUT
" " if $debug && ($lib || $exe);
657 print OUT
"# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
658 @defines2 = qw(WIN32 _DEBUG _WINDOWS _MBCS _LIB);
660 print OUT
"# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
661 @defines2 = qw(_DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
665 print OUT
"# ADD CPP /nologo /MT /W3 /GX /O2";
666 @defines2 = qw(WIN32 NDEBUG _WINDOWS _MBCS _LIB);
668 print OUT
"# ADD CPP /nologo /MT /W3 /GX /O2";
669 @defines2 = qw(NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
675 push @defines2, "_\U${project}\E_";
676 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
678 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
680 my $output_dir2 = $output_dir;
681 $output_dir =~ s/\\/\\\\/g;
682 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\"";
683 push @defines2, qw(__i386__ _X86_);
685 if($project =~ /^gdi32_(?:enhmfdrv|mfdrv|win16drv)$/) {
686 push @includes, "..";
689 if($project =~ /^user32_(?:windows)$/) {
690 push @includes, "..\\dlls\\user";
693 if($project =~ /^user32_dde$/) {
694 push @includes, "..";
697 if ($project =~ /_test$/) {
698 push @includes, "$msvc_wine_dir\\$output_dir";
701 if (!$msvc_headers || $project =~ /^winetest$/) {
702 push @includes, $wine_include_dir;
707 foreach my $include (@includes) {
708 if ($include !~ /[\\\"]/) {
709 print OUT
" /I \"$include\"";
711 print OUT
" /I $include";
716 foreach my $define (@defines2) {
717 if ($define !~ /[\\\"]/) {
718 print OUT
" /D \"$define\"";
720 print OUT
" /D $define";
723 print OUT
" /D inline=__inline" if $wine;
724 print OUT
" /D \"__STDC__\"" if 0 && $wine;
726 print OUT
" /YX" if $lib;
727 print OUT
" /FR" if !$lib;
729 print OUT
" /GZ" if $debug;
730 print OUT
" " if $debug && $lib;
732 print OUT
" /TP" if !$no_cpp;
736 print OUT
"# SUBTRACT CPP /X /YX\r\n" if $dll;
737 print OUT
"# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
738 print OUT
"# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
739 print OUT
"# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
740 print OUT
"# ADD RSC /l 0x41d";
742 foreach my $include (@includes) {
743 print OUT
" /i \"$include\"";
746 print OUT
" /d \"_DEBUG\"\r\n";
748 print OUT
"# SUBTRACT CPP /YX\r\n" if $dll;
749 print OUT
"# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
750 print OUT
"# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
751 print OUT
"# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
752 print OUT
"# ADD RSC /l 0x41d";
754 foreach my $include (@includes) {
755 print OUT
" /i \"$include\"";
758 print OUT
"/d \"NDEBUG\"\r\n";
760 print OUT
"BSC32=bscmake.exe\r\n";
761 print OUT
"# ADD BASE BSC32 /nologo\r\n";
762 print OUT
"# ADD BSC32 /nologo\r\n";
765 print OUT
"LINK32=link.exe\r\n";
766 print OUT
"# ADD BASE LINK32 ";
767 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
768 comdlg32.lib advapi32.lib shell32.lib ole32.lib
769 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
770 foreach my $library (@libraries) {
771 print OUT
"$library ";
773 print OUT
" /nologo";
774 print OUT
" /dll" if $dll;
775 print OUT
" /subsystem:console" if $console;
776 print OUT
" /debug" if $debug;
777 print OUT
" /machine:I386";
778 print OUT
" /pdbtype:sept" if $debug;
781 print OUT
"# ADD LINK32";
782 print OUT
" /nologo";
783 print OUT
" libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
784 foreach my $import (@imports) {
785 print OUT
" $import.lib" if ($import ne "msvcrt");
787 print OUT
" /dll" if $dll;
788 print OUT
" /subsystem:console" if $console;
789 print OUT
" /debug" if $debug;
790 print OUT
" /machine:I386";
791 print OUT
" /nodefaultlib" if $project =~ /^ntdll
$/; # FIXME: Kludge
792 print OUT
" /def:\"$project.def\"" if $dll;
793 print OUT
" /pdbtype:sept" if $debug;
796 print OUT
"LIB32=link.exe -lib\r\n";
797 print OUT
"# ADD BASE LIB32 /nologo\r\n";
798 print OUT
"# ADD LIB32 /nologo\r\n";
806 print OUT
"!ENDIF \r\n";
810 if ($project eq "winebuild") {
811 print OUT
"# Begin Special Build Tool\r\n";
812 print OUT
"SOURCE=\"\$(InputPath)\"\r\n";
813 print OUT
"PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n";
814 print OUT
"PostBuild_Cmds=";
815 print OUT
"copy ..\\..\\library\\$output_dir\\wine.dll \$(OutDir)\t";
816 print OUT
"copy ..\\..\\unicode\\$output_dir\\wine_unicode.dll \$(OutDir)\r\n";
817 print OUT
"# End Special Build Tool\r\n";
819 print OUT
"# Begin Target\r\n";
821 foreach my $cfg (@cfgs) {
822 print OUT
"# Name \"$cfg\"\r\n";
825 print OUT
"# Begin Group \"Source Files\"\r\n";
827 print OUT
"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
829 foreach my $source_file (@source_files) {
830 $source_file =~ s
%/%\\%g;
831 if($source_file !~ /^\./) {
832 $source_file = ".\\$source_file";
835 if($source_file =~ /^(.*?)\.spec$/) {
838 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
839 my $dbg_c_file = "$basename.dbg.c";
841 print OUT
"# Begin Source File\r\n";
843 print OUT
"SOURCE=$dbg_c_file\r\n";
844 print OUT
"# End Source File\r\n";
847 print OUT
"# Begin Source File\r\n";
850 print OUT
"SOURCE=$source_file\r\n";
852 if($source_file =~ /^(.*?)\.spec$/) {
855 my $spec_file = $source_file;
856 my $def_file = "$basename.def";
858 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
859 my $dbg_file = "$basename.dbg";
860 my $dbg_c_file = "$basename.dbg.c";
862 my $srcdir = "."; # FIXME: Is this really always correct?
864 print OUT
"# Begin Custom Build\r\n";
865 print OUT
"InputPath=$spec_file\r\n";
867 print OUT
"BuildCmds= \\\r\n";
868 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe --def $spec_file > $def_file \\\r\n";
870 if($project =~ /^ntdll$/) {
872 foreach my $c_src (@c_srcs) {
874 print OUT
"\techo $c_src >> $dbg_file \\\r\n";
876 print OUT
"\techo $c_src > $dbg_file \\\r\n";
879 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
880 print OUT
" -o $dbg_c_file --debug -C$srcdir $dbg_file \\\r\n";
882 my $c_srcs = join(" ", grep(/\.c$/, @c_srcs));
884 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
885 print OUT
" -o $dbg_c_file --debug -C$srcdir $c_srcs \\\r\n";
890 print OUT
"\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
891 print OUT
" \$(BuildCmds)\r\n";
893 print OUT
"\"$dbg_c_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
894 print OUT
" \$(BuildCmds)\r\n";
895 print OUT
"# End Custom Build\r\n";
896 } elsif($source_file =~ /([^\\]*?\.h)$/) {
899 foreach my $cfg (@cfgs) {
903 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
907 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
912 $output_dir =~ s/^$project - //;
913 $output_dir =~ s/ /_/g;
914 $output_dir =~ s/C\+\+/Cxx/g;
915 if($output_prefix_dir) {
916 $output_dir = "$output_prefix_dir\\$output_dir";
919 print OUT
"# Begin Custom Build\r\n";
920 print OUT
"OutDir=$output_dir\r\n";
921 print OUT
"InputPath=$source_file\r\n";
923 print OUT
"\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
924 print OUT
"\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
926 print OUT
"# End Custom Build\r\n";
931 print OUT
"!ENDIF \r\n";
936 print OUT
"# End Source File\r\n";
938 print OUT
"# End Group\r\n";
940 print OUT
"# Begin Group \"Header Files\"\r\n";
942 print OUT
"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
943 foreach my $header_file (@header_files) {
944 print OUT
"# Begin Source File\r\n";
946 print OUT
"SOURCE=.\\$header_file\r\n";
947 print OUT
"# End Source File\r\n";
949 print OUT
"# End Group\r\n";
953 print OUT
"# Begin Group \"Resource Files\"\r\n";
955 print OUT
"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
956 foreach my $resource_file (@resource_files) {
957 print OUT
"# Begin Source File\r\n";
959 print OUT
"SOURCE=.\\$resource_file\r\n";
960 print OUT
"# End Source File\r\n";
962 print OUT
"# End Group\r\n";
964 print OUT
"# End Target\r\n";
965 print OUT
"# End Project\r\n";
970 sub _generate_dsw_header
($) {
973 print OUT
"Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
974 print OUT
"# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
978 sub _generate_dsw_project
($$$$) {
982 my $dsp_file = shift;
983 my @dependencies = @
{(shift)};
985 $dsp_file = "./$dsp_file";
986 $dsp_file =~ y
%/%\\%;
988 @dependencies = sort(@dependencies);
990 print OUT
"###############################################################################\r\n";
992 print OUT
"Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
994 print OUT
"Package=<5>\r\n";
998 print OUT
"Package=<4>\r\n";
1000 foreach my $dependency (@dependencies) {
1001 print OUT
" Begin Project Dependency\r\n";
1002 print OUT
" Project_Dep_Name $dependency\r\n";
1003 print OUT
" End Project Dependency\r\n";
1005 print OUT
"}}}\r\n";
1009 sub _generate_dsw_footer
($) {
1012 print OUT
"###############################################################################\r\n";
1014 print OUT
"Global:\r\n";
1016 print OUT
"Package=<5>\r\n";
1017 print OUT
"{{{\r\n";
1018 print OUT
"}}}\r\n";
1020 print OUT
"Package=<3>\r\n";
1021 print OUT
"{{{\r\n";
1022 print OUT
"}}}\r\n";
1024 print OUT
"###############################################################################\r\n";
1028 if ($options->wine) {
1029 my $dsw_file = "wine.dsw";
1030 $output->progress("$dsw_file");
1031 replace_file
("$wine_dir/$dsw_file", \
&_generate_wine_dsw
);
1034 sub _generate_wine_dsw
($) {
1037 _generate_dsw_header
(\
*OUT
);
1038 foreach my $module (sort(keys(%modules))) {
1039 next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1041 my $project = $modules{$module}{project
};
1042 my $dsp_file = $modules{$module}{dsp_file
};
1045 if($project =~ /^wine(?:_unicode)?$/) {
1047 } elsif($project =~ /^winebuild$/) {
1048 @dependencies = ("wine", "wine_unicode");
1049 } elsif($project =~ /^(?:gdi32|ntdll|user32)_.+?$/) {
1052 @dependencies = ("wine", "wine_unicode", "winebuild");
1055 if($project =~ /^gdi32$/) {
1056 foreach my $dir (@gdi32_dirs) {
1058 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
1060 my $module = "gdi32_$dir2";
1062 push @dependencies, $module;
1064 } elsif($project =~ /^ntdll$/) {
1065 foreach my $dir (@ntdll_dirs) {
1066 my $module = "ntdll_$dir";
1068 push @dependencies, $module;
1070 } elsif($project =~ /^user32$/) {
1071 foreach my $dir (@user32_dirs) {
1073 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
1075 my $module = "user32_$dir2";
1077 push @dependencies, $module;
1081 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1083 _generate_dsw_footer
(\
*OUT
);
1088 if ($options->winetest) {
1089 my $dsw_file = "winetest.dsw";
1090 $output->progress("$dsw_file");
1091 replace_file
("$wine_dir/$dsw_file", \
&_generate_winetest_dsw
);
1094 sub _generate_winetest_dsw
($) {
1097 _generate_dsw_header
(\
*OUT
);
1099 my @runtests_dependencies = ();
1100 foreach my $module (sort(keys(%modules))) {
1101 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1102 next if $module eq "wineruntests";
1104 my $project = $modules{$module}{project
};
1106 push @runtests_dependencies, $project;
1109 foreach my $module (sort(keys(%modules))) {
1110 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1112 my $project = $modules{$module}{project
};
1113 my $dsp_file = $modules{$module}{dsp_file
};
1116 if($project =~ /^winetest$/) {
1118 } elsif($project =~ /^wineruntests$/) {
1119 @dependencies = @runtests_dependencies;
1121 @dependencies = ("winetest");
1124 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1127 _generate_dsw_footer
(\
*OUT
);
1130 if ($options->winetest) {
1131 foreach my $module (sort(keys(%modules))) {
1132 next if $module !~ /_test\.exe$/;
1134 my $project = $modules{$module}{project
};
1135 my $dsp_file = $modules{$module}{dsp_file
};
1136 my @tests = @
{$modules{$module}{tests
}};
1138 my $testlist_c = $dsp_file;
1139 $testlist_c =~ s
%[^/]*\
.dsp
$%testlist.c
%;
1141 replace_file
("$wine_dir/$testlist_c", \
&_generate_testlist_c
, \
@tests);
1145 # ***** Keep in sync with tools/make_ctests *****
1146 sub _generate_testlist_c
($$) {
1149 my @tests = @
{(shift)};
1151 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1153 print OUT
"/* stdarg.h is needed for Winelib */\n";
1154 print OUT
"#include <stdarg.h>\n";
1155 print OUT
"#include <stdio.h>\n";
1156 print OUT
"#include <stdlib.h>\n";
1157 print OUT
"#include \"windef.h\"\n";
1158 print OUT
"#include \"winbase.h\"\n";
1160 foreach my $test (@tests) {
1161 print OUT
"extern void func_$test(void);\n";
1164 print OUT
"struct test\n";
1166 print OUT
" const char *name;\n";
1167 print OUT
" void (*func)(void);\n";
1170 print OUT
"static const struct test winetest_testlist[] =\n";
1172 foreach my $test (@tests) {
1173 print OUT
" { \"$test\", func_$test },\n";
1175 print OUT
" { 0, 0 }\n";
1178 print OUT
"#define WINETEST_WANT_MAIN\n";
1179 print OUT
"#include \"wine/test.h\"\n";
1182 if ($options->winetest) {
1183 replace_file
("$wine_dir/runtests.c", \
&_generate_runtests_c
);
1186 sub _generate_runtests_c
($) {
1189 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1192 print OUT
"#include <stdio.h>\n";
1193 print OUT
"#include <stdlib.h>\n";
1196 print OUT
"int main(int argc, char *argv[])\n";
1198 print OUT
" char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1199 print OUT
" char command[4096];\n";
1201 foreach my $dsp_file (keys(%runtests)) {
1202 my @tests = @
{$runtests{$dsp_file}};
1204 my $project = $dsp_file;
1205 $project =~ s
%^(.*?
)/?([^/]+)\
.dsp
$%$2%;
1209 foreach my $test (@tests) {
1210 print OUT
" sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1211 print OUT
" system(command);\n";
1215 print OUT
" return 0;\n";
1219 if ($options->winetest) {
1220 replace_file
("$wine_dir/winetest.c", \
&_generate_winetest_c
);
1223 sub _generate_winetest_c
($) {
1226 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n\n";
1228 print OUT
"/* Force the linker to generate a .lib file */\n";
1229 print OUT
"void __wine_dummy_lib_function()\n{\n}\n\n";
1232 if ($options->wine) {
1233 my $config_h = "include/config.h";
1235 $output->progress("$config_h");
1237 replace_file
("$wine_dir/$config_h", \
&_generate_config_h
);
1240 sub _generate_config_h
($) {
1243 print OUT
"#define __WINE_CONFIG_H\n";
1246 my @headers = qw(direct.h fcntl.h io.h string.h process.h);
1247 foreach my $header (@headers) {
1248 $header =~ y/\.\//__
/;
1249 print OUT
"#define HAVE_\U$header\E\n";
1254 _alldiv _allmul _allrem _aulldiv _aullrem
1255 _access _chdir _close _lseek _mkdir _open _pclose _popen _read _rmdir _write _stat
1256 _snprintf _spawnvp _stricmp _strnicmp _vsnprintf _wcsicmp
1262 foreach my $function (@functions) {
1263 print OUT
"#define HAVE_\U$function\E 1\n";
1268 print OUT
"#define NEED_STDCALL_DECORATION 1\n";
1272 print OUT
"#define X_DISPLAY_MISSING 1\n";
1275 print OUT
"/* Define to a macro to generate an assembly function directive */\n";
1276 print OUT
"#define __ASM_FUNC(name) \"\"\n";
1279 print OUT
"/* Define to a macro to generate an assembly name from a C symbol */\n";
1280 print OUT
"#define __ASM_NAME(name) name\n";
1283 print OUT
"/* Define to the assembler keyword used to specify a word value */";
1284 print OUT
"define __ASM_SHORT \".short\"";
1287 print OUT
"/* Define to the assembler keyword used to specify an ASCII string */";
1288 print OUT
"#define __ASM_STRING \".string\"";
1291 print OUT
"/* Define to the address where bug reports for this package should be sent. */\n";
1292 print OUT
"#define PACKAGE_BUGREPORT \"\"\n";
1295 print OUT
"/* Define to the full name of this package. */\n";
1296 print OUT
"#define PACKAGE_NAME \"Wine\"\n";
1299 print OUT
"/* Define to the full name and version of this package. */\n";
1300 print OUT
"#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1303 print OUT
"/* Define to the one symbol short name of this package. */\n";
1304 print OUT
"#define PACKAGE_TARNAME \"wine\"\n";
1307 print OUT
"/* Define to the version of this package. */\n";
1308 print OUT
"#define PACKAGE_VERSION \"YYYYMMDD\"\n";