Commit | Line | Data |
---|---|---|
34618113 AJ |
1 | #!/usr/bin/perl -w |
2 | # | |
3 | # Build the auto-generated parts of the Wine makefiles. | |
4 | # | |
5 | # Copyright 2006 Alexandre Julliard | |
6 | # | |
7 | # This library is free software; you can redistribute it and/or | |
8 | # modify it under the terms of the GNU Lesser General Public | |
9 | # License as published by the Free Software Foundation; either | |
10 | # version 2.1 of the License, or (at your option) any later version. | |
11 | # | |
12 | # This library is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | # Lesser General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU Lesser General Public | |
18 | # License along with this library; if not, write to the Free Software | |
19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA | |
20 | # | |
21 | ||
48c14238 | 22 | # Make rules files |
44db04c0 AJ |
23 | my %makerules = |
24 | ( | |
25 | "MAKE_RULES" => "Make.rules", | |
26 | "MAKE_DLL_RULES" => "dlls/Makedll.rules", | |
27 | "MAKE_IMPLIB_RULES" => "dlls/Makeimplib.rules", | |
28 | "MAKE_TEST_RULES" => "dlls/Maketest.rules", | |
29 | "MAKE_PROG_RULES" => "programs/Makeprog.rules", | |
30 | ); | |
31 | ||
48c14238 AJ |
32 | # Programs that we want to install in the bin directory too |
33 | my %bin_install = | |
34 | ( | |
35 | "msiexec" => 1, | |
36 | "notepad" => 1, | |
37 | "progman" => 1, | |
38 | "regedit" => 1, | |
39 | "regsvr32" => 1, | |
40 | "uninstaller" => 1, | |
41 | "wineboot" => 1, | |
42 | "winebrowser" => 1, | |
43 | "winecfg" => 1, | |
44 | "wineconsole" => 1, | |
45 | "winedbg" => 1, | |
46 | "winefile" => 1, | |
47 | "winemine" => 1, | |
48 | "winepath" => 1, | |
49 | "winhelp" => 1, | |
50 | ); | |
51 | ||
52 | # Programs that we don't want to install at all | |
53 | my %dont_install = | |
54 | ( | |
55 | "cmdlgtst" => 1, | |
56 | "view" => 1, | |
57 | "winetest" => 1, | |
58 | ); | |
59 | ||
0134db6e AJ |
60 | # Special dlls that can be switched on or off by configure |
61 | my %special_dlls = | |
62 | ( | |
63 | "glu32" => "GLU32FILES", | |
64 | "opengl32" => "OPENGLFILES", | |
0134db6e AJ |
65 | "winex11.drv" => "XFILES", |
66 | "winequartz.drv" => "QUARTZFILES" | |
67 | ); | |
68 | ||
6150fe19 AJ |
69 | # Default patterns for top-level .gitignore |
70 | my @ignores = ( | |
71 | "*.[oa]", | |
6150fe19 | 72 | "*.so", |
6150fe19 AJ |
73 | "/autom4te.cache", |
74 | "/config.cache", | |
75 | "/config.log", | |
76 | "/config.status", | |
77 | "/TAGS", | |
78 | "/tags", | |
7d659398 AJ |
79 | "Makefile", |
80 | "include/config.h", | |
81 | "include/stamp-h" | |
6150fe19 AJ |
82 | ); |
83 | ||
5eb38cf9 AJ |
84 | # Source files and their resulting target to ignore |
85 | my @ignore_srcs = ( | |
86 | [ 'BISON_SRCS', '\.y', '.tab.c' ], | |
87 | [ 'BISON_SRCS', '\.y', '.tab.h' ], | |
88 | [ 'LEX_SRCS', '\.l', '.yy.c' ], | |
89 | [ 'MC_SRCS', '\.mc', '.mc.rc' ], | |
90 | [ 'RC_SRCS', '\.rc', '.res' ], | |
91 | [ 'RC_SRCS16', '\.rc', '.res' ], | |
92 | [ 'IDL_TLB_SRCS', '\.idl', '.tlb' ], | |
8c875111 | 93 | [ 'IDL_H_SRCS', '\.idl', '.h' ], |
1df72cc7 AJ |
94 | [ 'IDL_C_SRCS', '\.idl', '.h' ], |
95 | [ 'IDL_I_SRCS', '\.idl', '.h' ], | |
96 | [ 'IDL_P_SRCS', '\.idl', '.h' ], | |
97 | [ 'IDL_S_SRCS', '\.idl', '.h' ], | |
5eb38cf9 AJ |
98 | [ 'IDL_C_SRCS', '\.idl', '_c.c' ], |
99 | [ 'IDL_I_SRCS', '\.idl', '_i.c' ], | |
100 | [ 'IDL_P_SRCS', '\.idl', '_p.c' ], | |
101 | [ 'IDL_S_SRCS', '\.idl', '_s.c' ], | |
102 | ); | |
103 | ||
ac91ffd7 AJ |
104 | my %private_headers = ( |
105 | "thread.h" => 1, | |
106 | "win.h" => 1, | |
cfc50f89 | 107 | "wine/irot.idl" => 1, |
ac91ffd7 AJ |
108 | "wine/list.h" => 1, |
109 | "wine/mmsystem16.h" => 1, | |
110 | "wine/mscvpdb.h" => 1, | |
111 | "wine/port.h" => 1, | |
112 | "wine/pthread.h" => 1, | |
113 | "wine/rpcfc.h" => 1, | |
114 | "wine/rpcss_shared.h" => 1, | |
115 | "wine/server.h" => 1, | |
116 | "wine/server_protocol.h" => 1, | |
117 | "wine/test.h" => 1, | |
118 | "wine/wgl.h" => 1, | |
119 | "wine/winaspi.h" => 1, | |
120 | "wine/winbase16.h" => 1, | |
121 | "wine/windef16.h" => 1, | |
122 | "wine/wined3d_caps.h" => 1, | |
123 | "wine/wined3d_gl.h" => 1, | |
124 | "wine/wined3d_interface.h" => 1, | |
125 | "wine/wined3d_types.h" => 1, | |
126 | "wine/wingdi16.h" => 1, | |
127 | "wine/winnet16.h" => 1, | |
128 | "wine/winsock16.h" => 1, | |
129 | "wine/winuser16.h" => 1, | |
130 | "wine/wpp.h" => 1 | |
131 | ); | |
132 | ||
133 | my %private_idl_headers = ( | |
134 | "axcore.idl" => 1, | |
135 | "axextend.idl" => 1, | |
136 | "dbinit.idl" => 1, | |
137 | "dbprop.idl" => 1, | |
138 | "dbs.idl" => 1, | |
139 | "devenum.idl" => 1, | |
140 | "dyngraph.idl" => 1 | |
141 | ); | |
142 | ||
44db04c0 AJ |
143 | my (@makefiles, %makefiles); |
144 | ||
34618113 AJ |
145 | # update a file if changed |
146 | sub update_file($) | |
147 | { | |
148 | my $file = shift; | |
8c875111 | 149 | my $ret = !(-f $file) || system "cmp $file $file.new >/dev/null"; |
34618113 AJ |
150 | if (!$ret) |
151 | { | |
152 | unlink "$file.new"; | |
34618113 AJ |
153 | } |
154 | else | |
155 | { | |
156 | rename "$file.new", "$file"; | |
157 | print "$file updated\n"; | |
7035aa50 AJ |
158 | if ($file eq "configure.ac") |
159 | { | |
160 | system "autoconf"; | |
161 | print "configure updated\n"; | |
162 | } | |
34618113 AJ |
163 | } |
164 | return $ret; | |
165 | } | |
166 | ||
167 | # replace some lines in a file between two markers | |
168 | sub replace_in_file($$$@) | |
169 | { | |
170 | my $file = shift; | |
171 | my $start = shift; | |
172 | my $end = shift; | |
173 | ||
34618113 AJ |
174 | open NEW_FILE, ">$file.new" or die "cannot create $file.new"; |
175 | ||
48c14238 | 176 | if (defined($start)) |
34618113 | 177 | { |
48c14238 AJ |
178 | open OLD_FILE, "$file" or die "cannot open $file"; |
179 | while (<OLD_FILE>) | |
180 | { | |
181 | last if /$start/; | |
182 | print NEW_FILE $_; | |
183 | } | |
34618113 AJ |
184 | } |
185 | ||
186 | print NEW_FILE @_; | |
187 | ||
188 | if (defined($end)) | |
189 | { | |
190 | my $skip=1; | |
191 | while (<OLD_FILE>) | |
192 | { | |
193 | print NEW_FILE $_ unless $skip; | |
194 | $skip = 0 if /$end/; | |
195 | } | |
196 | } | |
197 | ||
48c14238 | 198 | close OLD_FILE if defined($start); |
34618113 AJ |
199 | close NEW_FILE; |
200 | return update_file($file); | |
201 | } | |
202 | ||
44db04c0 AJ |
203 | # parse the specified makefile to identify the rules file |
204 | sub parse_makefile($) | |
205 | { | |
206 | my $file = shift; | |
48c14238 | 207 | my %make; |
44db04c0 | 208 | |
7035aa50 AJ |
209 | ($make{"=dir"} = $file) =~ s/[^\/]+$//; |
210 | ||
44db04c0 AJ |
211 | open MAKE, "$file.in" or die "cannot open $file.in\n"; |
212 | ||
213 | while (<MAKE>) | |
214 | { | |
215 | chomp; | |
216 | while (/\\$/) { chop; $_ .= <MAKE>; chomp; } # merge continued lines | |
217 | ||
218 | if (/^\@(MAKE.*RULES)\@/) | |
219 | { | |
220 | my $var = $1; | |
48c14238 AJ |
221 | $make{"=rules"} = $makerules{$var}; |
222 | next; | |
223 | } | |
8ef6b39c | 224 | if (/^(MODULE|IMPORTLIB|TESTDLL)\s*=\s*(.*)/) |
48c14238 | 225 | { |
0134db6e | 226 | $make{$1} = $2; |
48c14238 AJ |
227 | next; |
228 | } | |
5eb38cf9 | 229 | if (/^(BISON_SRCS|LEX_SRCS|IDL_[CHIPS]_SRCS|IDL_TLB_SRCS|IMPLIB_SRCS|MC_SRCS|RC_SRCS|RC_SRCS16|RC_BINARIES|SPEC_SRCS16|MANPAGES|PROGRAMS)\s*=\s*(.*)/) |
365a463b AJ |
230 | { |
231 | my @list = split(/\s+/, $2); | |
232 | $make{$1} = \@list; | |
233 | next; | |
234 | } | |
48c14238 AJ |
235 | if (/^\#\s*MKDLL_SKIP/ || /^\#\s*MKPROG_SKIP/) |
236 | { | |
237 | $make{"=skip"} = 1; | |
238 | next; | |
44db04c0 AJ |
239 | } |
240 | } | |
48c14238 | 241 | return %make; |
44db04c0 | 242 | } |
34618113 | 243 | |
34618113 AJ |
244 | |
245 | ################################################################ | |
246 | # update the makefile list in configure.ac | |
247 | ||
ac91ffd7 | 248 | sub update_makerules(@) |
fbc80d79 | 249 | { |
fbc80d79 MM |
250 | } |
251 | ||
34618113 | 252 | |
27959beb | 253 | ################################################################ |
534fac98 | 254 | # update the tests list in programs/winetest/Makefile.in and programs/winetest/winetest.rc |
27959beb | 255 | |
6150fe19 | 256 | sub update_winetest(@) |
27959beb | 257 | { |
6150fe19 AJ |
258 | my (@tests, @lines); |
259 | ||
260 | foreach my $file (@_) | |
27959beb | 261 | { |
6150fe19 | 262 | if ($file =~ /^dlls\/(.*)\/tests\/Makefile/) { push @tests, $1; } |
27959beb | 263 | } |
6150fe19 AJ |
264 | push @lines, "TESTBINS ="; |
265 | push @lines, map { " \\\n\t" . $_ . "_test.exe"; } sort @tests; | |
266 | push @lines, "\n\n"; | |
27959beb | 267 | |
6150fe19 AJ |
268 | foreach my $test (sort @tests) |
269 | { | |
270 | push @lines, "${test}_test.exe: \$(DLLDIR)/$test/tests/${test}_test.exe\$(DLLEXT)\n"; | |
271 | push @lines, "\tcp \$(DLLDIR)/$test/tests/${test}_test.exe\$(DLLEXT) \$\@ && \$(STRIP) \$\@\n"; | |
272 | } | |
273 | push @lines, "\n# Special rules\n"; | |
27959beb | 274 | |
6150fe19 | 275 | replace_in_file( "programs/winetest/Makefile.in", '^TESTBINS\s*=', '^# Special rules', @lines ); |
27959beb | 276 | |
6150fe19 AJ |
277 | replace_in_file( "programs/winetest/winetest.rc", ' TESTRES ', undef, |
278 | map { $_ . "_test.exe TESTRES \"" . $_ . "_test.exe\"\n"; } sort @tests ); | |
279 | ||
280 | # return a list of test exe files for .gitignore | |
281 | return map { "programs/winetest/" . $_ . "_test.exe"; } sort @tests; | |
534fac98 AJ |
282 | } |
283 | ||
27959beb | 284 | |
5ea4e5ba | 285 | ################################################################ |
ac91ffd7 | 286 | # update the makefile list in configure.ac and Makefile.in |
5ea4e5ba | 287 | |
5eb38cf9 | 288 | sub update_makefiles(@) |
5ea4e5ba | 289 | { |
ac91ffd7 AJ |
290 | my (@targets, @depends, @lines); |
291 | ||
292 | foreach my $var (sort { $makerules{$a} cmp $makerules{$b}; } keys %makerules) | |
293 | { | |
294 | push @lines, "$var=$makerules{$var}\n"; | |
295 | push @lines, "AC_SUBST_FILE($var)\n\n"; | |
296 | } | |
297 | ||
298 | foreach my $var ((sort values %makerules), (sort @_)) | |
299 | { | |
300 | push @lines, "AC_CONFIG_FILES([$var])\n"; | |
301 | } | |
302 | ||
303 | push @lines, "\nAC_OUTPUT\n"; | |
304 | replace_in_file( "configure.ac", '^MAKE_RULES', '^AC_OUTPUT$', @lines); | |
5eb38cf9 AJ |
305 | |
306 | foreach my $file (sort values %makerules) | |
307 | { | |
308 | push @targets, $file; | |
309 | my %make = %{$makefiles{$file}}; | |
310 | if (!defined($make{"=rules"})) { push @depends, "$file: $file.in"; } | |
311 | else { push @depends, "$file: $file.in Make.rules"; } | |
312 | } | |
313 | ||
314 | foreach my $file (sort @_) | |
315 | { | |
316 | push @targets, $file unless $file eq "Makefile"; | |
317 | my %makefile = %{$makefiles{$file}}; | |
318 | my $dep = $makefile{"=rules"}; | |
319 | push @depends, "$file: $file.in $dep"; | |
320 | } | |
321 | ||
322 | ||
323 | @lines = (); | |
324 | push @lines, "ALL_MAKEFILES = \\\n\t"; | |
325 | push @lines, join (" \\\n\t", @targets ), "\n\n"; | |
326 | push @lines, "Makefile \$(ALL_MAKEFILES): config.status\n"; | |
274115f9 AJ |
327 | push @lines, "\t\@./config.status \$\@\n"; |
328 | push @lines, ".INIT: Makefile\n"; | |
329 | push @lines, ".BEGIN: Makefile\n\n"; | |
5eb38cf9 AJ |
330 | push @lines, "\$(RECURSE_TARGETS) \$(MAKEDEP): \$(ALL_MAKEFILES)\n\n"; |
331 | push @lines, "distclean::\n"; | |
332 | push @lines, "\t\$(RM) Makefile \$(ALL_MAKEFILES)\n\n"; | |
333 | push @lines, join ("\n", @depends ), "\n"; | |
334 | ||
335 | replace_in_file( "Makefile.in", '^ALL_MAKEFILES\s*=', undef, @lines ); | |
5ea4e5ba AJ |
336 | } |
337 | ||
5eb38cf9 AJ |
338 | |
339 | ################################################################ | |
340 | # process ignore targets for generic source files | |
341 | ||
342 | sub update_ignores(@) | |
5ea4e5ba | 343 | { |
5eb38cf9 | 344 | my @ignores; |
5ea4e5ba | 345 | |
5eb38cf9 AJ |
346 | foreach my $file (sort @_) |
347 | { | |
348 | my %makefile = %{$makefiles{$file}}; | |
349 | my @list; | |
5ea4e5ba | 350 | |
5eb38cf9 AJ |
351 | foreach my $src (@ignore_srcs) |
352 | { | |
353 | my @pattern = @{$src}; | |
354 | next unless defined $makefile{$pattern[0]}; | |
355 | push @list, map { (my $ret = $_) =~ s/$pattern[1]$/$pattern[2]/; $ret; } @{$makefile{$pattern[0]}}; | |
356 | } | |
357 | push @list, @{$makefile{"RC_BINARIES"}} if defined $makefile{"RC_BINARIES"}; | |
8c875111 AJ |
358 | foreach my $f (@list) |
359 | { | |
360 | push @ignores, $makefile{"=dir"} . $f unless $f =~ /\$\(.*\)/; # skip make variables | |
361 | } | |
5eb38cf9 AJ |
362 | } |
363 | return @ignores; | |
364 | } | |
5ea4e5ba | 365 | |
34618113 AJ |
366 | ################################################################ |
367 | # update dlls/Makefile.in | |
368 | ||
0134db6e AJ |
369 | sub update_dlls(@) |
370 | { | |
371 | my (%directories, %testdirs, %importlibs, %static_implibs, %staticlib_dirs, %altnames); | |
372 | my $text = ""; | |
bb7f2f9c | 373 | my @ignores = (); |
0134db6e | 374 | |
0134db6e AJ |
375 | foreach my $make (@_) |
376 | { | |
bb7f2f9c | 377 | my %makefile = %{$makefiles{$make}}; |
d44ed08d | 378 | next if defined $makefile{"=skip"}; |
bb7f2f9c | 379 | |
0134db6e AJ |
380 | if ($make =~ /dlls\/(.*)\/tests\/Makefile/) |
381 | { | |
8ef6b39c PS |
382 | $testdirs{$1} = "$1/tests"; |
383 | (my $crosstest = $makefile{"TESTDLL"}) =~ s/\.dll$//; | |
384 | push @ignores, $makefile{"=dir"} . $crosstest . "_crosstest.exe"; | |
bb7f2f9c AJ |
385 | push @ignores, $makefile{"=dir"} . "testlist.c"; |
386 | push @ignores, $makefile{"=dir"} . "*.ok"; | |
0134db6e AJ |
387 | next; |
388 | } | |
0134db6e AJ |
389 | |
390 | next unless defined $makefile{"MODULE"}; | |
391 | my $module = $makefile{"MODULE"}; | |
05ef63e8 | 392 | (my $dir = $makefile{"=dir"}) =~ s/^dlls\/(.*)\//$1/; |
0134db6e AJ |
393 | |
394 | if ($module =~ /^lib.*\.a$/) | |
395 | { | |
365a463b | 396 | $staticlib_dirs{$module} = $dir; |
0134db6e AJ |
397 | die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module; |
398 | } | |
399 | else | |
400 | { | |
a1a8036b | 401 | die "invalid module $module" unless $module =~ /\./; |
05ef63e8 AJ |
402 | (my $mod = $module) =~ s/\.dll$//; |
403 | die "invalid directory $dir for module $module\n" unless $mod eq $dir; | |
365a463b | 404 | $directories{$module} = $dir; |
0134db6e AJ |
405 | } |
406 | ||
407 | if (defined $makefile{"IMPORTLIB"}) | |
408 | { | |
409 | if ($makefile{"IMPORTLIB"} =~ /^([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/) | |
410 | { | |
411 | $importlibs{$module} = $1; | |
412 | } | |
413 | else | |
414 | { | |
415 | die "invalid importlib name $makefile{IMPORTLIB} in $make"; | |
416 | } | |
417 | } | |
418 | ||
419 | $static_implibs{$module} = 1 if defined $makefile{"IMPLIB_SRCS"}; | |
420 | ||
421 | if (defined $makefile{"SPEC_SRCS16"}) | |
422 | { | |
365a463b | 423 | my @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @{$makefile{"SPEC_SRCS16"}}; |
0134db6e AJ |
424 | $altnames{$module} = \@list; |
425 | } | |
426 | } | |
427 | ||
428 | # output special dlls configure definitions | |
429 | ||
430 | $text .= "# special configure-dependent targets\n\n"; | |
431 | my %specials = (); | |
432 | foreach my $mod (sort keys %special_dlls) | |
433 | { | |
434 | $specials{$special_dlls{$mod}} .= " " . $mod; | |
435 | } | |
436 | foreach my $i (sort keys %specials) | |
437 | { | |
438 | $text .= $i . " =" . $specials{$i} . "\n"; | |
439 | } | |
440 | $text .= "EXTRADIRS ="; | |
441 | foreach my $i (sort keys %specials) { $text .= sprintf " \@%s\@", $i; } | |
442 | $text .= "\n\n"; | |
443 | ||
444 | # output the subdirs list | |
445 | ||
446 | $text .= "# Subdir list\n\n"; | |
447 | $text .= "BASEDIRS ="; | |
448 | foreach my $dir (sort values %directories) | |
449 | { | |
450 | next if defined($special_dlls{$dir}); # skip special dlls | |
451 | $text .= " \\\n\t" . $dir; | |
452 | } | |
453 | ||
454 | $text .= "\n\nIMPLIBSUBDIRS = \\\n\t"; | |
455 | $text .= join " \\\n\t", sort values %staticlib_dirs; | |
456 | ||
457 | $text .= "\n\nTESTSUBDIRS = \\\n\t"; | |
458 | $text .= join " \\\n\t", sort values %testdirs; | |
459 | ||
460 | $text .= "\n\nSUBDIRS = \\\n\t"; | |
461 | $text .= join " \\\n\t", "\$(BASEDIRS)", "\$(IMPLIBSUBDIRS)", "\$(TESTSUBDIRS)", sort keys %special_dlls; | |
462 | ||
463 | $text .= "\n\nBUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(TESTSUBDIRS)\n"; | |
464 | $text .= "INSTALLSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(IMPLIBSUBDIRS)\n"; | |
465 | $text .= "DOCSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)\n"; | |
466 | ||
05ef63e8 | 467 | # output the list of 16-bit files |
0134db6e | 468 | |
05ef63e8 | 469 | my @targets16 = (); |
0134db6e AJ |
470 | foreach my $mod (sort keys %directories) |
471 | { | |
0134db6e AJ |
472 | next unless defined $altnames{$mod}; |
473 | foreach my $i (sort @{$altnames{$mod}}) | |
474 | { | |
05ef63e8 | 475 | push @targets16, $i . "16"; |
0134db6e AJ |
476 | } |
477 | } | |
05ef63e8 | 478 | $text .= "\n# 16-bit dlls\n\n"; |
0134db6e | 479 | $text .= "WIN16_FILES = \\\n"; |
05ef63e8 AJ |
480 | $text .= "\t" . join( " \\\n\t", sort @targets16 ) . "\n\n"; |
481 | $text .= "\@MAKE_RULES\@\n\n"; | |
482 | ||
483 | # output the all: target | |
484 | ||
0134db6e | 485 | $text .= "# Main target\n\n"; |
05ef63e8 | 486 | $text .= "all: \$(BUILDSUBDIRS) \@WIN16_FILES\@\n\n"; |
0134db6e AJ |
487 | |
488 | # output the lib name -> directory rules | |
489 | ||
0134db6e AJ |
490 | $text .= "# Placeholders for 16-bit libraries\n\n"; |
491 | foreach my $mod (sort keys %directories) | |
492 | { | |
493 | next unless defined $altnames{$mod}; | |
494 | $text .= sprintf "%s:\n", join(" ", map { $_ . "16"; } sort @{$altnames{$mod}}); | |
495 | $text .= sprintf "\techo \"%s\" >\$\@\n\n", $mod; | |
496 | } | |
497 | ||
498 | # output the import libraries rules | |
499 | ||
500 | $text .= "# Import libraries\n\n"; | |
501 | $text .= "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n"; | |
502 | ||
503 | my @lib_symlinks = (); | |
504 | foreach my $mod (sort keys %importlibs) | |
505 | { | |
506 | my $dir = $directories{$mod}; | |
507 | my $lib = $importlibs{$mod}; | |
508 | if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; } | |
509 | } | |
510 | $text .= "IMPORT_SYMLINKS ="; | |
511 | foreach my $mod (sort @lib_symlinks) | |
512 | { | |
513 | $text .= sprintf " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod}; | |
514 | } | |
515 | ||
516 | $text .= "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)"; | |
517 | foreach my $mod (sort keys %staticlib_dirs) | |
518 | { | |
519 | $text .= sprintf " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod; | |
520 | } | |
521 | foreach my $mod (sort keys %importlibs) | |
522 | { | |
523 | my $dir = $directories{$mod}; | |
524 | my $def = $mod; | |
525 | $def =~ s/\.(dll|drv)$//; | |
526 | $text .= sprintf " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def; | |
527 | next unless defined $static_implibs{$mod}; | |
528 | $text .= sprintf " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def | |
529 | } | |
530 | $text .= "\n\n"; | |
531 | $text .= "implib: \$(IMPORT_LIBS)\n\n"; | |
05ef63e8 | 532 | $text .= ".PHONY: implib\n\n"; |
0134db6e AJ |
533 | |
534 | foreach my $mod (sort keys %importlibs) | |
535 | { | |
536 | my $dir = $directories{$mod}; | |
537 | my $lib = $importlibs{$mod}; | |
538 | my $spec = $mod; | |
539 | $spec =~ s/\.dll$//; | |
540 | $text .= sprintf "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec; | |
541 | $text .= sprintf "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib; | |
542 | next unless $static_implibs{$mod}; | |
543 | $text .= sprintf "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec; | |
544 | $text .= sprintf "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib; | |
545 | } | |
546 | foreach my $mod (sort @lib_symlinks) | |
547 | { | |
548 | my $dir = $directories{$mod}; | |
549 | my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)"; | |
550 | $text .= sprintf "%s: %s/%s\n", $lib, $dir, $lib; | |
551 | $text .= sprintf "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib; | |
552 | } | |
553 | ||
554 | $text .= "\$(BUILDSUBDIRS): \$(IMPORT_LIBS)\n"; | |
555 | $text .= "\$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)\n\n"; | |
556 | ||
557 | # output the inter-dll dependencies and rules | |
558 | ||
559 | $text .= "# Map library name to the corresponding directory\n\n"; | |
560 | ||
0134db6e AJ |
561 | foreach my $mod (sort keys %staticlib_dirs) |
562 | { | |
563 | $text .= sprintf "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod}; | |
564 | } | |
565 | $text .= "\n# Misc rules\n"; | |
566 | ||
567 | replace_in_file( "dlls/Makefile.in", | |
568 | '^# special configure-dependent targets', | |
569 | '^# Misc rules', | |
570 | $text ); | |
571 | ||
572 | # .gitignore file | |
573 | ||
574 | foreach my $mod (sort @lib_symlinks) | |
575 | { | |
6150fe19 | 576 | push @ignores, "dlls/$importlibs{$mod}.def"; |
0134db6e AJ |
577 | } |
578 | foreach my $mod (sort keys %directories) | |
579 | { | |
580 | next unless defined $altnames{$mod}; | |
6150fe19 | 581 | push @ignores, map { "dlls/" . $_ . "16"; } @{$altnames{$mod}}; |
0134db6e AJ |
582 | } |
583 | foreach my $mod (sort keys %importlibs) | |
584 | { | |
585 | my $dir = $directories{$mod}; | |
586 | my $def = $mod; | |
587 | $def =~ s/\.(dll|drv)$//; | |
6150fe19 | 588 | push @ignores, "dlls/$dir/lib$def.def"; |
0134db6e AJ |
589 | } |
590 | ||
6150fe19 | 591 | return @ignores; |
0134db6e AJ |
592 | } |
593 | ||
34618113 | 594 | |
34618113 | 595 | ################################################################ |
6150fe19 | 596 | # update programs/Makefile.in |
48c14238 AJ |
597 | |
598 | sub update_progs(@) | |
599 | { | |
600 | my (@subdirs, @install_subdirs, @install_progs); | |
601 | ||
7035aa50 | 602 | my @ignores = (); |
48c14238 AJ |
603 | |
604 | foreach my $make (@_) | |
605 | { | |
606 | my %makefile = %{$makefiles{$make}}; | |
607 | my $module = $makefile{"MODULE"}; | |
608 | (my $dir = $make) =~ s/^programs\/(.*)\/Makefile$/$1/; | |
609 | die "Invalid module $module in $make" unless "$dir.exe" eq $module; | |
610 | next if defined $makefile{"=skip"}; | |
611 | push @subdirs, $dir; | |
6150fe19 | 612 | push @ignores, "programs/$dir/$dir"; |
48c14238 AJ |
613 | push @install_subdirs, $dir unless $dont_install{$dir}; |
614 | push @install_progs, $dir if $bin_install{$dir}; | |
615 | } | |
616 | ||
617 | replace_in_file( "programs/Makefile.in", '^SUBDIRS\s*=', '^INSTALLDIRS', | |
618 | "SUBDIRS = \\\n\t", | |
619 | join( " \\\n\t", @subdirs ), | |
620 | "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS = \\\n\t", | |
621 | join( " \\\n\t", @install_subdirs ), | |
622 | "\n\n# Programs to install in bin directory\nINSTALLPROGS = \\\n\t", | |
623 | join( " \\\n\t", @install_progs ), | |
624 | "\n\nINSTALLDIRS = \$(DESTDIR)\$(bindir)\n" ); | |
625 | ||
6150fe19 | 626 | return @ignores; |
48c14238 | 627 | } |
34618113 | 628 | |
7035aa50 | 629 | |
ac91ffd7 AJ |
630 | ################################################################ |
631 | # update include/Makefile.in | |
632 | ||
633 | sub update_includes() | |
634 | { | |
635 | return unless -d ".git"; | |
636 | my (@h_srcs, @idl_srcs, @tlb_srcs, %subdirs); | |
637 | my @includes = map { s/^include\///; $_; } split /\0/, `git ls-files -c -z include`; | |
638 | foreach my $incl (@includes) | |
639 | { | |
640 | if ($incl =~ /(.*)\//) { $subdirs{$1} = 1; } | |
641 | next if ($private_headers{$incl}); | |
642 | if ($incl =~ /stdole2\.idl$/) { push @tlb_srcs, $incl; } | |
643 | elsif ($private_idl_headers{$incl}) { push @h_srcs, $incl; } | |
644 | elsif ($incl =~ /\.h$/) { push @h_srcs, $incl; } | |
645 | elsif ($incl =~ /\.inl$/) { push @h_srcs, $incl; } | |
646 | elsif ($incl =~ /\.idl$/) { push @idl_srcs, $incl; } | |
647 | } | |
648 | replace_in_file( "include/Makefile.in", '^IDL_H_SRCS\s*=', '^INSTALLDIRS', | |
649 | "IDL_H_SRCS = \\\n\t", | |
650 | join( " \\\n\t", sort @idl_srcs ), | |
651 | "\n\nIDL_TLB_SRCS = \\\n\t", | |
652 | join( " \\\n\t", sort @tlb_srcs ), | |
653 | "\n\nSRCDIR_INCLUDES = \\\n\t\$(IDL_TLB_SRCS) \\\n\t\$(IDL_H_SRCS) \\\n\t", | |
654 | join( " \\\n\t", sort @h_srcs ), | |
655 | "\n\nEXTRASUBDIRS = ", | |
656 | join( " ", sort keys %subdirs ), | |
657 | "\n\nINSTALLDIRS = \\\n" ); | |
658 | } | |
659 | ||
660 | ||
7035aa50 AJ |
661 | ################################################################ |
662 | # update the main .gitignore | |
663 | ||
6150fe19 | 664 | sub update_gitignore(@) |
7035aa50 | 665 | { |
6150fe19 | 666 | my @ignores = values %makerules; |
7035aa50 AJ |
667 | |
668 | foreach my $make (@makefiles) | |
669 | { | |
670 | my %makefile = %{$makefiles{$make}}; | |
671 | my $dir = $makefile{"=dir"}; | |
672 | if (defined $makefile{"MANPAGES"}) | |
673 | { | |
674 | push @ignores, map { $dir . $_; } @{$makefile{"MANPAGES"}}; | |
675 | } | |
676 | if (defined $makefile{"PROGRAMS"}) | |
677 | { | |
678 | push @ignores, map { s/\$\(EXEEXT\)//; $dir . $_; } @{$makefile{"PROGRAMS"}}; | |
679 | } | |
680 | } | |
681 | ||
682 | # prepend a slash to paths that don't have one | |
683 | @ignores = map { $_ =~ s/^([^\/]+)$/\/$1/; $_; } @ignores; | |
684 | ||
74bd17e9 AJ |
685 | # get rid of duplicates |
686 | my %ignores = (); | |
687 | foreach my $i (@ignores, @_) { $ignores{$i} = 1; } | |
6150fe19 AJ |
688 | |
689 | replace_in_file( ".gitignore", undef, undef, | |
690 | "# Automatically generated by make_makefiles; DO NOT EDIT!!\n", | |
74bd17e9 | 691 | join("\n", sort keys %ignores), "\n" ); |
7035aa50 AJ |
692 | } |
693 | ||
694 | ||
ac91ffd7 AJ |
695 | if (-d ".git") |
696 | { | |
697 | @makefiles = map { s/\.in$//; $_; } split /\0/, `git ls-files -c -z Makefile.in \\*/Makefile.in`; | |
698 | } | |
699 | else | |
700 | { | |
701 | @makefiles = map { s/^\.\/(.*)\.in/$1/; $_; } split(/\s/,`find . -name Makefile.in -print`); | |
702 | } | |
703 | ||
704 | update_includes(); | |
705 | ||
706 | foreach my $file (sort values %makerules, @makefiles) | |
707 | { | |
708 | my %make = parse_makefile( $file ); | |
709 | $makefiles{$file} = \%make; | |
710 | } | |
711 | ||
5eb38cf9 AJ |
712 | update_makefiles( @makefiles ); |
713 | push @ignores, update_ignores( @makefiles ); | |
6150fe19 AJ |
714 | push @ignores, update_winetest( @makefiles ); |
715 | push @ignores, update_dlls( sort grep /^dlls\//, @makefiles ); | |
716 | push @ignores, update_progs( sort grep /^programs\/.*\/Makefile$/, @makefiles ); | |
717 | update_gitignore( @ignores ); |