3 # Copyright 2002 Patrik Stridvall
8 $0 =~ m
%^(.*?
/?tools)/winapi
/msvcmaker
$%;
9 require "$1/winapi/setup.pm";
12 use setup
qw($current_dir $wine_dir);
13 use lib $setup::winapi_dir;
14 use config qw(get_spec_files get_makefile_in_files);
15 use output
qw($output);
16 use util qw(replace_file);
18 use msvcmaker_options
qw($options);
20 if($options->progress) {
21 $output->enable_progress;
23 $output->disable_progress;
26 ########################################################################
29 my @spec_files = get_spec_files("winelib");
30 my @makefile_in_files = get_makefile_in_files("winelib");
34 my $output_prefix_dir = "Output";
39 sub read_spec_file($) {
40 my $spec_file = shift;
42 my $module = $spec_file;
43 $module =~ s%^.*?([^/]+)\.spec$%$1%;
44 $module .= ".dll" if $module !~ /\./;
48 open(IN, "< $wine_dir/$spec_file");
52 while($lookahead || defined($_ = <IN>)) {
55 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
56 s/^(.*?)\s*#.*$/$1/; # remove comments
57 /^$/ && next; # skip empty lines
67 if(/^(\d+|@)\s+pascal(?:16)?/) {
75 if($module =~ /^(?:(?:imm|ole2conv|ole2prox|ole2thk|rasapi16|msacm|windebug)\.dll|comm\.drv)$/) {
79 if($type eq "win32") {
80 $modules{$module}{module} = $module;
81 $modules{$module}{type} = $type;
82 $modules{$module}{spec_file} = $spec_file;
86 if ($options->wine || $options->winetest) {
87 foreach my $spec_file (@spec_files) {
88 read_spec_file($spec_file);
92 my @gdi32_dirs = qw(dlls/gdi/enhmfdrv dlls/gdi/mfdrv);
94 push @makefile_in_files, "libs/wine/Makefile.in";
95 push @makefile_in_files, "libs/unicode/Makefile.in";
96 push @makefile_in_files, "tools/winebuild/Makefile.in";
98 sub filter_files
($$) {
102 my $filtered_files = [];
103 my $rest_of_files = [];
104 foreach my $file (@
$files) {
105 if($file =~ /$filter/) {
106 $file =~ s
%.*?
([^/]+)$%./$1%; # FIXME: Kludge
107 push @
$filtered_files, $file;
109 push @
$rest_of_files, $file;
112 return ($rest_of_files, $filtered_files);
115 my %wine_test_dsp_files;
117 MAKEFILE_IN
: foreach my $makefile_in_file (@makefile_in_files) {
118 open(IN
, "< $wine_dir/$makefile_in_file");
130 if($makefile_in_file eq "loader/Makefile.in") {
134 while($again || defined(my $line = <IN
>)) {
147 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
148 s/^(.*?)\s*#.*$/$1/; # remove comments
149 /^$/ && next; # skip empty lines
156 if(/^MODULE\s*=\s*([\w\.]+)$/) {
159 if($module eq "none") {
160 if($makefile_in_file eq "tools/winebuild/Makefile.in") {
161 $module = "winebuild.exe";
166 } elsif(/^LIBRARY\s*=\s*(\S+)\s*$/) {
167 $module = $1 . "\.lib";
168 } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
170 } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
172 } elsif (/^IMPORTS\s*=\s*/) {
173 push @imports, grep !/^ntdll$/, split /\s+/s, $';
174 } elsif (/^EXTRALIBS\s*=\s*/) {
175 push @imports, map { /^-l(dxerr8|dxerr9|dxguid|strmiids|uuid)$/ ? $1 : () } split /\s+/s, $';
176 } elsif (/^CTESTS\s*=\s*/) {
177 my @files = split /\s+/s, $';
179 my $dir = $makefile_in_file;
180 $dir =~ s/\/Makefile\.in$//;
182 my $dsp_file = $testdll;
183 $dsp_file =~ s/\.(dll|drv)$/_test.dsp/;
184 $dsp_file = "$dir/$dsp_file";
186 $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
187 $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
188 } elsif(/^(\w+)\s*=\s*/) {
190 my @files = split /\s+/s, $';
193 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
194 my @list = @
{$vars{$1}};
197 foreach my $item (@list) {
198 $item = "$prefix$item$suffix";
201 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
204 print STDERR
"unknown variable '$_'\n" if 0;
211 $vars{$var} = \
@files;
220 my $source_files = [];
221 if(exists($vars{C_SRCS
})) {
222 $c_srcs = [sort(@
{$vars{C_SRCS
}})];
223 $source_files = [sort(@
{$vars{C_SRCS
}})];
226 my $header_files = [];
227 if(exists($vars{H_SRCS
})) {
228 $header_files = [sort(@
{$vars{H_SRCS
}})];
231 my $resource_files = [];
232 if(exists($vars{RC_SRCS
})) {
233 $resource_files = [sort(@
{$vars{RC_SRCS
}})];
236 my $project = $module;
237 $project =~ s/\.(?:dll|exe|lib)$//;
241 if($module =~ /\.exe$/) {
243 } elsif($module =~ /\.lib$/) {
249 my $dsp_file = $makefile_in_file;
250 $dsp_file =~ s/Makefile.in$/$project.dsp/;
252 if($module eq "gdi32.dll") {
253 foreach my $dir (@gdi32_dirs) {
255 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
257 my $module = "gdi32_$dir2.lib";
260 my $project = "gdi32_$dir2";
264 my $dsp_file = "$dir/$project.dsp";
266 ($source_files, my $local_source_files) = filter_files
($source_files, "$dir2/");
267 ($header_files, my $local_header_files) = filter_files
($header_files, "$dir2/");
268 ($resource_files, my $local_resource_files) = filter_files
($resource_files, "$dir2/");
270 $modules{$module}{wine
} = 1;
271 $modules{$module}{winetest
} = 0;
272 $modules{$module}{project
} = $project;
273 $modules{$module}{type
} = $type;
274 $modules{$module}{dsp_file
} = $dsp_file;
275 $modules{$module}{c_srcs
} = $c_srcs;
276 $modules{$module}{source_files
} = $local_source_files;
277 $modules{$module}{header_files
} = $local_header_files;
278 $modules{$module}{resource_files
} = $local_resource_files;
279 $modules{$module}{imports
} = [];
283 $modules{$module}{wine
} = 1;
284 $modules{$module}{winetest
} = 0;
285 $modules{$module}{project
} = $project;
286 $modules{$module}{type
} = $type;
287 $modules{$module}{dsp_file
} = $dsp_file;
288 $modules{$module}{c_srcs
} = $c_srcs;
289 $modules{$module}{source_files
} = $source_files;
290 $modules{$module}{header_files
} = $header_files;
291 $modules{$module}{resource_files
} = $resource_files;
292 $modules{$module}{imports
} = [];
295 $wine_test_dsp_files{"wineruntests.dsp"}{files
} = ["runtests.c"];
296 $wine_test_dsp_files{"wineruntests.dsp"}{imports
} = [];
298 $wine_test_dsp_files{"winetest.dsp"}{files
} = [
299 'include/wine/exception.h',
300 'include/wine/test.h',
301 'include/wine/unicode.h',
304 $wine_test_dsp_files{"winetest.dsp"}{imports
} = [];
308 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
309 my $project = $dsp_file;
310 $project =~ s
%^(?
:.*?
/)?([^/]+)\
.dsp
$%$1%;
312 my @files = @
{$wine_test_dsp_files{$dsp_file}{files
}};
313 my @imports = @
{$wine_test_dsp_files{$dsp_file}{imports
}};
317 my $source_files = [];
318 my $header_files = [];
319 my $resource_files = [];
323 if ($project eq "winetest") {
326 $source_files = [@files];
328 $resource_files = [];
329 } elsif ($project eq "wineruntests") {
332 $source_files = [@files];
334 $resource_files = [];
338 $source_files = [@files];
340 $resource_files = [];
343 if (/^testlist\.c$/) {
351 $runtests{$dsp_file} = [@tests];
353 my $module = "$project.$type";
355 $modules{$module}{wine
} = 0;
356 $modules{$module}{winetest
} = 1;
358 $modules{$module}{project
} = $project;
359 $modules{$module}{type
} = $type;
360 $modules{$module}{dsp_file
} = $dsp_file;
361 $modules{$module}{c_srcs
} = $c_srcs;
362 $modules{$module}{source_files
} = $source_files;
363 $modules{$module}{header_files
} = $header_files;
364 $modules{$module}{resource_files
} = $resource_files;
365 $modules{$module}{imports
} = [@imports];
367 $modules{$module}{tests
} = [@tests];
370 foreach my $module (sort(keys(%modules))) {
371 if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
372 delete $modules{$module};
377 foreach my $module (sort(keys(%modules))) {
378 if (($options->wine && $modules{$module}{wine
}) ||
379 ($options->winetest && $modules{$module}{winetest
}))
381 push @modules, $module;
386 my $progress_current = 0;
387 my $progress_max = scalar(@modules);
389 foreach my $module (@modules) {
390 my $dsp_file = $modules{$module}{dsp_file
};
391 replace_file
("$wine_dir/$dsp_file", \
&_generate_dsp
, $module);
394 sub _generate_dsp
($$) {
399 my $dsp_file = $modules{$module}{dsp_file
};
400 my $project = $modules{$module}{project
};
401 my @imports = @
{$modules{$module}{imports
}};
403 my $lib = ($modules{$module}{type
} eq "lib");
404 my $dll = ($modules{$module}{type
} eq "dll");
405 my $exe = ($modules{$module}{type
} eq "exe");
407 my $console = $exe; # FIXME: Not always correct
409 my $msvc_wine_dir = do {
410 my @parts = split(m
%/%, $dsp_file);
413 } elsif($#parts == 2) {
419 my $wine_include_dir = "$msvc_wine_dir\\include";
422 $output->progress("$dsp_file (file $progress_current of $progress_max)");
424 my @c_srcs = @
{$modules{$module}{c_srcs
}};
425 my @source_files = @
{$modules{$module}{source_files
}};
426 my @header_files = @
{$modules{$module}{header_files
}};
427 my @resource_files = @
{$modules{$module}{resource_files
}};
429 if ($project !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
430 $project !~ /^(?:gdi32)_.+?$/ &&
431 $project !~ /_test$/)
433 push @source_files, "$project.spec";
434 # push @source_files, "$project.spec.c";
435 @source_files = sort(@source_files);
439 my $no_msvc_headers = 1;
440 if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
441 $no_msvc_headers = 0;
446 push @cfgs, "$project - Win32";
450 foreach my $cfg (@cfgs) {
451 push @_cfgs, "$cfg C";
452 push @_cfgs, "$cfg C++";
459 foreach my $cfg (@cfgs) {
460 push @_cfgs, "$cfg Debug";
461 push @_cfgs, "$cfg Release";
466 if (!$no_msvc_headers) {
468 foreach my $cfg (@cfgs) {
469 push @_cfgs, "$cfg MSVC Headers";
470 push @_cfgs, "$cfg Wine Headers";
475 my $default_cfg = $cfgs[$#cfgs];
477 print OUT
"# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
478 print OUT
"# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
479 print OUT
"# ** DO NOT EDIT **\r\n";
483 print OUT
"# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
485 print OUT
"# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
487 print OUT
"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
491 print OUT
"CFG=$default_cfg\r\n";
492 print OUT
"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
493 print OUT
"!MESSAGE use the Export Makefile command and run\r\n";
494 print OUT
"!MESSAGE \r\n";
495 print OUT
"!MESSAGE NMAKE /f \"$project.mak\".\r\n";
496 print OUT
"!MESSAGE \r\n";
497 print OUT
"!MESSAGE You can specify a configuration when running NMAKE\r\n";
498 print OUT
"!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
499 print OUT
"!MESSAGE \r\n";
500 print OUT
"!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
501 print OUT
"!MESSAGE \r\n";
502 print OUT
"!MESSAGE Possible choices for configuration are:\r\n";
503 print OUT
"!MESSAGE \r\n";
504 foreach my $cfg (@cfgs) {
506 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
508 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
510 print OUT
"!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
513 print OUT
"!MESSAGE \r\n";
516 print OUT
"# Begin Project\r\n";
517 print OUT
"# PROP AllowPerConfigDependencies 0\r\n";
518 print OUT
"# PROP Scc_ProjName \"\"\r\n";
519 print OUT
"# PROP Scc_LocalPath \"\"\r\n";
520 print OUT
"CPP=cl.exe\r\n";
521 print OUT
"MTL=midl.exe\r\n" if !$lib && !$exe;
522 print OUT
"RSC=rc.exe\r\n";
527 foreach my $cfg (@cfgs) {
531 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
535 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
539 my $debug = ($cfg !~ /Release/);
540 my $msvc_headers = ($cfg =~ /MSVC Headers/);
542 print OUT
"# PROP BASE Use_MFC 0\r\n";
545 print OUT
"# PROP BASE Use_Debug_Libraries 1\r\n";
547 print OUT
"# PROP BASE Use_Debug_Libraries 0\r\n";
551 $output_dir =~ s/^$project - //;
552 $output_dir =~ s/ /_/g;
553 $output_dir =~ s/C\+\+/Cxx/g;
554 if($output_prefix_dir) {
555 $output_dir = "$output_prefix_dir\\$output_dir";
558 print OUT
"# PROP BASE Output_Dir \"$output_dir\"\r\n";
559 print OUT
"# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
561 print OUT
"# PROP BASE Target_Dir \"\"\r\n";
563 print OUT
"# PROP Use_MFC 0\r\n";
565 print OUT
"# PROP Use_Debug_Libraries 1\r\n";
567 print OUT
"# PROP Use_Debug_Libraries 0\r\n";
569 print OUT
"# PROP Output_Dir \"$output_dir\"\r\n";
570 print OUT
"# PROP Intermediate_Dir \"$output_dir\"\r\n";
572 print OUT
"# PROP Ignore_Export_Lib 0\r\n" if $dll;
573 print OUT
"# PROP Target_Dir \"\"\r\n";
578 print OUT
"# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od";
579 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _MBCS _LIB));
581 print OUT
"# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
582 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
586 print OUT
"# ADD BASE CPP /nologo /W3 /GX /O2";
587 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _MBCS _LIB));
589 print OUT
"# ADD BASE CPP /nologo /MT /W3 /GX /O2";
590 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
594 foreach my $define (@defines) {
595 print OUT
" /D \"$define\"";
597 print OUT
" /YX" if $lib || $exe;
599 print OUT
" /GZ" if $debug;
600 print OUT
" " if $debug && ($lib || $exe);
607 print OUT
"# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
608 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _LIB);
610 print OUT
"# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
611 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 _DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
615 print OUT
"# ADD CPP /nologo /MT /W3 /GX /O2";
616 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _WINDOWS _MBCS _LIB);
618 print OUT
"# ADD CPP /nologo /MT /W3 /GX /O2";
619 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
625 push @defines2, "_\U${project}\E_";
626 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
628 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
630 my $output_dir2 = $output_dir;
631 $output_dir =~ s/\\/\\\\/g;
632 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\"";
633 push @defines2, qw(__i386__ _X86_);
635 if($project =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
636 push @includes, "..";
639 if ($project =~ /_test$/) {
640 push @includes, "$msvc_wine_dir\\$output_dir";
643 if (!$msvc_headers || $project eq "winetest") {
644 push @includes, $wine_include_dir;
649 foreach my $include (@includes) {
650 if ($include !~ /[\\\"]/) {
651 print OUT
" /I \"$include\"";
653 print OUT
" /I $include";
658 foreach my $define (@defines2) {
659 if ($define !~ /[\\\"]/) {
660 print OUT
" /D \"$define\"";
662 print OUT
" /D $define";
665 print OUT
" /D inline=__inline" if $wine;
666 print OUT
" /D \"__STDC__\"" if 0 && $wine;
668 print OUT
" /YX" if $lib;
669 print OUT
" /FR" if !$lib;
671 print OUT
" /GZ" if $debug;
672 print OUT
" " if $debug && $lib;
674 print OUT
" /TP" if !$no_cpp;
678 print OUT
"# SUBTRACT CPP /X /YX\r\n" if $dll;
679 print OUT
"# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
680 print OUT
"# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
681 print OUT
"# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
682 print OUT
"# ADD RSC /l 0x41d";
684 foreach my $include (@includes) {
685 print OUT
" /i \"$include\"";
688 print OUT
" /d \"_DEBUG\"\r\n";
690 print OUT
"# SUBTRACT CPP /YX\r\n" if $dll;
691 print OUT
"# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
692 print OUT
"# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
693 print OUT
"# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
694 print OUT
"# ADD RSC /l 0x41d";
696 foreach my $include (@includes) {
697 print OUT
" /i \"$include\"";
700 print OUT
"/d \"NDEBUG\"\r\n";
702 print OUT
"BSC32=bscmake.exe\r\n";
703 print OUT
"# ADD BASE BSC32 /nologo\r\n";
704 print OUT
"# ADD BSC32 /nologo\r\n";
707 print OUT
"LINK32=link.exe\r\n";
708 print OUT
"# ADD BASE LINK32 ";
709 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
710 comdlg32.lib advapi32.lib shell32.lib ole32.lib
711 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
712 foreach my $library (@libraries) {
713 print OUT
"$library ";
715 print OUT
" /nologo";
716 print OUT
" /dll" if $dll;
717 print OUT
" /subsystem:console" if $console;
718 print OUT
" /debug" if $debug;
719 print OUT
" /machine:I386";
720 print OUT
" /pdbtype:sept" if $debug;
723 print OUT
"# ADD LINK32";
724 print OUT
" /nologo";
725 print OUT
" libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
726 foreach my $import (@imports) {
727 print OUT
" $import.lib" if ($import ne "msvcrt");
729 print OUT
" /dll" if $dll;
730 print OUT
" /subsystem:console" if $console;
731 print OUT
" /debug" if $debug;
732 print OUT
" /machine:I386";
733 print OUT
" /nodefaultlib" if $project =~ /^ntdll
$/; # FIXME: Kludge
734 print OUT
" /def:\"$project.def\"" if $dll;
735 print OUT
" /pdbtype:sept" if $debug;
738 print OUT
"LIB32=link.exe -lib\r\n";
739 print OUT
"# ADD BASE LIB32 /nologo\r\n";
740 print OUT
"# ADD LIB32 /nologo\r\n";
748 print OUT
"!ENDIF \r\n";
752 if ($project eq "winebuild") {
753 print OUT
"# Begin Special Build Tool\r\n";
754 print OUT
"SOURCE=\"\$(InputPath)\"\r\n";
755 print OUT
"PostBuild_Desc=Copying wine.lib and wine_unicode.lib ...\r\n";
756 print OUT
"PostBuild_Cmds=";
757 print OUT
"copy ..\\..\\libs\\wine\\$output_dir\\wine.lib \$(OutDir)\t";
758 print OUT
"copy ..\\..\\libs\\unicode\\$output_dir\\wine_unicode.lib \$(OutDir)\r\n";
759 print OUT
"# End Special Build Tool\r\n";
761 print OUT
"# Begin Target\r\n";
763 foreach my $cfg (@cfgs) {
764 print OUT
"# Name \"$cfg\"\r\n";
767 print OUT
"# Begin Group \"Source Files\"\r\n";
769 print OUT
"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
771 foreach my $source_file (@source_files) {
772 $source_file =~ s
%/%\\%g;
773 if($source_file !~ /^\./) {
774 $source_file = ".\\$source_file";
777 if($source_file =~ /^(.*?)\.spec$/) {
780 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
781 my $dbg_c_file = "$basename.dbg.c";
783 print OUT
"# Begin Source File\r\n";
785 print OUT
"SOURCE=$dbg_c_file\r\n";
786 print OUT
"# End Source File\r\n";
789 print OUT
"# Begin Source File\r\n";
792 print OUT
"SOURCE=$source_file\r\n";
794 if($source_file =~ /^(.*?)\.spec$/) {
797 my $spec_file = $source_file;
798 my $def_file = "$basename.def";
800 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
801 my $dbg_file = "$basename.dbg";
802 my $dbg_c_file = "$basename.dbg.c";
804 my $srcdir = "."; # FIXME: Is this really always correct?
806 print OUT
"# Begin Custom Build\r\n";
807 print OUT
"InputPath=$spec_file\r\n";
809 print OUT
"BuildCmds= \\\r\n";
810 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe --def $spec_file > $def_file \\\r\n";
812 if($project =~ /^ntdll$/) {
814 foreach my $c_src (@c_srcs) {
816 print OUT
"\techo $c_src >> $dbg_file \\\r\n";
818 print OUT
"\techo $c_src > $dbg_file \\\r\n";
821 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
822 print OUT
" -o $dbg_c_file --debug -C$srcdir $dbg_file \\\r\n";
824 my $c_srcs = join(" ", grep(/\.c$/, @c_srcs));
826 print OUT
"\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
827 print OUT
" -o $dbg_c_file --debug -C$srcdir $c_srcs \\\r\n";
832 print OUT
"\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
833 print OUT
" \$(BuildCmds)\r\n";
835 print OUT
"\"$dbg_c_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
836 print OUT
" \$(BuildCmds)\r\n";
837 print OUT
"# End Custom Build\r\n";
838 } elsif($source_file =~ /([^\\]*?\.h)$/) {
841 foreach my $cfg (@cfgs) {
845 print OUT
"!IF \"\$(CFG)\" == \"$cfg\"\r\n";
849 print OUT
"!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
854 $output_dir =~ s/^$project - //;
855 $output_dir =~ s/ /_/g;
856 $output_dir =~ s/C\+\+/Cxx/g;
857 if($output_prefix_dir) {
858 $output_dir = "$output_prefix_dir\\$output_dir";
861 print OUT
"# Begin Custom Build\r\n";
862 print OUT
"OutDir=$output_dir\r\n";
863 print OUT
"InputPath=$source_file\r\n";
865 print OUT
"\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
866 print OUT
"\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
868 print OUT
"# End Custom Build\r\n";
873 print OUT
"!ENDIF \r\n";
878 print OUT
"# End Source File\r\n";
880 print OUT
"# End Group\r\n";
882 print OUT
"# Begin Group \"Header Files\"\r\n";
884 print OUT
"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
885 foreach my $header_file (@header_files) {
886 print OUT
"# Begin Source File\r\n";
888 print OUT
"SOURCE=.\\$header_file\r\n";
889 print OUT
"# End Source File\r\n";
891 print OUT
"# End Group\r\n";
895 print OUT
"# Begin Group \"Resource Files\"\r\n";
897 print OUT
"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
898 foreach my $resource_file (@resource_files) {
899 print OUT
"# Begin Source File\r\n";
901 print OUT
"SOURCE=.\\$resource_file\r\n";
902 print OUT
"# End Source File\r\n";
904 print OUT
"# End Group\r\n";
906 print OUT
"# End Target\r\n";
907 print OUT
"# End Project\r\n";
912 sub _generate_dsw_header
($) {
915 print OUT
"Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
916 print OUT
"# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
920 sub _generate_dsw_project
($$$$) {
924 my $dsp_file = shift;
925 my @dependencies = @
{(shift)};
927 $dsp_file = "./$dsp_file";
928 $dsp_file =~ y
%/%\\%;
930 @dependencies = sort(@dependencies);
932 print OUT
"###############################################################################\r\n";
934 print OUT
"Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
936 print OUT
"Package=<5>\r\n";
940 print OUT
"Package=<4>\r\n";
942 foreach my $dependency (@dependencies) {
943 print OUT
" Begin Project Dependency\r\n";
944 print OUT
" Project_Dep_Name $dependency\r\n";
945 print OUT
" End Project Dependency\r\n";
951 sub _generate_dsw_footer
($) {
954 print OUT
"###############################################################################\r\n";
956 print OUT
"Global:\r\n";
958 print OUT
"Package=<5>\r\n";
962 print OUT
"Package=<3>\r\n";
966 print OUT
"###############################################################################\r\n";
970 if ($options->wine) {
971 my $dsw_file = "wine.dsw";
972 $output->progress("$dsw_file");
973 replace_file
("$wine_dir/$dsw_file", \
&_generate_wine_dsw
);
976 sub _generate_wine_dsw
($) {
979 _generate_dsw_header
(\
*OUT
);
980 foreach my $module (sort(keys(%modules))) {
981 next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
983 my $project = $modules{$module}{project
};
984 my $dsp_file = $modules{$module}{dsp_file
};
987 if($project =~ /^wine(?:_unicode)?$/) {
989 } elsif($project =~ /^winebuild$/) {
990 @dependencies = ("wine", "wine_unicode");
991 } elsif($project =~ /^(?:gdi32)_.+?$/) {
994 @dependencies = ("wine", "wine_unicode", "winebuild");
997 if($project =~ /^gdi32$/) {
998 foreach my $dir (@gdi32_dirs) {
1000 $dir2 =~ s
%^.*?
/([^/]+)$%$1%;
1002 my $module = "gdi32_$dir2";
1004 push @dependencies, $module;
1008 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1010 _generate_dsw_footer
(\
*OUT
);
1015 if ($options->winetest) {
1016 my $dsw_file = "winetest.dsw";
1017 $output->progress("$dsw_file");
1018 replace_file
("$wine_dir/$dsw_file", \
&_generate_winetest_dsw
);
1021 sub _generate_winetest_dsw
($) {
1024 _generate_dsw_header
(\
*OUT
);
1026 my @runtests_dependencies = ();
1027 foreach my $module (sort(keys(%modules))) {
1028 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1029 next if $module eq "wineruntests";
1031 my $project = $modules{$module}{project
};
1033 push @runtests_dependencies, $project;
1036 foreach my $module (sort(keys(%modules))) {
1037 next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1039 my $project = $modules{$module}{project
};
1040 my $dsp_file = $modules{$module}{dsp_file
};
1043 if($project =~ /^winetest$/) {
1045 } elsif($project =~ /^wineruntests$/) {
1046 @dependencies = @runtests_dependencies;
1048 @dependencies = ("winetest");
1051 _generate_dsw_project
(\
*OUT
, $project, $dsp_file, \
@dependencies);
1054 _generate_dsw_footer
(\
*OUT
);
1057 if ($options->winetest) {
1058 foreach my $module (sort(keys(%modules))) {
1059 next if $module !~ /_test\.exe$/;
1061 my $project = $modules{$module}{project
};
1062 my $dsp_file = $modules{$module}{dsp_file
};
1063 my @tests = @
{$modules{$module}{tests
}};
1065 my $testlist_c = $dsp_file;
1066 $testlist_c =~ s
%[^/]*\
.dsp
$%testlist.c
%;
1068 replace_file
("$wine_dir/$testlist_c", \
&_generate_testlist_c
, \
@tests);
1072 # ***** Keep in sync with tools/make_ctests *****
1073 sub _generate_testlist_c
($$) {
1076 my @tests = @
{(shift)};
1078 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1080 print OUT
"/* stdarg.h is needed for Winelib */\n";
1081 print OUT
"#include <stdarg.h>\n";
1082 print OUT
"#include <stdio.h>\n";
1083 print OUT
"#include <stdlib.h>\n";
1084 print OUT
"#include \"windef.h\"\n";
1085 print OUT
"#include \"winbase.h\"\n";
1087 print OUT
"#define STANDALONE\n";
1088 print OUT
"#include \"wine/test.h\"\n";
1090 foreach my $test (@tests) {
1091 print OUT
"extern void func_$test(void);\n";
1094 print OUT
"const struct test winetest_testlist[] =\n";
1096 foreach my $test (@tests) {
1097 print OUT
" { \"$test\", func_$test },\n";
1099 print OUT
" { 0, 0 }\n";
1103 if ($options->winetest) {
1104 replace_file
("$wine_dir/runtests.c", \
&_generate_runtests_c
);
1107 sub _generate_runtests_c
($) {
1110 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n";
1113 print OUT
"#include <stdio.h>\n";
1114 print OUT
"#include <stdlib.h>\n";
1117 print OUT
"int main(int argc, char *argv[])\n";
1119 print OUT
" char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1120 print OUT
" char command[4096];\n";
1122 foreach my $dsp_file (keys(%runtests)) {
1123 my @tests = @
{$runtests{$dsp_file}};
1125 my $project = $dsp_file;
1126 $project =~ s
%^(.*?
)/?([^/]+)\
.dsp
$%$2%;
1130 foreach my $test (@tests) {
1131 print OUT
" sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1132 print OUT
" system(command);\n";
1136 print OUT
" return 0;\n";
1140 if ($options->winetest) {
1141 replace_file
("$wine_dir/winetest.c", \
&_generate_winetest_c
);
1144 sub _generate_winetest_c
($) {
1147 print OUT
"/* Automatically generated file; DO NOT EDIT!! */\n\n";
1149 print OUT
"/* Force the linker to generate a .lib file */\n";
1150 print OUT
"void __wine_dummy_lib_function()\n{\n}\n\n";
1153 if ($options->wine) {
1154 my $config_h = "include/config.h";
1156 $output->progress("$config_h");
1158 replace_file
("$wine_dir/$config_h", \
&_generate_config_h
);
1161 sub _generate_config_h
($) {
1164 print OUT
"#define __WINE_CONFIG_H\n";
1167 my @headers = qw(direct.h fcntl.h io.h string.h process.h);
1168 foreach my $header (@headers) {
1169 $header =~ y/\.\//__
/;
1170 print OUT
"#define HAVE_\U$header\E\n";
1175 _alldiv _allmul _allrem _aulldiv _aullrem
1176 _access _chdir _close _lseek _mkdir _open _pclose _popen _read _rmdir _write _stat
1177 _snprintf _spawnvp _stricmp _strnicmp _vsnprintf _wcsicmp
1183 foreach my $function (@functions) {
1184 print OUT
"#define HAVE_\U$function\E 1\n";
1189 print OUT
"#define NEED_STDCALL_DECORATION 1\n";
1193 print OUT
"#define X_DISPLAY_MISSING 1\n";
1196 print OUT
"/* Define to a macro to generate an assembly function directive */\n";
1197 print OUT
"#define __ASM_FUNC(name) \"\"\n";
1200 print OUT
"/* Define to a macro to generate an assembly name from a C symbol */\n";
1201 print OUT
"#define __ASM_NAME(name) name\n";
1204 print OUT
"/* Define to the assembler keyword used to specify a word value */\n";
1205 print OUT
"#define __ASM_SHORT \".short\"\n";
1208 print OUT
"/* Define to the assembler keyword used to specify an ASCII string */\n";
1209 print OUT
"#define __ASM_STRING \".string\"\n";
1212 print OUT
"/* Define to the address where bug reports for this package should be sent. */\n";
1213 print OUT
"#define PACKAGE_BUGREPORT \"\"\n";
1216 print OUT
"/* Define to the full name of this package. */\n";
1217 print OUT
"#define PACKAGE_NAME \"Wine\"\n";
1220 print OUT
"/* Define to the full name and version of this package. */\n";
1221 print OUT
"#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1224 print OUT
"/* Define to the one symbol short name of this package. */\n";
1225 print OUT
"#define PACKAGE_TARNAME \"wine\"\n";
1228 print OUT
"/* Define to the version of this package. */\n";
1229 print OUT
"#define PACKAGE_VERSION \"YYYYMMDD\"\n";