msvcmaker 36 KB

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