msvcmaker 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. #!/usr/bin/perl
  2. # Copyright 2002 Patrik Stridvall
  3. use strict;
  4. use warnings 'all';
  5. BEGIN {
  6. $0 =~ m%^(.*?/?tools)/winapi/msvcmaker$%;
  7. require "$1/winapi/setup.pm";
  8. }
  9. use setup qw($current_dir $wine_dir);
  10. use lib $setup::winapi_dir;
  11. use config qw(get_spec_files get_makefile_in_files);
  12. use output qw($output);
  13. use util qw(replace_file);
  14. use msvcmaker_options qw($options);
  15. if($options->progress) {
  16. $output->enable_progress;
  17. } else {
  18. $output->disable_progress;
  19. }
  20. ########################################################################
  21. # main
  22. my @spec_files = get_spec_files("winelib");
  23. my @makefile_in_files = get_makefile_in_files("winelib");
  24. my $wine = 1;
  25. my $output_prefix_dir = "Output";
  26. my $no_release = 1;
  27. my %modules;
  28. # These DLLs don't have a hope of compiling properly
  29. my @unix_dependent_dlls = qw(iphlpapi mountmgr.sys ntdll mswsock opengl32
  30. secur32 winex11 wnaspi32 ws2_32);
  31. sub is_unix_dependent_dll($) {
  32. my $dll = shift;
  33. foreach my $unix_only_dll (@unix_dependent_dlls) {
  34. if($dll eq $unix_only_dll) {
  35. return 1;
  36. }
  37. }
  38. return 0;
  39. }
  40. sub read_spec_file($) {
  41. my $spec_file = shift;
  42. my $module = $spec_file;
  43. $module =~ s%^.*?([^/]+)\.spec$%$1%;
  44. $module .= ".dll" if $module !~ /\./;
  45. my $type = "win32";
  46. open(IN, "< $wine_dir/$spec_file") || die "Error: Can't open $wine_dir/$spec_file: $!\n";
  47. my $header = 1;
  48. my $lookahead = 0;
  49. while($lookahead || defined($_ = <IN>)) {
  50. $lookahead = 0;
  51. s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
  52. s/^(.*?)\s*#.*$/$1/; # remove comments
  53. /^$/ && next; # skip empty lines
  54. if($header) {
  55. if(/^(?:\d+|@)/) {
  56. $header = 0;
  57. $lookahead = 1;
  58. }
  59. next;
  60. }
  61. if(/^(\d+|@)\s+pascal(?:16)?/) {
  62. $type = "win16";
  63. last;
  64. }
  65. }
  66. close(IN);
  67. # FIXME: Kludge
  68. if($module =~ /^(?:(?:imm|ole2conv|ole2prox|ole2thk|rasapi16|msacm|windebug)\.dll|comm\.drv)$/) {
  69. $type = "win16";
  70. }
  71. if($type eq "win32") {
  72. $modules{$module}{module} = $module;
  73. $modules{$module}{type} = $type;
  74. $modules{$module}{spec_file} = $spec_file;
  75. }
  76. }
  77. if ($options->wine || $options->winetest) {
  78. foreach my $spec_file (@spec_files) {
  79. my $dll = $spec_file;
  80. $dll =~ s%dlls/([^/]+)/[^/]+\.spec%$1%;
  81. if(!is_unix_dependent_dll($dll)) {
  82. read_spec_file($spec_file);
  83. }
  84. }
  85. }
  86. my @gdi32_dirs = qw(dlls/gdi32/enhmfdrv dlls/gdi32/mfdrv);
  87. push @makefile_in_files, "libs/wine/Makefile.in";
  88. push @makefile_in_files, "tools/winebuild/Makefile.in";
  89. sub filter_files($$) {
  90. my $files = shift;
  91. my $filter = shift;
  92. my $filtered_files = [];
  93. my $rest_of_files = [];
  94. foreach my $file (@$files) {
  95. if($file =~ /$filter/) {
  96. $file =~ s%.*?([^/]+)$%./$1%; # FIXME: Kludge
  97. push @$filtered_files, $file;
  98. } else {
  99. push @$rest_of_files, $file;
  100. }
  101. }
  102. return ($rest_of_files, $filtered_files);
  103. }
  104. my %wine_test_dsp_files;
  105. MAKEFILE_IN: foreach my $makefile_in_file (@makefile_in_files) {
  106. open(IN, "< $wine_dir/$makefile_in_file") || die "Error: Can't open $wine_dir/$makefile_in_file: $!\n";
  107. my $topobjdir;
  108. my $module;
  109. my $testdll;
  110. my @imports;
  111. my $type;
  112. my $dll;
  113. my %vars;
  114. my $again = 0;
  115. my $lookahead = 0;
  116. $dll = $makefile_in_file;
  117. $dll =~ s%dlls/([^/]+)/Makefile\.in%$1%;
  118. if($makefile_in_file eq "loader/Makefile.in" ||
  119. is_unix_dependent_dll($dll)) {
  120. next;
  121. }
  122. while($again || defined(my $line = <IN>)) {
  123. if(!$again) {
  124. chomp $line;
  125. if($lookahead) {
  126. $lookahead = 0;
  127. $_ .= " " . $line;
  128. } else {
  129. $_ = $line;
  130. }
  131. } else {
  132. $again = 0;
  133. }
  134. s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
  135. s/^(.*?)\s*#.*$/$1/; # remove comments
  136. /^$/ && next; # skip empty lines
  137. if(s/\\$/ /s) {
  138. $lookahead = 1;
  139. next;
  140. }
  141. if(/^MODULE\s*=\s*([\w\.-]+)$/) {
  142. $module = $1;
  143. } elsif (/^\@MAKE_IMPLIB_RULES\@/) {
  144. $type = "lib";
  145. } elsif(/^TOPOBJDIR\s*=\s*(\S+)\s*$/) {
  146. $topobjdir = $1;
  147. } elsif (/^TESTDLL\s*=\s*(\S+)\s*$/) {
  148. $testdll = $1;
  149. } elsif (/^IMPORTS\s*=\s*/) {
  150. push @imports, grep !/^ntdll$/, split /\s+/s, $';
  151. } elsif (/^DELAYIMPORTS\s*=\s*/) {
  152. push @imports, $;
  153. } elsif (/^EXTRALIBS\s*=\s*/) {
  154. push @imports, map { /^-l(dxerr8|dxerr9|dxguid|strmiids|uuid)$/ ? $1 : () } split /\s+/s, $';
  155. } elsif (/^CTESTS\s*=\s*/ || ( ($makefile_in_file =~ /\/tests\/Makefile\.in$/) && /^C_SRCS\s*=\s*/ ) ) {
  156. my @files = split /\s+/s, $';
  157. my $dir = $makefile_in_file;
  158. $dir =~ s/\/Makefile\.in$//;
  159. my $dsp_file = $testdll;
  160. $dsp_file =~ s/\.(dll|drv|ocx)$/_test.dsp/;
  161. $dsp_file = "$dir/$dsp_file";
  162. $wine_test_dsp_files{$dsp_file}{files} = [@files, "testlist.c"];
  163. $wine_test_dsp_files{$dsp_file}{imports} = [@imports];
  164. } elsif(/^(\w+)\s*=\s*/) {
  165. my $var = $1;
  166. my @files = split /\s+/s, $';
  167. @files = map {
  168. if(/^\$\((\w+):\%=(.*?)\%(.*?)\)$/) {
  169. my @list = @{$vars{$1}};
  170. my $prefix = $2;
  171. my $suffix = $3;
  172. foreach my $item (@list) {
  173. $item = "$prefix$item$suffix";
  174. }
  175. @list;
  176. } elsif(/^\$\(TOPOBJDIR\)(.*?)$/) {
  177. "$topobjdir$1";
  178. } elsif(/^\$/) {
  179. print STDERR "unknown variable '$_'\n" if 0;
  180. ();
  181. } else {
  182. $_;
  183. }
  184. } @files;
  185. $vars{$var} = \@files;
  186. }
  187. }
  188. close(IN);
  189. if (!$module) {
  190. if ($makefile_in_file eq "libs/wine/Makefile.in") {
  191. $module = "wine.lib";
  192. } elsif ($makefile_in_file eq "tools/winebuild/Makefile.in") {
  193. $module = "winebuild.exe";
  194. }
  195. }
  196. next if !$module;
  197. my $c_srcs = [];
  198. my $source_files = [];
  199. if(exists($vars{C_SRCS})) {
  200. $c_srcs = [sort(@{$vars{C_SRCS}})];
  201. $source_files = [sort(@{$vars{C_SRCS}})];
  202. }
  203. my $header_files = [];
  204. if(exists($vars{H_SRCS})) {
  205. $header_files = [sort(@{$vars{H_SRCS}})];
  206. }
  207. my $resource_files = [];
  208. if(exists($vars{RC_SRCS})) {
  209. $resource_files = [sort(@{$vars{RC_SRCS}})];
  210. }
  211. my $idl_h_files = [];
  212. if(exists($vars{IDL_H_SRCS})) {
  213. $idl_h_files = [sort(@{$vars{IDL_H_SRCS}})];
  214. }
  215. my $idl_c_files = [];
  216. if(exists($vars{IDL_C_SRCS})) {
  217. $idl_c_files = [sort(@{$vars{IDL_C_SRCS}})];
  218. }
  219. my $idl_s_files = [];
  220. if(exists($vars{IDL_S_SRCS})) {
  221. $idl_s_files = [sort(@{$vars{IDL_S_SRCS}})];
  222. }
  223. my $idl_p_files = [];
  224. if(exists($vars{IDL_P_SRCS})) {
  225. $idl_p_files = [sort(@{$vars{IDL_P_SRCS}})];
  226. }
  227. my $idl_tlb_files = [];
  228. if(exists($vars{IDL_TLB_SRCS})) {
  229. $idl_tlb_files = [sort(@{$vars{IDL_TLB_SRCS}})];
  230. }
  231. my $extradefs;
  232. if(exists($vars{EXTRADEFS})) {
  233. $extradefs = $vars{EXTRADEFS};
  234. }
  235. my $project = $module;
  236. $project =~ s/\.(?:dll|exe|lib)$//;
  237. $project =~ y/./_/;
  238. if($module =~ /\.exe$/) {
  239. $type = "exe";
  240. } elsif($module =~ /\.lib$/) {
  241. $type = "lib";
  242. } elsif(!$type) {
  243. $type = "dll";
  244. }
  245. my $dsp_file = $makefile_in_file;
  246. $dsp_file =~ s/Makefile.in$/$project.dsp/;
  247. if($module eq "gdi32.dll") {
  248. foreach my $dir (@gdi32_dirs) {
  249. my $dir2 = $dir;
  250. $dir2 =~ s%^.*?/([^/]+)$%$1%;
  251. my $module = "gdi32_$dir2.lib";
  252. $module =~ s%/%_%g;
  253. my $project = "gdi32_$dir2";
  254. $project =~ s%/%_%g;
  255. my $type = "lib";
  256. my $dsp_file = "$dir/$project.dsp";
  257. ($source_files, my $local_source_files) = filter_files($source_files, "$dir2/");
  258. ($header_files, my $local_header_files) = filter_files($header_files, "$dir2/");
  259. ($resource_files, my $local_resource_files) = filter_files($resource_files, "$dir2/");
  260. ($idl_h_files, my $local_idl_h_files) = filter_files($idl_h_files, "$dir2/");
  261. $modules{$module}{wine} = 1;
  262. $modules{$module}{winetest} = 0;
  263. $modules{$module}{project} = $project;
  264. $modules{$module}{type} = $type;
  265. $modules{$module}{dsp_file} = $dsp_file;
  266. $modules{$module}{c_srcs} = $c_srcs;
  267. $modules{$module}{source_files} = $local_source_files;
  268. $modules{$module}{header_files} = $local_header_files;
  269. $modules{$module}{resource_files} = $local_resource_files;
  270. $modules{$module}{imports} = [];
  271. $modules{$module}{idl_h_files} = $local_idl_h_files;
  272. $modules{$module}{idl_c_files} = [];
  273. $modules{$module}{idl_s_files} = [];
  274. $modules{$module}{idl_p_files} = [];
  275. $modules{$module}{idl_tlb_files} = [];
  276. $modules{$module}{extradefs} = $extradefs if $extradefs;
  277. }
  278. }
  279. $modules{$module}{wine} = 1;
  280. $modules{$module}{winetest} = 0;
  281. $modules{$module}{project} = $project;
  282. $modules{$module}{type} = $type;
  283. $modules{$module}{dsp_file} = $dsp_file;
  284. $modules{$module}{c_srcs} = $c_srcs;
  285. $modules{$module}{source_files} = $source_files;
  286. $modules{$module}{header_files} = $header_files;
  287. $modules{$module}{resource_files} = $resource_files;
  288. $modules{$module}{imports} = [@imports];
  289. $modules{$module}{idl_h_files} = $idl_h_files;
  290. $modules{$module}{idl_c_files} = $idl_c_files;
  291. $modules{$module}{idl_s_files} = $idl_s_files;
  292. $modules{$module}{idl_p_files} = $idl_p_files;
  293. $modules{$module}{idl_tlb_files} = $idl_tlb_files;
  294. $modules{$module}{extradefs} = $extradefs if $extradefs;
  295. }
  296. $wine_test_dsp_files{"wineruntests.dsp"}{files} = ["runtests.c"];
  297. $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',
  302. 'winetest.c'
  303. ];
  304. $wine_test_dsp_files{"winetest.dsp"}{imports} = [];
  305. my %runtests = ();
  306. foreach my $dsp_file (keys(%wine_test_dsp_files)) {
  307. my $project = $dsp_file;
  308. $project =~ s%^(?:.*?/)?([^/]+)\.dsp$%$1%;
  309. my @files = @{$wine_test_dsp_files{$dsp_file}{files}};
  310. my @imports = @{$wine_test_dsp_files{$dsp_file}{imports}};
  311. my $type;
  312. my $c_srcs = [];
  313. my $source_files = [];
  314. my $header_files = [];
  315. my $resource_files = [];
  316. my $idl_h_files = [];
  317. my @tests = ();
  318. if ($project eq "winetest") {
  319. $type = "lib";
  320. $c_srcs = [@files];
  321. $source_files = [@files];
  322. $header_files = [];
  323. $resource_files = [];
  324. } elsif ($project eq "wineruntests") {
  325. $type = "exe";
  326. $c_srcs = [@files];
  327. $source_files = [@files];
  328. $header_files = [];
  329. $resource_files = [];
  330. } else {
  331. $type = "exe";
  332. $c_srcs = [@files];
  333. $source_files = [@files];
  334. $header_files = [];
  335. $resource_files = [];
  336. @tests = map {
  337. if (/^testlist\.c$/) {
  338. ();
  339. } else {
  340. s/\.c$//;
  341. $_;
  342. }
  343. } @files;
  344. $runtests{$dsp_file} = [@tests];
  345. }
  346. my $module = "$project.$type";
  347. $modules{$module}{wine} = 0;
  348. $modules{$module}{winetest} = 1;
  349. $modules{$module}{project} = $project;
  350. $modules{$module}{type} = $type;
  351. $modules{$module}{dsp_file} = $dsp_file;
  352. $modules{$module}{c_srcs} = $c_srcs;
  353. $modules{$module}{source_files} = $source_files;
  354. $modules{$module}{header_files} = $header_files;
  355. $modules{$module}{resource_files} = $resource_files;
  356. $modules{$module}{imports} = [@imports];
  357. $modules{$module}{idl_h_files} = [];
  358. $modules{$module}{idl_c_files} = [];
  359. $modules{$module}{idl_s_files} = [];
  360. $modules{$module}{idl_p_files} = [];
  361. $modules{$module}{idl_tlb_files} = [];
  362. $modules{$module}{tests} = [@tests];
  363. }
  364. foreach my $module (sort(keys(%modules))) {
  365. if($module =~ /^(?:ttydrv.dll|x11drv.dll)$/) {
  366. delete $modules{$module};
  367. }
  368. }
  369. my @modules = ();
  370. foreach my $module (sort(keys(%modules))) {
  371. if (($options->wine && $modules{$module}{wine}) ||
  372. ($options->winetest && $modules{$module}{winetest}))
  373. {
  374. push @modules, $module;
  375. }
  376. }
  377. my $progress_output;
  378. my $progress_current = 0;
  379. my $progress_max = scalar(@modules);
  380. foreach my $module (@modules) {
  381. my $dsp_file = $modules{$module}{dsp_file};
  382. replace_file("$wine_dir/$dsp_file", \&_generate_dsp, $module);
  383. }
  384. sub output_dsp_idl_rules($$$) {
  385. my $wine_include_dir = shift;
  386. my $ext = shift;
  387. my @idl_src_files = @{(shift)};
  388. foreach my $idl_src_file (@idl_src_files) {
  389. $idl_src_file =~ s%/%\\%g;
  390. if($idl_src_file !~ /^\./) {
  391. $idl_src_file = ".\\$idl_src_file";
  392. }
  393. print OUT "# Begin Source File\r\n";
  394. print OUT "\r\n";
  395. print OUT "SOURCE=$idl_src_file\r\n";
  396. my $basename = $idl_src_file;
  397. $basename =~ s/\.idl$//;
  398. print OUT "# PROP Ignore_Default_Tool 1\r\n";
  399. print OUT "# Begin Custom Build\r\n";
  400. print OUT "InputPath=$idl_src_file\r\n";
  401. print OUT "\r\n";
  402. print OUT "BuildCmds= \\\r\n";
  403. print OUT "\tmidl /nologo /I $wine_include_dir $idl_src_file ";
  404. if ($ext eq ".h") {
  405. print OUT "/client none /server none /notlb /h ";
  406. } elsif ($ext eq "_c.c") {
  407. print OUT "/server none /notlb /cstub ";
  408. } elsif ($ext eq "_s.c") {
  409. print OUT "/client none /notlb /sstub ";
  410. } elsif ($ext eq "_p.c") {
  411. print OUT "/client none /server none /notlb /proxy ";
  412. } elsif ($ext eq ".tlb") {
  413. print OUT "/client none /server none /tlb ";
  414. }
  415. print OUT "$basename$ext\r\n";
  416. print OUT "\r\n";
  417. print OUT "\"$basename$ext\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
  418. print OUT " \$(BuildCmds)\r\n";
  419. print OUT "# End Custom Build\r\n";
  420. print OUT "# End Source File\r\n";
  421. }
  422. }
  423. sub _generate_dsp($$) {
  424. local *OUT = shift;
  425. my $module = shift;
  426. my $dsp_file = $modules{$module}{dsp_file};
  427. my $project = $modules{$module}{project};
  428. my @imports = @{$modules{$module}{imports}};
  429. my $lib = ($modules{$module}{type} eq "lib");
  430. my $dll = ($modules{$module}{type} eq "dll");
  431. my $exe = ($modules{$module}{type} eq "exe");
  432. my $console = $exe; # FIXME: Not always correct
  433. my $msvc_wine_dir = do {
  434. my @parts = split(m%/%, $dsp_file);
  435. if($#parts == 1) {
  436. "..";
  437. } elsif($#parts == 2) {
  438. "..\\..";
  439. } else {
  440. "..\\..\\..";
  441. }
  442. };
  443. my $wine_include_dir = "$msvc_wine_dir\\include";
  444. $progress_current++;
  445. $output->progress("$dsp_file (file $progress_current of $progress_max)");
  446. my $base_module = $module;
  447. $base_module =~ s/\.(?:dll)$//;
  448. my @c_srcs = @{$modules{$module}{c_srcs}};
  449. my @source_files = @{$modules{$module}{source_files}};
  450. my @header_files = @{$modules{$module}{header_files}};
  451. my @resource_files = @{$modules{$module}{resource_files}};
  452. my @idl_h_files = @{$modules{$module}{idl_h_files}};
  453. my @idl_c_files = @{$modules{$module}{idl_c_files}};
  454. my @idl_s_files = @{$modules{$module}{idl_s_files}};
  455. my @idl_p_files = @{$modules{$module}{idl_p_files}};
  456. my @idl_tlb_files = @{$modules{$module}{idl_tlb_files}};
  457. if ($project !~ /^wine(?:build|runtests|test)?$/ &&
  458. $project !~ /^(?:gdi32)_.+?$/ &&
  459. $project !~ /_test$/ &&
  460. !$lib)
  461. {
  462. push @source_files, "$base_module.spec";
  463. @source_files = sort(@source_files);
  464. }
  465. my $no_cpp = 1;
  466. my $no_msvc_headers = 1;
  467. if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
  468. $no_msvc_headers = 0;
  469. }
  470. my @cfgs;
  471. push @cfgs, "$project - Win32";
  472. if (!$no_cpp) {
  473. my @_cfgs;
  474. foreach my $cfg (@cfgs) {
  475. push @_cfgs, "$cfg C";
  476. push @_cfgs, "$cfg C++";
  477. }
  478. @cfgs = @_cfgs;
  479. }
  480. if (!$no_release) {
  481. my @_cfgs;
  482. foreach my $cfg (@cfgs) {
  483. push @_cfgs, "$cfg Debug";
  484. push @_cfgs, "$cfg Release";
  485. }
  486. @cfgs = @_cfgs;
  487. } else {
  488. my @_cfgs;
  489. foreach my $cfg (@cfgs) {
  490. push @_cfgs, "$cfg Debug";
  491. }
  492. @cfgs = @_cfgs;
  493. }
  494. if (!$no_msvc_headers) {
  495. my @_cfgs;
  496. foreach my $cfg (@cfgs) {
  497. push @_cfgs, "$cfg MSVC Headers";
  498. push @_cfgs, "$cfg Wine Headers";
  499. }
  500. @cfgs = @_cfgs;
  501. }
  502. my $default_cfg = $cfgs[$#cfgs];
  503. print OUT "# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\r\n";
  504. print OUT "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n";
  505. print OUT "# ** DO NOT EDIT **\r\n";
  506. print OUT "\r\n";
  507. if ($lib) {
  508. print OUT "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n";
  509. } elsif ($dll) {
  510. print OUT "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n";
  511. } else {
  512. print OUT "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n";
  513. }
  514. print OUT "\r\n";
  515. print OUT "CFG=$default_cfg\r\n";
  516. print OUT "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n";
  517. print OUT "!MESSAGE use the Export Makefile command and run\r\n";
  518. print OUT "!MESSAGE \r\n";
  519. print OUT "!MESSAGE NMAKE /f \"$project.mak\".\r\n";
  520. print OUT "!MESSAGE \r\n";
  521. print OUT "!MESSAGE You can specify a configuration when running NMAKE\r\n";
  522. print OUT "!MESSAGE by defining the macro CFG on the command line. For example:\r\n";
  523. print OUT "!MESSAGE \r\n";
  524. print OUT "!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\r\n";
  525. print OUT "!MESSAGE \r\n";
  526. print OUT "!MESSAGE Possible choices for configuration are:\r\n";
  527. print OUT "!MESSAGE \r\n";
  528. foreach my $cfg (@cfgs) {
  529. if ($lib) {
  530. print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\r\n";
  531. } elsif ($dll) {
  532. print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n";
  533. } else {
  534. print OUT "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\r\n";
  535. }
  536. }
  537. print OUT "!MESSAGE \r\n";
  538. print OUT "\r\n";
  539. print OUT "# Begin Project\r\n";
  540. print OUT "# PROP AllowPerConfigDependencies 0\r\n";
  541. print OUT "# PROP Scc_ProjName \"\"\r\n";
  542. print OUT "# PROP Scc_LocalPath \"\"\r\n";
  543. print OUT "CPP=cl.exe\r\n";
  544. print OUT "MTL=midl.exe\r\n" if !$lib && !$exe;
  545. print OUT "RSC=rc.exe\r\n";
  546. print OUT "\r\n";
  547. my $n = 0;
  548. my $output_dir;
  549. foreach my $cfg (@cfgs) {
  550. if($#cfgs == 0) {
  551. # Nothing
  552. } elsif($n == 0) {
  553. print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
  554. print OUT "\r\n";
  555. } else {
  556. print OUT "\r\n";
  557. print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
  558. print OUT "\r\n";
  559. }
  560. my $debug = ($cfg !~ /Release/);
  561. my $msvc_headers = ($cfg =~ /MSVC Headers/);
  562. print OUT "# PROP BASE Use_MFC 0\r\n";
  563. if($debug) {
  564. print OUT "# PROP BASE Use_Debug_Libraries 1\r\n";
  565. } else {
  566. print OUT "# PROP BASE Use_Debug_Libraries 0\r\n";
  567. }
  568. $output_dir = $cfg;
  569. $output_dir =~ s/^$project - //;
  570. $output_dir =~ s/ /_/g;
  571. $output_dir =~ s/C\+\+/Cxx/g;
  572. if($output_prefix_dir) {
  573. $output_dir = "$output_prefix_dir\\$output_dir";
  574. }
  575. print OUT "# PROP BASE Output_Dir \"$output_dir\"\r\n";
  576. print OUT "# PROP BASE Intermediate_Dir \"$output_dir\"\r\n";
  577. print OUT "# PROP BASE Target_Dir \"\"\r\n";
  578. print OUT "# PROP Use_MFC 0\r\n";
  579. if($debug) {
  580. print OUT "# PROP Use_Debug_Libraries 1\r\n";
  581. } else {
  582. print OUT "# PROP Use_Debug_Libraries 0\r\n";
  583. }
  584. print OUT "# PROP Output_Dir \"$output_dir\"\r\n";
  585. print OUT "# PROP Intermediate_Dir \"$output_dir\"\r\n";
  586. print OUT "# PROP Ignore_Export_Lib 0\r\n" if $dll;
  587. print OUT "# PROP Target_Dir \"\"\r\n";
  588. print OUT "# ADD BASE CPP /nologo ";
  589. my @defines = qw(WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700 WIN32);
  590. if($debug) {
  591. if($lib || $exe) {
  592. push @defines, qw(_DEBUG _MBCS _LIB);
  593. } else {
  594. print OUT "/MDd ";
  595. push @defines, qw(_DEBUG _WINDOWS _MBCS _USRDLL);
  596. }
  597. print OUT "/W3 /Gm /GX /Zi /Od";
  598. } else {
  599. if($lib || $exe) {
  600. push @defines, qw(NDEBUG _MBCS _LIB);
  601. } else {
  602. print OUT "/MD ";
  603. push @defines, qw(NDEBUG _WINDOWS _MBCS _USRDLL);
  604. }
  605. print OUT "/W3 /GX /O2";
  606. }
  607. foreach my $define (@defines) {
  608. if ($define !~ /=/) {
  609. print OUT " /D \"$define\"";
  610. } else {
  611. print OUT " /D $define";
  612. }
  613. }
  614. print OUT " /YX" if $lib || $exe;
  615. print OUT " /FD";
  616. print OUT " /GZ" if $debug;
  617. print OUT " /c";
  618. print OUT "\r\n";
  619. my @defines2 = qw(_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
  620. USE_COMPILER_EXCEPTIONS _USE_MATH_DEFINES
  621. WINVER=0x0600 _WIN32_WINNT=0x0600 _WIN32_IE=0x0700);
  622. if($debug) {
  623. if($lib) {
  624. print OUT "# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
  625. push @defines2, qw(WIN32 _DEBUG _WINDOWS _MBCS _LIB);
  626. } else {
  627. print OUT "# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
  628. push @defines2, qw(_DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
  629. }
  630. } else {
  631. if($lib) {
  632. print OUT "# ADD CPP /nologo /MD /W3 /GX /O2";
  633. push @defines2, qw(WIN32 NDEBUG _WINDOWS _MBCS _LIB);
  634. } else {
  635. print OUT "# ADD CPP /nologo /MD /W3 /GX /O2";
  636. push @defines2, qw(NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
  637. }
  638. }
  639. my @includes = ();
  640. if($wine) {
  641. push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
  642. if ($msvc_headers) {
  643. push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
  644. }
  645. my $output_dir2 = $output_dir;
  646. $output_dir2 =~ s/\\/\\\\/g;
  647. push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir2\\\"";
  648. push @defines2, qw(__i386__ _X86_);
  649. if ($project eq "wine") {
  650. push @defines2, "WINE_UNICODE_API=";
  651. }
  652. if ($project =~ /_test$/) {
  653. push @includes, "$msvc_wine_dir\\$output_dir";
  654. }
  655. if (!$msvc_headers || $project eq "winetest") {
  656. push @includes, $wine_include_dir;
  657. }
  658. }
  659. if($wine) {
  660. foreach my $include (@includes) {
  661. print OUT " /I \"$include\"";
  662. }
  663. }
  664. foreach my $define (@defines2) {
  665. if ($define !~ /=/) {
  666. print OUT " /D \"$define\"";
  667. } else {
  668. print OUT " /D $define";
  669. }
  670. }
  671. print OUT " /D inline=__inline" if $wine;
  672. print OUT " /D \"__STDC__\"" if 0 && $wine;
  673. if(exists($modules{$module}{extradefs})) {
  674. print OUT " @{$modules{$module}{extradefs}} ";
  675. }
  676. print OUT " /YX" if $lib;
  677. print OUT " /FR" if !$lib;
  678. print OUT " /FD";
  679. print OUT " /GZ" if $debug;
  680. print OUT " /c";
  681. print OUT " /TP" if !$no_cpp;
  682. print OUT "\r\n";
  683. if($debug) {
  684. print OUT "# SUBTRACT CPP /X /YX\r\n" if $dll;
  685. print OUT "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
  686. print OUT "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" if $dll;
  687. print OUT "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n";
  688. print OUT "# ADD RSC /l 0x41d";
  689. if($wine) {
  690. foreach my $include (@includes) {
  691. print OUT " /i \"$include\"";
  692. }
  693. }
  694. print OUT " /d \"_DEBUG\"\r\n";
  695. } else {
  696. print OUT "# SUBTRACT CPP /YX\r\n" if $dll;
  697. print OUT "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
  698. print OUT "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" if $dll;
  699. print OUT "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n";
  700. print OUT "# ADD RSC /l 0x41d";
  701. if($wine) {
  702. foreach my $include (@includes) {
  703. print OUT " /i \"$include\"";
  704. }
  705. }
  706. print OUT "/d \"NDEBUG\"\r\n";
  707. }
  708. print OUT "BSC32=bscmake.exe\r\n";
  709. print OUT "# ADD BASE BSC32 /nologo\r\n";
  710. print OUT "# ADD BSC32 /nologo\r\n";
  711. if($exe || $dll) {
  712. print OUT "LINK32=link.exe\r\n";
  713. print OUT "# ADD BASE LINK32";
  714. my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
  715. comdlg32.lib advapi32.lib shell32.lib ole32.lib
  716. oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
  717. foreach my $library (@libraries) {
  718. print OUT " $library";
  719. }
  720. print OUT " /nologo";
  721. print OUT " /dll" if $dll;
  722. print OUT " /subsystem:console" if $console;
  723. print OUT " /debug" if $debug;
  724. print OUT " /machine:I386";
  725. print OUT " /pdbtype:sept" if $debug;
  726. print OUT "\r\n";
  727. print OUT "# ADD LINK32";
  728. print OUT " libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
  729. foreach my $import (@imports) {
  730. print OUT " $import.lib" if ($import ne "msvcrt");
  731. }
  732. print OUT " /nologo";
  733. print OUT " /dll" if $dll;
  734. print OUT " /subsystem:console" if $console;
  735. print OUT " /debug" if $debug;
  736. print OUT " /machine:I386";
  737. print OUT " /nodefaultlib" if $project =~ /^ntdll$/; # FIXME: Kludge
  738. print OUT " /def:\"$project.def\"" if $dll;
  739. print OUT " /pdbtype:sept" if $debug;
  740. print OUT "\r\n";
  741. } else {
  742. print OUT "LIB32=link.exe -lib\r\n";
  743. print OUT "# ADD BASE LIB32 /nologo\r\n";
  744. print OUT "# ADD LIB32 /nologo\r\n";
  745. }
  746. $n++;
  747. }
  748. if($#cfgs != 0) {
  749. print OUT "\r\n";
  750. print OUT "!ENDIF \r\n";
  751. print OUT "\r\n";
  752. }
  753. print OUT "# Begin Target\r\n";
  754. print OUT "\r\n";
  755. foreach my $cfg (@cfgs) {
  756. print OUT "# Name \"$cfg\"\r\n";
  757. }
  758. print OUT "# Begin Group \"Source Files\"\r\n";
  759. print OUT "\r\n";
  760. print OUT "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
  761. if ($project eq "winebuild") {
  762. for my $ source_file ("getopt.c", "getopt1.c", "mkstemps.c")
  763. {
  764. print OUT "# Begin Source File\r\n";
  765. print OUT "\r\n";
  766. print OUT "SOURCE=..\\..\\libs\\port\\$source_file\r\n";
  767. print OUT "# End Source File\r\n";
  768. }
  769. }
  770. foreach my $source_file (@source_files) {
  771. $source_file =~ s%/%\\%g;
  772. if($source_file !~ /^\./) {
  773. $source_file = ".\\$source_file";
  774. }
  775. print OUT "# Begin Source File\r\n";
  776. print OUT "\r\n";
  777. print OUT "SOURCE=$source_file\r\n";
  778. if ($project eq "wine" && $source_file eq ".\\config.c") {
  779. print OUT "# ADD CPP /D BINDIR=\\\"\\\" /D DLLDIR=\\\"\\\" /D LIB_TO_BINDIR=\\\"\\\" /D LIB_TO_DLLDIR=\\\"\\\" /D BIN_TO_DLLDIR=\\\"\\\" /D LIB_TO_DATADIR=\\\"\\\" /D BIN_TO_DATADIR=\\\"\\\"\r\n";
  780. }
  781. if($source_file =~ /^(.*?)\.spec$/) {
  782. my $basename = $1;
  783. my $spec_file = $source_file;
  784. my $def_file = "$basename.def";
  785. my $srcdir = "."; # FIXME: Is this really always correct?
  786. print OUT "# Begin Custom Build\r\n";
  787. print OUT "InputPath=$spec_file\r\n";
  788. print OUT "\r\n";
  789. print OUT "BuildCmds= \\\r\n";
  790. print OUT "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe -w --def -k -o $def_file --export $spec_file\r\n";
  791. print OUT "\r\n";
  792. print OUT "\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
  793. print OUT " \$(BuildCmds)\r\n";
  794. print OUT "# End Custom Build\r\n";
  795. } elsif($source_file =~ /([^\\]*?\.h)$/) {
  796. my $h_file = $1;
  797. foreach my $cfg (@cfgs) {
  798. if($#cfgs == 0) {
  799. # Nothing
  800. } elsif($n == 0) {
  801. print OUT "!IF \"\$(CFG)\" == \"$cfg\"\r\n";
  802. print OUT "\r\n";
  803. } else {
  804. print OUT "\r\n";
  805. print OUT "!ELSEIF \"\$(CFG)\" == \"$cfg\"\r\n";
  806. print OUT "\r\n";
  807. }
  808. $output_dir = $cfg;
  809. $output_dir =~ s/^$project - //;
  810. $output_dir =~ s/ /_/g;
  811. $output_dir =~ s/C\+\+/Cxx/g;
  812. if($output_prefix_dir) {
  813. $output_dir = "$output_prefix_dir\\$output_dir";
  814. }
  815. print OUT "# Begin Custom Build\r\n";
  816. print OUT "OutDir=$output_dir\r\n";
  817. print OUT "InputPath=$source_file\r\n";
  818. print OUT "\r\n";
  819. print OUT "\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\r\n";
  820. print OUT "\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\r\n";
  821. print OUT "\r\n";
  822. print OUT "# End Custom Build\r\n";
  823. }
  824. if($#cfgs != 0) {
  825. print OUT "\r\n";
  826. print OUT "!ENDIF \r\n";
  827. print OUT "\r\n";
  828. }
  829. }
  830. print OUT "# End Source File\r\n";
  831. }
  832. output_dsp_idl_rules $wine_include_dir, ".h", \@idl_h_files;
  833. output_dsp_idl_rules $wine_include_dir, "_c.c", \@idl_c_files;
  834. output_dsp_idl_rules $wine_include_dir, "_s.c", \@idl_s_files;
  835. output_dsp_idl_rules $wine_include_dir, "_p.c", \@idl_p_files;
  836. # Hack - stdole2.idl cannot be compiled with midl
  837. if($project ne "include") {
  838. output_dsp_idl_rules $wine_include_dir, ".tlb", \@idl_tlb_files;
  839. }
  840. print OUT "# End Group\r\n";
  841. print OUT "# Begin Group \"Header Files\"\r\n";
  842. print OUT "\r\n";
  843. print OUT "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
  844. foreach my $header_file (@header_files) {
  845. print OUT "# Begin Source File\r\n";
  846. print OUT "\r\n";
  847. print OUT "SOURCE=.\\$header_file\r\n";
  848. print OUT "# End Source File\r\n";
  849. }
  850. print OUT "# End Group\r\n";
  851. print OUT "# Begin Group \"Resource Files\"\r\n";
  852. print OUT "\r\n";
  853. print OUT "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
  854. foreach my $resource_file (@resource_files) {
  855. print OUT "# Begin Source File\r\n";
  856. print OUT "\r\n";
  857. print OUT "SOURCE=.\\$resource_file\r\n";
  858. print OUT "# End Source File\r\n";
  859. }
  860. print OUT "# End Group\r\n";
  861. print OUT "# End Target\r\n";
  862. print OUT "# End Project\r\n";
  863. close(OUT);
  864. }
  865. sub _generate_dsw_header($) {
  866. local *OUT = shift;
  867. print OUT "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n";
  868. print OUT "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n";
  869. print OUT "\r\n";
  870. }
  871. sub _generate_dsw_project($$$$) {
  872. local *OUT = shift;
  873. my $project = shift;
  874. my $dsp_file = shift;
  875. my @dependencies = @{(shift)};
  876. $dsp_file = "./$dsp_file";
  877. $dsp_file =~ y%/%\\%;
  878. @dependencies = sort(@dependencies);
  879. print OUT "###############################################################################\r\n";
  880. print OUT "\r\n";
  881. print OUT "Project: \"$project\"=$dsp_file - Package Owner=<4>\r\n";
  882. print OUT "\r\n";
  883. print OUT "Package=<5>\r\n";
  884. print OUT "{{{\r\n";
  885. print OUT "}}}\r\n";
  886. print OUT "\r\n";
  887. print OUT "Package=<4>\r\n";
  888. print OUT "{{{\r\n";
  889. foreach my $dependency (@dependencies) {
  890. print OUT " Begin Project Dependency\r\n";
  891. print OUT " Project_Dep_Name $dependency\r\n";
  892. print OUT " End Project Dependency\r\n";
  893. }
  894. print OUT "}}}\r\n";
  895. print OUT "\r\n";
  896. }
  897. sub _generate_dsw_footer($) {
  898. local *OUT = shift;
  899. print OUT "###############################################################################\r\n";
  900. print OUT "\r\n";
  901. print OUT "Global:\r\n";
  902. print OUT "\r\n";
  903. print OUT "Package=<5>\r\n";
  904. print OUT "{{{\r\n";
  905. print OUT "}}}\r\n";
  906. print OUT "\r\n";
  907. print OUT "Package=<3>\r\n";
  908. print OUT "{{{\r\n";
  909. print OUT "}}}\r\n";
  910. print OUT "\r\n";
  911. print OUT "###############################################################################\r\n";
  912. print OUT "\r\n";
  913. }
  914. if ($options->wine) {
  915. my $dsw_file = "wine.dsw";
  916. $output->progress("$dsw_file");
  917. replace_file("$wine_dir/$dsw_file", \&_generate_wine_dsw);
  918. }
  919. sub _generate_wine_dsw($) {
  920. local *OUT = shift;
  921. _generate_dsw_header(\*OUT);
  922. foreach my $module (sort(keys(%modules))) {
  923. next if $module =~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
  924. my $project = $modules{$module}{project};
  925. my $dsp_file = $modules{$module}{dsp_file};
  926. my @dependencies;
  927. if($project eq "wine") {
  928. @dependencies = ();
  929. } elsif($project eq "winebuild") {
  930. @dependencies = ("wine");
  931. } elsif($project =~ /^(?:gdi32)_.+?$/) {
  932. @dependencies = ();
  933. } else {
  934. @dependencies = ("wine", "include", "winebuild");
  935. }
  936. if($project =~ /^gdi32$/) {
  937. foreach my $dir (@gdi32_dirs) {
  938. my $dir2 = $dir;
  939. $dir2 =~ s%^.*?/([^/]+)$%$1%;
  940. my $module = "gdi32_$dir2";
  941. $module =~ s%/%_%g;
  942. push @dependencies, $module;
  943. }
  944. }
  945. _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
  946. }
  947. _generate_dsw_footer(\*OUT);
  948. return 1;
  949. }
  950. if ($options->winetest) {
  951. my $dsw_file = "winetest.dsw";
  952. $output->progress("$dsw_file");
  953. replace_file("$wine_dir/$dsw_file", \&_generate_winetest_dsw);
  954. }
  955. sub _generate_winetest_dsw($) {
  956. local *OUT = shift;
  957. _generate_dsw_header(\*OUT);
  958. my @runtests_dependencies = ();
  959. foreach my $module (sort(keys(%modules))) {
  960. next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
  961. next if $module eq "wineruntests";
  962. my $project = $modules{$module}{project};
  963. push @runtests_dependencies, $project;
  964. }
  965. foreach my $module (sort(keys(%modules))) {
  966. next if $module !~ /(?:winetest\.lib|wineruntests\.exe|_test\.exe)$/;
  967. my $project = $modules{$module}{project};
  968. my $dsp_file = $modules{$module}{dsp_file};
  969. my @dependencies;
  970. if($project =~ /^winetest$/) {
  971. @dependencies = ();
  972. } elsif($project =~ /^wineruntests$/) {
  973. @dependencies = @runtests_dependencies;
  974. } else {
  975. @dependencies = ("winetest");
  976. }
  977. _generate_dsw_project(\*OUT, $project, $dsp_file, \@dependencies);
  978. }
  979. _generate_dsw_footer(\*OUT);
  980. }
  981. if ($options->winetest) {
  982. foreach my $module (sort(keys(%modules))) {
  983. next if $module !~ /_test\.exe$/;
  984. my $project = $modules{$module}{project};
  985. my $dsp_file = $modules{$module}{dsp_file};
  986. my @tests = @{$modules{$module}{tests}};
  987. my $testlist_c = $dsp_file;
  988. $testlist_c =~ s%[^/]*\.dsp$%testlist.c%;
  989. replace_file("$wine_dir/$testlist_c", \&_generate_testlist_c, \@tests);
  990. }
  991. }
  992. # ***** Keep in sync with tools/make_ctests *****
  993. sub _generate_testlist_c($$) {
  994. local *OUT = shift;
  995. my @tests = @{(shift)};
  996. print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
  997. print OUT "\n";
  998. print OUT "/* stdarg.h is needed for Winelib */\n";
  999. print OUT "#include <stdarg.h>\n";
  1000. print OUT "#include <stdio.h>\n";
  1001. print OUT "#include <stdlib.h>\n";
  1002. print OUT "#include \"windef.h\"\n";
  1003. print OUT "#include \"winbase.h\"\n";
  1004. print OUT "\n";
  1005. print OUT "#define STANDALONE\n";
  1006. print OUT "#include \"wine/test.h\"\n";
  1007. print OUT "\n";
  1008. foreach my $test (@tests) {
  1009. print OUT "extern void func_$test(void);\n";
  1010. }
  1011. print OUT "\n";
  1012. print OUT "const struct test winetest_testlist[] =\n";
  1013. print OUT "{\n";
  1014. foreach my $test (@tests) {
  1015. print OUT " { \"$test\", func_$test },\n";
  1016. }
  1017. print OUT " { 0, 0 }\n";
  1018. print OUT "};\n";
  1019. }
  1020. if ($options->winetest) {
  1021. replace_file("$wine_dir/runtests.c", \&_generate_runtests_c);
  1022. }
  1023. sub _generate_runtests_c($) {
  1024. local *OUT = shift;
  1025. print OUT "/* Automatically generated file; DO NOT EDIT!! */\n";
  1026. print OUT "\n";
  1027. print OUT "#include <stdio.h>\n";
  1028. print OUT "#include <stdlib.h>\n";
  1029. print OUT "\n";
  1030. print OUT "int main(int argc, char *argv[])\n";
  1031. print OUT "{\n";
  1032. print OUT " char output_dir[] = __WINETEST_OUTPUT_DIR;\n";
  1033. print OUT " char command[4096];\n";
  1034. print OUT "\n";
  1035. foreach my $dsp_file (keys(%runtests)) {
  1036. my @tests = @{$runtests{$dsp_file}};
  1037. my $project = $dsp_file;
  1038. $project =~ s%^(.*?)/?([^/]+)\.dsp$%$2%;
  1039. my $dir = $1;
  1040. $dir =~ s%/%\\\\%g;
  1041. foreach my $test (@tests) {
  1042. print OUT " sprintf(command, \"$dir\\\\%s\\\\$project.exe $test\", output_dir);\n";
  1043. print OUT " system(command);\n";
  1044. print OUT "\n";
  1045. }
  1046. }
  1047. print OUT " return 0;\n";
  1048. print OUT "}\n";
  1049. }
  1050. if ($options->winetest) {
  1051. replace_file("$wine_dir/winetest.c", \&_generate_winetest_c);
  1052. }
  1053. sub _generate_winetest_c($) {
  1054. local *OUT = shift;
  1055. print OUT "/* Automatically generated file; DO NOT EDIT!! */\n\n";
  1056. print OUT "/* Force the linker to generate a .lib file */\n";
  1057. print OUT "void __wine_dummy_lib_function(void)\n{\n}\n\n";
  1058. }
  1059. if ($options->wine) {
  1060. my $config_h = "include/config.h";
  1061. $output->progress("$config_h");
  1062. replace_file("$wine_dir/$config_h", \&_generate_config_h);
  1063. }
  1064. sub _generate_config_h($) {
  1065. local *OUT = shift;
  1066. my @defines;
  1067. print OUT "#define __WINE_CONFIG_H\n";
  1068. print OUT "\n";
  1069. my @headers = qw(direct.h float.h memory.h io.h stdlib.h string.h process.h sys/stat.h sys/types.h);
  1070. foreach my $header (@headers) {
  1071. $header =~ y/\.\//__/;
  1072. push @defines, "HAVE_\U$header\E 1";
  1073. }
  1074. my @functions = qw(
  1075. _pclose _popen _snprintf _spawnvp _stricmp _strnicmp _strdup
  1076. _strtoi64 _strtoui64 _vsnprintf
  1077. chsize memmove strdup spawnvp strerror vsnprintf
  1078. );
  1079. foreach my $function (@functions) {
  1080. push @defines, "HAVE_\U$function\E 1";
  1081. }
  1082. my @types = qw(
  1083. long_long off_t size_t
  1084. );
  1085. foreach my $type (@types) {
  1086. push @defines, "HAVE_\U$type\E 1";
  1087. }
  1088. foreach my $define (sort(@defines)) {
  1089. print OUT "#define $define\n";
  1090. print OUT "\n";
  1091. }
  1092. print OUT "/* Define to the address where bug reports for this package should be sent. */\n";
  1093. print OUT "#define PACKAGE_BUGREPORT \"\"\n";
  1094. print OUT "\n";
  1095. print OUT "/* Define to the full name of this package. */\n";
  1096. print OUT "#define PACKAGE_NAME \"Wine\"\n";
  1097. print OUT "\n";
  1098. print OUT "/* Define to the full name and version of this package. */\n";
  1099. print OUT "#define PACKAGE_STRING \"Wine YYYYMMDD\"\n";
  1100. print OUT "\n";
  1101. print OUT "/* Define to the one symbol short name of this package. */\n";
  1102. print OUT "#define PACKAGE_TARNAME \"wine\"\n";
  1103. print OUT "\n";
  1104. print OUT "/* Define to the version of this package. */\n";
  1105. print OUT "#define PACKAGE_VERSION \"YYYYMMDD\"\n";
  1106. print OUT "\n";
  1107. print OUT "#define X_DISPLAY_MISSING 1\n";
  1108. print OUT "\n";
  1109. print OUT "/* Define to a macro to generate an assembly function directive */\n";
  1110. print OUT "#define __ASM_FUNC(name) \"\"\n";
  1111. print OUT "\n";
  1112. print OUT "/* Define to a macro to generate an assembly name from a C symbol */\n";
  1113. print OUT "#define __ASM_NAME(name) name\n";
  1114. print OUT "\n";
  1115. close(OUT);
  1116. }