Add -B prefix support. Small consistency cleanups.
[wine] / tools / winapi / msvcmaker
1 #! /usr/bin/perl -w
2
3 # Copyright 2002 Patrik Stridvall
4
5 use strict;
6
7 BEGIN {
8     $0 =~ m%^(.*?/?tools)/winapi/msvcmaker$%;
9     require "$1/winapi/setup.pm";
10 }
11
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);
15
16 use msvcmaker_options qw($options);
17
18 if($options->progress) {
19     $output->enable_progress;
20 } else {
21     $output->disable_progress;
22 }
23
24 ########################################################################
25 # main
26
27 my @spec_files = get_spec_files("winelib");
28 my @makefile_in_files = get_makefile_in_files("winelib");
29
30 my $wine = 1;
31
32 my $output_prefix_dir = "Output";
33 my $no_release = 1;
34
35 if ($options->wine || $options->winetest) {
36     foreach my $spec_file (@spec_files) {
37         read_spec_file($spec_file);
38     }
39 }
40
41 my %modules;
42
43 sub read_spec_file {
44     my $spec_file = shift;
45
46     my $module = $spec_file;
47     $module =~ s%^.*?([^/]+)\.spec$%$1%;
48     $module .= ".dll" if $module !~ /\./;
49
50     my $type = "win32";
51
52     open(IN, "< $wine_dir/$spec_file");
53
54     my $header = 1;
55     my $lookahead = 0;
56     while($lookahead || defined($_ = <IN>)) {
57         $lookahead = 0;
58
59         s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begining and end of line
60         s/^(.*?)\s*#.*$/$1/;  # remove comments
61         /^$/ && next;         # skip empty lines
62
63         if($header)  {
64             if(/^\d+|@/) {
65                 $header = 0;
66                 $lookahead = 1;
67             }
68             next;
69         }
70
71         if(/^(\d+|@)\s+pascal(?:16)?/) {
72             $type = "win16";
73             last;
74         }
75     }
76     close(IN);
77
78     # FIXME: Kludge
79     if($module =~ /^(?:comm|imm|ole2conv|ole2prox|ole2thk|rasapi16|windebug)\.dll$/) {
80         $type = "win16";
81     }
82
83     if($type eq "win32") {
84         $modules{$module}{module} = $module;
85         $modules{$module}{type} = $type;
86         $modules{$module}{spec_file} = $spec_file;
87     }
88 }
89
90 my @gdi32_dirs = qw(dlls/gdi/enhmfdrv dlls/gdi/mfdrv graphics objects);
91 my @ntdll_dirs = qw(files misc);
92 my @user32_dirs = qw(controls dlls/user/dde windows);
93
94 push @makefile_in_files, "tools/winebuild/Makefile.in";
95
96 sub filter_files {
97     my $files = shift;
98     my $filter = shift;
99
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;
106         } else {
107             push @$rest_of_files, $file;
108         }
109     }
110     return ($rest_of_files, $filtered_files);
111 }
112
113 my %wine_test_dsp_files;
114
115 MAKEFILE_IN: foreach my $makefile_in_file (@makefile_in_files) {
116     open(IN, "< $wine_dir/$makefile_in_file");
117
118     my $topobjdir;
119     my $module;
120     my $testdll;
121     my @imports;
122
123     my %vars;
124
125     my $again = 0;
126     my $lookahead = 0;
127     while($again || defined(my $line = <IN>)) {
128         if(!$again) {
129             chomp $line;
130             if($lookahead) {
131                 $lookahead = 0;
132                 $_ .= "\n" . $line;
133             } else {
134                 $_ = $line;
135             }
136         } else {
137             $again = 0;
138         }
139
140         s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begining and end of line
141         s/^(.*?)\s*#.*$/$1/;  # remove comments
142         /^$/ && next;         # skip empty lines
143
144         if(s/\\$/ /s) {
145             $lookahead = 1;
146             next;
147         }
148
149         if(/^MODULE\s*=\s*([\w\.]+)$/) {
150             $module = $1;
151
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";
159                 } else {
160                     next MAKEFILE_IN;
161                 }
162             }
163         } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
164             $topobjdir = $1;
165         } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
166             $testdll = $1;
167         } elsif (/^IMPORTS\s*=\s*/) {
168             @imports = split /\s+/s, $';
169             @imports = grep !/^ntdll$/, @imports;
170         } elsif (/^CTESTS\s*=\s*/) {
171             my @files = split /\s+/s, $';
172
173             my $dir = $makefile_in_file;
174             $dir =~ s/\/Makefile\.in$//;
175
176             my $dsp_file = $testdll;
177             $dsp_file =~ s/\.(dll|drv)$/_test.dsp/;
178             $dsp_file = "$dir/$dsp_file";
179
180             $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
181             $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
182         } elsif(/^(\w+)\s*=\s*/) {
183             my $var = $1;
184             my @files = split /\s+/s, $';
185
186             @files = map {
187                 if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
188                     my @list = @{$vars{$1}};
189                     my $prefix = $2;
190                     my $suffix = $3;
191                     foreach my $item (@list) {
192                         $item = "$prefix$item$suffix";
193                     }
194                     @list;
195                 } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
196                     "$topobjdir$1";
197                 } elsif(/^\$/) {
198                     print STDERR "unknown variable '$_'\n" if 0;
199                     ();
200                 } else {
201                     $_;
202                 }
203             } @files;
204
205             $vars{$var} = \@files;
206         }
207     }
208
209     close(IN);
210
211     next if !$module;
212
213     my $c_srcs = [];
214     my $source_files = [];
215     if(exists($vars{C_SRCS})) {
216         $c_srcs = [sort(@{$vars{C_SRCS}})];
217         $source_files = [sort(@{$vars{C_SRCS}})];
218     }
219
220     my $header_files = [];
221     if(exists($vars{H_SRCS})) {
222         $header_files = [sort(@{$vars{H_SRCS}})];
223     }
224
225     my $resource_files = [];
226     if(exists($vars{RC_SRCS})) {
227         $resource_files = [sort(@{$vars{RC_SRCS}})];
228     }
229
230     my $project = $module;
231     $project =~ s/\.(?:dll|exe|lib)$//;
232     $project =~ y/./_/;
233
234     my $type;
235     if($module =~ /\.exe$/) {
236         $type = "exe";
237     } elsif($module =~ /\.lib$/) {
238         $type = "lib";
239     } else {
240         $type = "dll";
241     }
242
243     my $dsp_file = $makefile_in_file;
244     $dsp_file =~ s/Makefile.in$/$project.dsp/;
245
246     if($module eq "gdi32.dll") {
247         foreach my $dir (@gdi32_dirs) {
248             my $dir2 = $dir;
249             $dir2 =~ s%^.*?/([^/]+)$%$1%;
250
251             my $module = "gdi32_$dir2.lib";
252             $module =~ s%/%_%g;
253
254             my $project = "gdi32_$dir2";
255             $project =~ s%/%_%g;
256
257             my $type = "lib";
258             my $dsp_file = "$dir/$project.dsp";
259
260             ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
261             ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
262             ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
263
264             $modules{$module}{wine} = 1;
265             $modules{$module}{winetest} = 0;
266             $modules{$module}{project} = $project;
267             $modules{$module}{type} = $type;
268             $modules{$module}{dsp_file} = $dsp_file;
269             $modules{$module}{c_srcs} = $c_srcs;
270             $modules{$module}{source_files} = $local_source_files;
271             $modules{$module}{header_files} = $local_header_files;
272             $modules{$module}{resource_files} = $local_resource_files;
273             $modules{$module}{imports} = [];
274         }
275     } elsif($module eq "ntdll.dll") {
276         foreach my $dir (@ntdll_dirs) {
277             my $module = "ntdll_$dir.lib";
278             $module =~ s%/%_%g;
279
280             my $project = "ntdll_$dir";
281             $project =~ s%/%_%g;
282
283             my $type = "lib";
284             my $dsp_file = "$dir/$project.dsp";
285
286             ($source_files, my $local_source_files) = filter_files($source_files, "/$dir/");
287             ($header_files, my $local_header_files) = filter_files($header_files, "/$dir/");
288             ($resource_files, my $local_resource_files) = filter_files($resource_files, "/$dir/");
289
290             $modules{$module}{wine} = 1;
291             $modules{$module}{winetest} = 0;
292             $modules{$module}{project} = $project;
293             $modules{$module}{type} = $type;
294             $modules{$module}{dsp_file} = $dsp_file;
295             $modules{$module}{c_srcs} = $c_srcs;
296             $modules{$module}{source_files} = $local_source_files;
297             $modules{$module}{header_files} = $local_header_files;
298             $modules{$module}{resource_files} = $local_resource_files;
299             $modules{$module}{imports} = [];
300         }
301     } elsif($module eq "user32.dll") {
302         foreach my $dir (@user32_dirs) {
303             my $dir2 = $dir;
304             $dir2 =~ s%^.*?/([^/]+)$%$1%;
305
306             my $module = "user32_$dir2.lib";
307             $module =~ s%/%_%g;
308
309             my $project = "user32_$dir2";
310             $project =~ s%/%_%g;
311
312             my $type = "lib";
313             my $dsp_file = "$dir/$project.dsp";
314
315             ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
316             ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
317             ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
318
319             $modules{$module}{wine} = 1;
320             $modules{$module}{winetest} = 0;
321             $modules{$module}{project} = $project;
322             $modules{$module}{type} = $type;
323             $modules{$module}{dsp_file} = $dsp_file;
324             $modules{$module}{c_srcs} = $c_srcs;
325             $modules{$module}{source_files} = $local_source_files;
326             $modules{$module}{header_files} = $local_header_files;
327             $modules{$module}{resource_files} = $local_resource_files;
328             $modules{$module}{imports} = [];
329         }
330     }
331
332     $modules{$module}{wine} = 1;
333     $modules{$module}{winetest} = 0;
334     $modules{$module}{project} = $project;
335     $modules{$module}{type} = $type;
336     $modules{$module}{dsp_file} = $dsp_file;
337     $modules{$module}{c_srcs} = $c_srcs;
338     $modules{$module}{source_files} = $source_files;
339     $modules{$module}{header_files} = $header_files;
340     $modules{$module}{resource_files} = $resource_files;
341     $modules{$module}{imports} = [];
342 }
343
344 $wine_test_dsp_files{"wineruntests.dsp"}{files} = ["runtests.c"];
345 $wine_test_dsp_files{"wineruntests.dsp"}{imports} = [];
346
347 $wine_test_dsp_files{"winetest.dsp"}{files} = [
348   'include/wine/exception.h',
349   'include/wine/test.h',
350   'include/wine/unicode.h',
351   'winetest.c'
352 ];
353 $wine_test_dsp_files{"winetest.dsp"}{imports} = [];
354
355 my %runtests = ();
356
357 foreach my $dsp_file (keys(%wine_test_dsp_files)) {
358     my $project = $dsp_file;
359     $project =~ s%^(?:.*?/)?([^/]+)\.dsp$%$1%;
360
361     my @files = @{$wine_test_dsp_files{$dsp_file}{files}};
362     my @imports = @{$wine_test_dsp_files{$dsp_file}{imports}};
363
364     my $type;
365     my $c_srcs = [];
366     my $source_files = [];
367     my $header_files = [];
368     my $resource_files = [];
369
370     my @tests = ();
371
372     if ($project eq "winetest") {
373         $type = "lib";
374         $c_srcs = [@files];
375         $source_files = [@files];
376         $header_files = [];
377         $resource_files = [];
378     } elsif ($project eq "wineruntests") {
379         $type = "exe";
380         $c_srcs = [@files];
381         $source_files = [@files];
382         $header_files = [];
383         $resource_files = [];
384     } else {
385         $type = "exe";
386         $c_srcs = [@files];
387         $source_files = [@files];
388         $header_files = [];
389         $resource_files = [];
390         
391         @tests = map {
392             if (/^testlist\.c$/) {
393                 ();
394             } else {
395                 s/\.c$//;
396                 $_;
397             }
398         } @files;
399
400         $runtests{$dsp_file} = [@tests];
401     }
402     my $module = "$project.$type";
403
404     $modules{$module}{wine} = 0;
405     $modules{$module}{winetest} = 1;
406
407     $modules{$module}{project} = $project;
408     $modules{$module}{type} = $type;
409     $modules{$module}{dsp_file} = $dsp_file;
410     $modules{$module}{c_srcs} = $c_srcs;
411     $modules{$module}{source_files} = $source_files;
412     $modules{$module}{header_files} = $header_files;
413     $modules{$module}{resource_files} = $resource_files;
414     $modules{$module}{imports} = [@imports];
415
416     $modules{$module}{tests} = [@tests];
417 }
418
419 foreach my $module (sort(keys(%modules))) {
420     if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
421         delete $modules{$module};
422     }
423 }
424
425 my @modules = ();
426 foreach my $module (sort(keys(%modules))) {
427     if (($options->wine && $modules{$module}{wine}) ||
428         ($options->winetest && $modules{$module}{winetest}))
429     {
430         push @modules, $module;
431     }
432 }
433
434 my $progress_output;
435 my $progress_current = 0;
436 my $progress_max = scalar(@modules);
437
438 foreach my $module (@modules) {
439     my $dsp_file = $modules{$module}{dsp_file};
440     replace_file("$wine_dir/$dsp_file", \&_generate_dsp, $module);
441 }
442
443 sub _generate_dsp {
444     local *OUT = shift;
445
446     my $module = shift;
447
448     my $dsp_file = $modules{$module}{dsp_file};
449     my $project = $modules{$module}{project};
450     my @imports = @{$modules{$module}{imports}};
451
452     my $lib = ($modules{$module}{type} eq "lib");
453     my $dll = ($modules{$module}{type} eq "dll");
454     my $exe = ($modules{$module}{type} eq "exe");
455
456     my $console = $exe; # FIXME: Not always correct
457
458     my $msvc_wine_dir = do {
459         my @parts = split(m%/%, $dsp_file);
460         if($#parts == 1) {
461             "..";
462         } elsif($#parts == 2) {
463             "..\\..";
464         } else {
465             "..\\..\\..";
466         }
467     };
468     my $wine_include_dir = "$msvc_wine_dir\\include";
469
470     $progress_current++;
471     $output->progress("$dsp_file (file $progress_current of $progress_max)");
472
473     my @c_srcs = @{$modules{$module}{c_srcs}};
474     my @source_files = @{$modules{$module}{source_files}};
475     my @header_files = @{$modules{$module}{header_files}};
476     my @resource_files = @{$modules{$module}{resource_files}};
477
478     if ($project !~ /^(?:wine(?:_unicode)?|wine(?:build|runtests|test))$/ &&
479         $project !~ /^(?:gdi32|ntdll|user32)_.+?$/ &&
480         $project !~ /_test$/)
481     {
482         push @source_files, "$project.spec";
483         # push @source_files, "$project.spec.c";
484         @source_files = sort(@source_files);
485     }
486
487     my $no_cpp = 1;
488     my $no_msvc_headers = 1;
489     if ($project =~ /^(?:wine(?:runtests|test))$/ || $project =~ /_test$/) {
490         $no_msvc_headers = 0;
491     }
492
493     my @cfgs;
494
495     push @cfgs, "$project - Win32";
496
497     if (!$no_cpp) {
498         my @_cfgs;
499         foreach my $cfg (@cfgs) {
500             push @_cfgs, "$cfg C";
501             push @_cfgs, "$cfg C++";
502         }
503         @cfgs = @_cfgs;
504     }
505
506     if (!$no_release) {
507         my @_cfgs;
508         foreach my $cfg (@cfgs) {
509             push @_cfgs, "$cfg Debug";
510             push @_cfgs, "$cfg Release";
511         }
512         @cfgs = @_cfgs;
513     }
514
515     if (!$no_msvc_headers) {
516         my @_cfgs;
517         foreach my $cfg (@cfgs) {
518             push @_cfgs, "$cfg MSVC Headers";
519             push @_cfgs, "$cfg Wine Headers";
520         }
521         @cfgs = @_cfgs;
522     }
523
524     my $default_cfg = $cfgs[$#cfgs];
525
526     print OUT "# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
527     print OUT "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
528     print OUT "# ** DO NOT EDIT **\r\n";
529     print OUT "\r\n";
530
531     if ($lib) {
532         print OUT "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
533     } elsif ($dll) {
534         print OUT "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
535     } else {
536         print OUT "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
537     }
538     print OUT "\r\n";
539
540     print OUT "CFG=$default_cfg\r\n";
541     print OUT "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
542     print OUT "!MESSAGE use the Export Makefile command and run\r\n";
543     print OUT "!MESSAGE \r\n";
544     print OUT "!MESSAGE NMAKE /f \"$project.mak\".\r\n";
545     print OUT "!MESSAGE \r\n";
546     print OUT "!MESSAGE You can specify a configuration when running NMAKE\r\n";
547     print OUT "!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
548     print OUT "!MESSAGE \r\n";
549     print OUT "!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
550     print OUT "!MESSAGE \r\n";
551     print OUT "!MESSAGE Possible choices for configuration are:\r\n";
552     print OUT "!MESSAGE \r\n";
553     foreach my $cfg (@cfgs) {
554         if ($lib) {
555             print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
556         } elsif ($dll) {
557             print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
558         } else {
559             print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
560         }
561     }
562     print OUT "!MESSAGE \r\n";
563     print OUT "\r\n";
564
565     print OUT "# Begin Project\r\n";
566     print OUT "# PROP AllowPerConfigDependencies 0\r\n";
567     print OUT "# PROP Scc_ProjName \"\"\r\n";
568     print OUT "# PROP Scc_LocalPath \"\"\r\n";
569     print OUT "CPP=cl.exe\r\n";
570     print OUT "MTL=midl.exe\r\n" if !$lib && !$exe;
571     print OUT "RSC=rc.exe\r\n";
572
573     my $n = 0;
574
575     my $output_dir;
576     foreach my $cfg (@cfgs) {
577         if($#cfgs == 0) {
578             # Nothing
579         } elsif($n == 0) {
580             print OUT "!IF  \"\$(CFG)\" == \"$cfg\"\r\n";
581             print OUT "\r\n";
582         } else {
583             print OUT "\r\n";
584             print OUT "!ELSEIF  \"\$(CFG)\" == \"$cfg\"\r\n";
585             print OUT "\r\n";
586         }
587
588         my $debug = ($cfg !~ /Release/);
589         my $msvc_headers = ($cfg =~ /MSVC Headers/);
590
591         print OUT "# PROP BASE Use_MFC 0\r\n";
592
593         if($debug) {
594             print OUT "# PROP BASE Use_Debug_Libraries 1\r\n";
595         } else {
596             print OUT "# PROP BASE Use_Debug_Libraries 0\r\n";
597         }
598
599         $output_dir = $cfg;
600         $output_dir =~ s/^$project - //;
601         $output_dir =~ s/ /_/g;
602         $output_dir =~ s/C\+\+/Cxx/g;
603         if($output_prefix_dir) {
604             $output_dir = "$output_prefix_dir\\$output_dir";
605         }
606
607         print OUT "# PROP BASE Output_Dir \"$output_dir\"\r\n";
608         print OUT "# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
609
610         print OUT "# PROP BASE Target_Dir \"\"\r\n";
611
612         print OUT "# PROP Use_MFC 0\r\n";
613         if($debug) {
614             print OUT "# PROP Use_Debug_Libraries 1\r\n";
615         } else {
616             print OUT "# PROP Use_Debug_Libraries 0\r\n";
617         }
618         print OUT "# PROP Output_Dir \"$output_dir\"\r\n";
619         print OUT "# PROP Intermediate_Dir \"$output_dir\"\r\n";
620
621         print OUT "# PROP Ignore_Export_Lib 0\r\n" if $dll;
622         print OUT "# PROP Target_Dir \"\"\r\n";
623
624         my @defines;
625         if($debug) {
626             if($lib || $exe) {
627                 print OUT "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od";
628                 @defines = (qw(WIN32 _DEBUG _MBCS _LIB));
629             } else {
630                 print OUT "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
631                 @defines = (qw(WIN32 _DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
632             }
633         } else {
634             if($lib || $exe) {
635                 print OUT "# ADD BASE CPP /nologo /W3 /GX /O2";
636                 @defines = (qw(WIN32 NDEBUG _MBCS _LIB));
637             } else {
638                 print OUT "# ADD BASE CPP /nologo /MT /W3 /GX /O2";
639                 @defines = (qw(WIN32 NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
640             }
641         }
642
643         foreach my $define (@defines) {
644             print OUT " /D \"$define\"";
645         }
646         print OUT " /YX" if $lib || $exe;
647         print OUT " /FD";
648         print OUT " /GZ" if $debug;
649         print OUT " " if $debug && ($lib || $exe);
650         print OUT " /c";
651         print OUT "\r\n";
652
653         my @defines2;
654         if($debug) {
655             if($lib) {
656                 print OUT "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
657                 @defines2 = qw(WIN32 _DEBUG _WINDOWS _MBCS _LIB);
658             } else {
659                 print OUT "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od";
660                 @defines2 = qw(_DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
661             }
662         } else {
663             if($lib) {
664                 print OUT "# ADD CPP /nologo /MT /W3 /GX /O2";
665                 @defines2 = qw(WIN32 NDEBUG _WINDOWS _MBCS _LIB);
666             } else {
667                 print OUT "# ADD CPP /nologo /MT /W3 /GX /O2";
668                 @defines2 = qw(NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
669             }
670         }
671
672         my @includes = ();
673         if($wine) {
674             push @defines2, "_\U${project}\E_";
675             push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
676             push @defines2, qw(__WINE_USE_MSVCRT);
677             if ($msvc_headers) {
678                 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
679             }
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_);
684
685             if($project =~ /^gdi32_(?:enhmfdrv|mfdrv|win16drv)$/) {
686                 push @includes, "..";
687             }
688
689             if($project =~ /^user32_(?:controls|windows)$/) {
690                 push @includes, "..\\dlls\\user";
691             }
692
693             if($project =~ /^user32_dde$/) {
694                 push @includes, "..";
695             }
696
697             if ($project =~ /_test$/) {
698                 push @includes, "$msvc_wine_dir\\$output_dir";
699             } 
700
701             if (!$msvc_headers || $project =~ /^winetest$/) {
702                 push @includes, $wine_include_dir;
703             }
704         }
705
706         if($wine) {
707             foreach my $include (@includes) {
708                 if ($include !~ /[\\\"]/) {
709                     print OUT " /I \"$include\"";
710                 } else {
711                     print OUT " /I $include";
712                 }
713             }
714         }
715
716         foreach my $define (@defines2) {
717             if ($define !~ /[\\\"]/) {
718                 print OUT " /D \"$define\"";
719             } else {
720                 print OUT " /D $define";
721             }
722         }
723         print OUT " /D inline=__inline" if $wine;
724         print OUT " /D \"__STDC__\"" if 0 && $wine;
725
726         print OUT " /YX" if $lib;
727         print OUT " /FR" if !$lib;
728         print OUT " /FD";
729         print OUT " /GZ" if $debug;
730         print OUT " " if $debug && $lib;
731         print OUT " /c";
732         print OUT " /TP" if !$no_cpp;
733         print OUT "\r\n";
734
735         if($debug) {
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";
741             if($wine) {
742                 foreach my $include (@includes) {
743                     print OUT " /i \"$include\"";
744                 }
745             }
746             print OUT " /d \"_DEBUG\"\r\n";
747         } else {
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";
753             if($wine) {
754                 foreach my $include (@includes) {
755                     print OUT " /i \"$include\"";
756                 }
757             }
758             print OUT "/d \"NDEBUG\"\r\n";
759         }
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";
763
764         if($exe || $dll) {
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 ";
772             }
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;
779             print OUT "\r\n";
780
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");
786             }
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;
794             print OUT "\r\n";
795         } else {
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";
799         }
800
801         $n++;
802     }
803
804     if($#cfgs != 0) {
805         print OUT "\r\n";
806         print OUT "!ENDIF \r\n";
807         print OUT "\r\n";
808     }
809
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";
818     }
819     print OUT "# Begin Target\r\n";
820     print OUT "\r\n";
821     foreach my $cfg (@cfgs) {
822         print OUT "# Name \"$cfg\"\r\n";
823     }
824
825     print OUT "# Begin Group \"Source Files\"\r\n";
826     print OUT "\r\n";
827     print OUT "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
828
829     foreach my $source_file (@source_files) {
830         $source_file =~ s%/%\\%g;
831         if($source_file !~ /^\./) {
832             $source_file = ".\\$source_file";
833         }
834
835         if($source_file =~ /^(.*?)\.spec$/) {
836             my $basename = $1;
837
838             $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
839             my $dbg_c_file = "$basename.dbg.c";
840
841             print OUT "# Begin Source File\r\n";
842             print OUT "\r\n";
843             print OUT "SOURCE=$dbg_c_file\r\n";
844             print OUT "# End Source File\r\n";
845         }
846
847         print OUT "# Begin Source File\r\n";
848         print OUT "\r\n";
849
850         print OUT "SOURCE=$source_file\r\n";
851
852         if($source_file =~ /^(.*?)\.spec$/) {
853             my $basename = $1;
854
855             my $spec_file = $source_file;
856             my $def_file = "$basename.def";
857
858             $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
859             my $dbg_file = "$basename.dbg";
860             my $dbg_c_file = "$basename.dbg.c";
861
862             my $srcdir = "."; # FIXME: Is this really always correct?
863
864             print OUT "# Begin Custom Build\r\n";
865             print OUT "InputPath=$spec_file\r\n";
866             print OUT "\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";
869             
870             if($project =~ /^ntdll$/) {
871                 my $n = 0;
872                 foreach my $c_src (@c_srcs) {
873                     if($n++ > 0)  {
874                         print OUT "\techo $c_src >> $dbg_file \\\r\n";
875                     } else {
876                         print OUT "\techo $c_src > $dbg_file \\\r\n";
877                     }
878                 }
879                 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
880                 print OUT " -o $dbg_c_file --debug -C$srcdir $dbg_file \\\r\n";
881             } else {
882                 my $c_srcs = join(" ", grep(/\.c$/, @c_srcs));
883
884                 print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe";
885                 print OUT " -o $dbg_c_file --debug -C$srcdir $c_srcs \\\r\n";
886             }
887
888             print OUT "\t\r\n";
889             print OUT "\r\n";
890             print OUT "\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
891             print OUT "   \$(BuildCmds)\r\n";
892             print OUT "\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)$/) {
897             my $h_file = $1;
898
899             foreach my $cfg (@cfgs) {
900                 if($#cfgs == 0) {
901                     # Nothing
902                 } elsif($n == 0) {
903                     print OUT "!IF  \"\$(CFG)\" == \"$cfg\"\r\n";
904                     print OUT "\r\n";
905                 } else {
906                     print OUT "\r\n";
907                     print OUT "!ELSEIF  \"\$(CFG)\" == \"$cfg\"\r\n";
908                     print OUT "\r\n";
909                 }
910
911                 $output_dir = $cfg;
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";
917                 }
918
919                 print OUT "# Begin Custom Build\r\n";
920                 print OUT "OutDir=$output_dir\r\n";
921                 print OUT "InputPath=$source_file\r\n";
922                 print OUT "\r\n";
923                 print OUT "\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
924                 print OUT "\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
925                 print OUT "\r\n";
926                 print OUT "# End Custom Build\r\n";
927             }
928
929             if($#cfgs != 0) {
930                 print OUT "\r\n";
931                 print OUT "!ENDIF \r\n";
932                 print OUT "\r\n";
933             }
934         }
935
936         print OUT "# End Source File\r\n";
937     }
938     print OUT "# End Group\r\n";
939
940     print OUT "# Begin Group \"Header Files\"\r\n";
941     print OUT "\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";
945         print OUT "\r\n";
946         print OUT "SOURCE=.\\$header_file\r\n";
947         print OUT "# End Source File\r\n";
948     }
949     print OUT "# End Group\r\n";
950
951
952
953     print OUT "# Begin Group \"Resource Files\"\r\n";
954     print OUT "\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";
958         print OUT "\r\n";
959         print OUT "SOURCE=.\\$resource_file\r\n";
960         print OUT "# End Source File\r\n";
961     }
962     print OUT "# End Group\r\n";
963
964     print OUT "# End Target\r\n";
965     print OUT "# End Project\r\n";
966
967     close(OUT);
968 }
969
970 sub _generate_dsw_header {
971     local *OUT = shift;
972
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";
975     print OUT "\r\n";
976 }
977
978 sub _generate_dsw_project {
979     local *OUT = shift;
980
981     my $project = shift;
982     my $dsp_file = shift;
983     my @dependencies = @{(shift)};
984
985     $dsp_file = "./$dsp_file";
986     $dsp_file =~ y%/%\\%;
987     
988     @dependencies = sort(@dependencies);
989
990     print OUT "###############################################################################\r\n";
991     print OUT "\r\n";
992     print OUT "Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
993     print OUT "\r\n";
994     print OUT "Package=<5>\r\n";
995     print OUT "{{{\r\n";
996     print OUT "}}}\r\n";
997     print OUT "\r\n";
998     print OUT "Package=<4>\r\n";
999     print OUT "{{{\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";
1004     }
1005     print OUT "}}}\r\n";
1006     print OUT "\r\n";
1007 }
1008
1009 sub _generate_dsw_footer {
1010     local *OUT = shift;
1011
1012     print OUT "###############################################################################\r\n";
1013     print OUT "\r\n";
1014     print OUT "Global:\r\n";
1015     print OUT "\r\n";
1016     print OUT "Package=<5>\r\n";
1017     print OUT "{{{\r\n";
1018     print OUT "}}}\r\n";
1019     print OUT "\r\n";
1020     print OUT "Package=<3>\r\n";
1021     print OUT "{{{\r\n";
1022     print OUT "}}}\r\n";
1023     print OUT "\r\n";
1024     print OUT "###############################################################################\r\n";
1025     print OUT "\r\n";
1026 }
1027
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);
1032 }
1033
1034 sub _generate_wine_dsw {
1035     local *OUT = shift;
1036
1037     _generate_dsw_header(\*OUT);
1038     foreach my $module (sort(keys(%modules))) {
1039         next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1040
1041         my $project = $modules{$module}{project};
1042         my $dsp_file = $modules{$module}{dsp_file};
1043
1044         my @dependencies;
1045         if($project =~ /^wine(?:_unicode)?$/) {
1046             @dependencies = ();
1047         } elsif($project =~ /^winebuild$/) {
1048             @dependencies = ("wine", "wine_unicode");
1049         } elsif($project =~ /^(?:gdi32|ntdll|user32)_.+?$/) {
1050             @dependencies = ();
1051         } else {
1052             @dependencies = ("wine", "wine_unicode", "winebuild");
1053         }
1054
1055         if($project =~ /^gdi32$/) {
1056             foreach my $dir (@gdi32_dirs) {
1057                 my $dir2 = $dir;
1058                 $dir2 =~ s%^.*?/([^/]+)$%$1%;
1059
1060                 my $module = "gdi32_$dir2";
1061                 $module =~ s%/%_%g;
1062                 push @dependencies, $module;
1063             }
1064         } elsif($project =~ /^ntdll$/) {
1065             foreach my $dir (@ntdll_dirs) {
1066                 my $module = "ntdll_$dir";
1067                 $module =~ s%/%_%g;
1068                 push @dependencies, $module;
1069             }
1070         } elsif($project =~ /^user32$/) {
1071             foreach my $dir (@user32_dirs) {
1072                 my $dir2 = $dir;
1073                 $dir2 =~ s%^.*?/([^/]+)$%$1%;
1074
1075                 my $module = "user32_$dir2";
1076                 $module =~ s%/%_%g;
1077                 push @dependencies, $module;
1078             }
1079         }
1080
1081         _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
1082     }
1083     _generate_dsw_footer(\*OUT);
1084
1085     return 1;
1086 }
1087
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);
1092 }
1093
1094 sub _generate_winetest_dsw {
1095     local *OUT = shift;
1096
1097     _generate_dsw_header(\*OUT);
1098
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";
1103
1104         my $project = $modules{$module}{project};
1105
1106         push @runtests_dependencies, $project;
1107     }
1108
1109     foreach my $module (sort(keys(%modules))) {
1110         next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
1111
1112         my $project = $modules{$module}{project};
1113         my $dsp_file = $modules{$module}{dsp_file};
1114
1115         my @dependencies;
1116         if($project =~ /^winetest$/) {
1117             @dependencies = ();
1118         } elsif($project =~ /^wineruntests$/) {
1119             @dependencies = @runtests_dependencies;
1120         } else {
1121             @dependencies = ("winetest");
1122         }
1123
1124         _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
1125     }
1126
1127     _generate_dsw_footer(\*OUT);
1128 }
1129
1130 if ($options->winetest) {
1131     foreach my $module (sort(keys(%modules))) {
1132         next if $module !~ /_test\.exe$/;
1133
1134         my $project = $modules{$module}{project};
1135         my $dsp_file = $modules{$module}{dsp_file};
1136         my @tests = @{$modules{$module}{tests}};
1137
1138         my $testlist_c = $dsp_file;
1139         $testlist_c =~ s%[^/]*\.dsp$%testlist.c%;
1140
1141         replace_file("$wine_dir/$testlist_c", \&_generate_testlist_c, \@tests);
1142     }
1143 }
1144
1145 sub _generate_testlist_c {
1146     local *OUT = shift;
1147
1148     my @tests = @{(shift)};
1149
1150     print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1151     print OUT "\n";
1152     print OUT "#include <stdio.h>\n";
1153     print OUT "#include <stdlib.h>\n";
1154     print OUT "#include \"windef.h\"\n";
1155     print OUT "#include \"winbase.h\"\n";
1156     print OUT "\n";
1157     foreach my $test (@tests) {
1158         print OUT "extern void func_$test(void);\n";
1159     }
1160     print OUT "\n";
1161     print OUT "struct test\n";
1162     print OUT "{\n";
1163     print OUT "    const char *name;\n";
1164     print OUT "    void (*func)(void);\n";
1165     print OUT "};\n";
1166     print OUT "\n";
1167     print OUT "static const struct test winetest_testlist[] =\n";
1168     print OUT "{\n";
1169     foreach my $test (@tests) {
1170         print OUT "    { \"$test\", func_$test },\n";
1171     }
1172     print OUT "    { 0, 0 }\n";
1173     print OUT "};\n";
1174     print OUT "\n";
1175     print OUT "#define WINETEST_WANT_MAIN\n";
1176     print OUT "#include \"wine/test.h\"\n";
1177 }
1178
1179 if ($options->winetest) {
1180     replace_file("$wine_dir/runtests.c", \&_generate_runtests_c);
1181 }
1182
1183 sub _generate_runtests_c {
1184     local *OUT = shift;
1185
1186     print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
1187
1188     print OUT "\n";
1189     print OUT "#include <stdio.h>\n";
1190     print OUT "#include <stdlib.h>\n";
1191     print OUT "\n";
1192
1193     print OUT "int main(int argc, char *argv[])\n";
1194     print OUT "{\n";
1195     print OUT "    char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
1196     print OUT "    char command[4096];\n";
1197     print OUT "\n";
1198     foreach my $dsp_file (keys(%runtests)) {
1199         my @tests =  @{$runtests{$dsp_file}};
1200
1201         my $project = $dsp_file;
1202         $project =~ s%^(.*?)/?([^/]+)\.dsp$%$2%;
1203         my $dir = $1;
1204         $dir =~ s%/%\\\\%g; 
1205
1206         foreach my $test (@tests) {
1207             print OUT "    sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
1208             print OUT "    system(command);\n";
1209             print OUT "\n";
1210         }
1211     }
1212     print OUT "    return 0;\n";
1213     print OUT "}\n";
1214 }
1215
1216 if ($options->winetest) {
1217     replace_file("$wine_dir/winetest.c", \&_generate_winetest_c);
1218 }
1219
1220 sub _generate_winetest_c {
1221     local *OUT = shift;
1222
1223     print OUT "/* Automatically generated file; DO NOT EDIT!! */\n\n";
1224
1225     print OUT "/* Force the linker to generate a .lib file */\n";
1226     print OUT "void __wine_dummy_lib_function()\n{\n}\n\n";
1227 }
1228
1229 if ($options->wine) {
1230     my $config_h = "include/config.h";
1231
1232     $output->progress("$config_h");
1233
1234     replace_file("$wine_dir/$config_h", \&_generate_config_h);
1235 }
1236
1237 sub _generate_config_h {
1238     local *OUT = shift;
1239
1240     print OUT "#define __WINE_CONFIG_H\n";
1241     print OUT "\n";
1242
1243     my @headers = qw(direct.h fcntl.h io.h string.h process.h);
1244     foreach my $header (@headers) {
1245         $header =~ y/\.\//__/;
1246         print OUT "#define HAVE_\U$header\E\n";
1247         print OUT "\n";
1248     }
1249
1250     my @functions = qw(
1251         _alldiv _allmul _allrem _aulldiv _aullrem
1252         _access _chdir _close _lseek _mkdir _open _pclose _popen _read _rmdir _write _stat
1253         _snprintf _spawnvp _stricmp _strnicmp _vsnprintf _wcsicmp
1254         ecvt fcvt gcvt
1255         memmove
1256         strerror
1257         wcslen
1258     );
1259     foreach my $function (@functions) {
1260         print OUT "#define HAVE_\U$function\E 1\n";
1261         print OUT "\n";
1262     }
1263
1264     if(0) {
1265         print OUT "#define NEED_STDCALL_DECORATION 1\n";
1266         print OUT "\n";
1267     }
1268
1269     print OUT "#define X_DISPLAY_MISSING 1\n";
1270     print OUT "\n";
1271
1272     print OUT "/* Define to a macro to generate an assembly function directive */\n";
1273     print OUT "#define __ASM_FUNC(name) \"\"\n";
1274     print OUT "\n";
1275
1276     print OUT "/* Define to a macro to generate an assembly name from a C symbol */\n";
1277     print OUT "#define __ASM_NAME(name) name\n";
1278     print OUT "\n";
1279
1280     print OUT "/* Define to the assembler keyword used to specify a word value */";
1281     print OUT "define __ASM_SHORT \".short\"";
1282     print OUT "\n";
1283
1284     print OUT "/* Define to the assembler keyword used to specify an ASCII string */";
1285     print OUT "#define __ASM_STRING \".string\"";
1286     print OUT "\n";
1287
1288     print OUT "/* Define to the address where bug reports for this package should be sent. */\n";
1289     print OUT "#define PACKAGE_BUGREPORT \"\"\n";
1290     print OUT "\n";
1291
1292     print OUT "/* Define to the full name of this package. */\n";
1293     print OUT "#define PACKAGE_NAME \"Wine\"\n";
1294     print OUT "\n";
1295
1296     print OUT "/* Define to the full name and version of this package. */\n";
1297     print OUT "#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
1298     print OUT "\n";
1299
1300     print OUT "/* Define to the one symbol short name of this package. */\n";
1301     print OUT "#define PACKAGE_TARNAME \"wine\"\n";
1302     print OUT "\n";
1303
1304     print OUT "/* Define to the version of this package. */\n";
1305     print OUT "#define PACKAGE_VERSION \"YYYYMMDD\"\n";
1306     print OUT "\n";
1307
1308     close(OUT);
1309 }