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", | |
65 | "wined3d" => "OPENGLFILES", | |
66 | "winex11.drv" => "XFILES", | |
67 | "winequartz.drv" => "QUARTZFILES" | |
68 | ); | |
69 | ||
6150fe19 AJ |
70 | # Default patterns for top-level .gitignore |
71 | my @ignores = ( | |
72 | "*.[oa]", | |
6150fe19 | 73 | "*.so", |
6150fe19 AJ |
74 | "/autom4te.cache", |
75 | "/config.cache", | |
76 | "/config.log", | |
77 | "/config.status", | |
78 | "/TAGS", | |
79 | "/tags", | |
7d659398 AJ |
80 | "Makefile", |
81 | "include/config.h", | |
82 | "include/stamp-h" | |
6150fe19 AJ |
83 | ); |
84 | ||
5eb38cf9 AJ |
85 | # Source files and their resulting target to ignore |
86 | my @ignore_srcs = ( | |
87 | [ 'BISON_SRCS', '\.y', '.tab.c' ], | |
88 | [ 'BISON_SRCS', '\.y', '.tab.h' ], | |
89 | [ 'LEX_SRCS', '\.l', '.yy.c' ], | |
90 | [ 'MC_SRCS', '\.mc', '.mc.rc' ], | |
91 | [ 'RC_SRCS', '\.rc', '.res' ], | |
92 | [ 'RC_SRCS16', '\.rc', '.res' ], | |
93 | [ 'IDL_TLB_SRCS', '\.idl', '.tlb' ], | |
8c875111 | 94 | [ 'IDL_H_SRCS', '\.idl', '.h' ], |
1df72cc7 AJ |
95 | [ 'IDL_C_SRCS', '\.idl', '.h' ], |
96 | [ 'IDL_I_SRCS', '\.idl', '.h' ], | |
97 | [ 'IDL_P_SRCS', '\.idl', '.h' ], | |
98 | [ 'IDL_S_SRCS', '\.idl', '.h' ], | |
5eb38cf9 AJ |
99 | [ 'IDL_C_SRCS', '\.idl', '_c.c' ], |
100 | [ 'IDL_I_SRCS', '\.idl', '_i.c' ], | |
101 | [ 'IDL_P_SRCS', '\.idl', '_p.c' ], | |
102 | [ 'IDL_S_SRCS', '\.idl', '_s.c' ], | |
103 | ); | |
104 | ||
44db04c0 AJ |
105 | my (@makefiles, %makefiles); |
106 | ||
34618113 AJ |
107 | # update a file if changed |
108 | sub update_file($) | |
109 | { | |
110 | my $file = shift; | |
8c875111 | 111 | my $ret = !(-f $file) || system "cmp $file $file.new >/dev/null"; |
34618113 AJ |
112 | if (!$ret) |
113 | { | |
114 | unlink "$file.new"; | |
34618113 AJ |
115 | } |
116 | else | |
117 | { | |
118 | rename "$file.new", "$file"; | |
119 | print "$file updated\n"; | |
7035aa50 AJ |
120 | if ($file eq "configure.ac") |
121 | { | |
122 | system "autoconf"; | |
123 | print "configure updated\n"; | |
124 | } | |
34618113 AJ |
125 | } |
126 | return $ret; | |
127 | } | |
128 | ||
129 | # replace some lines in a file between two markers | |
130 | sub replace_in_file($$$@) | |
131 | { | |
132 | my $file = shift; | |
133 | my $start = shift; | |
134 | my $end = shift; | |
135 | ||
34618113 AJ |
136 | open NEW_FILE, ">$file.new" or die "cannot create $file.new"; |
137 | ||
48c14238 | 138 | if (defined($start)) |
34618113 | 139 | { |
48c14238 AJ |
140 | open OLD_FILE, "$file" or die "cannot open $file"; |
141 | while (<OLD_FILE>) | |
142 | { | |
143 | last if /$start/; | |
144 | print NEW_FILE $_; | |
145 | } | |
34618113 AJ |
146 | } |
147 | ||
148 | print NEW_FILE @_; | |
149 | ||
150 | if (defined($end)) | |
151 | { | |
152 | my $skip=1; | |
153 | while (<OLD_FILE>) | |
154 | { | |
155 | print NEW_FILE $_ unless $skip; | |
156 | $skip = 0 if /$end/; | |
157 | } | |
158 | } | |
159 | ||
48c14238 | 160 | close OLD_FILE if defined($start); |
34618113 AJ |
161 | close NEW_FILE; |
162 | return update_file($file); | |
163 | } | |
164 | ||
44db04c0 AJ |
165 | # parse the specified makefile to identify the rules file |
166 | sub parse_makefile($) | |
167 | { | |
168 | my $file = shift; | |
48c14238 | 169 | my %make; |
44db04c0 | 170 | |
7035aa50 AJ |
171 | ($make{"=dir"} = $file) =~ s/[^\/]+$//; |
172 | ||
44db04c0 AJ |
173 | open MAKE, "$file.in" or die "cannot open $file.in\n"; |
174 | ||
175 | while (<MAKE>) | |
176 | { | |
177 | chomp; | |
178 | while (/\\$/) { chop; $_ .= <MAKE>; chomp; } # merge continued lines | |
179 | ||
180 | if (/^\@(MAKE.*RULES)\@/) | |
181 | { | |
182 | my $var = $1; | |
48c14238 AJ |
183 | $make{"=rules"} = $makerules{$var}; |
184 | next; | |
185 | } | |
8ef6b39c | 186 | if (/^(MODULE|IMPORTLIB|TESTDLL)\s*=\s*(.*)/) |
48c14238 | 187 | { |
0134db6e | 188 | $make{$1} = $2; |
48c14238 AJ |
189 | next; |
190 | } | |
5eb38cf9 | 191 | 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 |
192 | { |
193 | my @list = split(/\s+/, $2); | |
194 | $make{$1} = \@list; | |
195 | next; | |
196 | } | |
48c14238 AJ |
197 | if (/^\#\s*MKDLL_SKIP/ || /^\#\s*MKPROG_SKIP/) |
198 | { | |
199 | $make{"=skip"} = 1; | |
200 | next; | |
44db04c0 AJ |
201 | } |
202 | } | |
48c14238 | 203 | return %make; |
44db04c0 | 204 | } |
34618113 AJ |
205 | |
206 | if (-d ".git") | |
207 | { | |
208 | @makefiles = map { s/\.in$//; $_; } split /\s/, `git ls-files -c Makefile.in \\*/Makefile.in`; | |
34618113 AJ |
209 | } |
210 | else | |
211 | { | |
212 | @makefiles = map { s/^\.\/(.*)\.in/$1/; $_; } split(/\s/,`find . -name Makefile.in -print`); | |
34618113 AJ |
213 | } |
214 | ||
44db04c0 AJ |
215 | foreach my $file (sort values %makerules, @makefiles) |
216 | { | |
48c14238 AJ |
217 | my %make = parse_makefile( $file ); |
218 | $makefiles{$file} = \%make; | |
44db04c0 | 219 | } |
34618113 AJ |
220 | |
221 | ################################################################ | |
222 | # update the makefile list in configure.ac | |
223 | ||
44db04c0 AJ |
224 | my @lines = (); |
225 | ||
226 | foreach my $var (sort { $makerules{$a} cmp $makerules{$b}; } keys %makerules) | |
227 | { | |
228 | push @lines, "$var=$makerules{$var}\n"; | |
229 | push @lines, "AC_SUBST_FILE($var)\n\n"; | |
230 | } | |
231 | ||
fbc80d79 MM |
232 | foreach my $var ((sort values %makerules), (sort @makefiles)) |
233 | { | |
234 | push @lines, "AC_CONFIG_FILES([$var])\n"; | |
235 | } | |
236 | ||
237 | push @lines, "\nAC_OUTPUT\n"; | |
238 | ||
239 | replace_in_file( "configure.ac", '^MAKE_RULES', '^AC_OUTPUT$', @lines); | |
34618113 AJ |
240 | |
241 | ||
27959beb | 242 | ################################################################ |
534fac98 | 243 | # update the tests list in programs/winetest/Makefile.in and programs/winetest/winetest.rc |
27959beb | 244 | |
6150fe19 | 245 | sub update_winetest(@) |
27959beb | 246 | { |
6150fe19 AJ |
247 | my (@tests, @lines); |
248 | ||
249 | foreach my $file (@_) | |
27959beb | 250 | { |
6150fe19 | 251 | if ($file =~ /^dlls\/(.*)\/tests\/Makefile/) { push @tests, $1; } |
27959beb | 252 | } |
6150fe19 AJ |
253 | push @lines, "TESTBINS ="; |
254 | push @lines, map { " \\\n\t" . $_ . "_test.exe"; } sort @tests; | |
255 | push @lines, "\n\n"; | |
27959beb | 256 | |
6150fe19 AJ |
257 | foreach my $test (sort @tests) |
258 | { | |
259 | push @lines, "${test}_test.exe: \$(DLLDIR)/$test/tests/${test}_test.exe\$(DLLEXT)\n"; | |
260 | push @lines, "\tcp \$(DLLDIR)/$test/tests/${test}_test.exe\$(DLLEXT) \$\@ && \$(STRIP) \$\@\n"; | |
261 | } | |
262 | push @lines, "\n# Special rules\n"; | |
27959beb | 263 | |
6150fe19 | 264 | replace_in_file( "programs/winetest/Makefile.in", '^TESTBINS\s*=', '^# Special rules', @lines ); |
27959beb | 265 | |
6150fe19 AJ |
266 | replace_in_file( "programs/winetest/winetest.rc", ' TESTRES ', undef, |
267 | map { $_ . "_test.exe TESTRES \"" . $_ . "_test.exe\"\n"; } sort @tests ); | |
268 | ||
269 | # return a list of test exe files for .gitignore | |
270 | return map { "programs/winetest/" . $_ . "_test.exe"; } sort @tests; | |
534fac98 AJ |
271 | } |
272 | ||
27959beb | 273 | |
5ea4e5ba AJ |
274 | ################################################################ |
275 | # update the makefile list in Makefile.in | |
276 | ||
5eb38cf9 | 277 | sub update_makefiles(@) |
5ea4e5ba | 278 | { |
5eb38cf9 AJ |
279 | my (@targets, @depends); |
280 | ||
281 | foreach my $file (sort values %makerules) | |
282 | { | |
283 | push @targets, $file; | |
284 | my %make = %{$makefiles{$file}}; | |
285 | if (!defined($make{"=rules"})) { push @depends, "$file: $file.in"; } | |
286 | else { push @depends, "$file: $file.in Make.rules"; } | |
287 | } | |
288 | ||
289 | foreach my $file (sort @_) | |
290 | { | |
291 | push @targets, $file unless $file eq "Makefile"; | |
292 | my %makefile = %{$makefiles{$file}}; | |
293 | my $dep = $makefile{"=rules"}; | |
294 | push @depends, "$file: $file.in $dep"; | |
295 | } | |
296 | ||
297 | ||
298 | @lines = (); | |
299 | push @lines, "ALL_MAKEFILES = \\\n\t"; | |
300 | push @lines, join (" \\\n\t", @targets ), "\n\n"; | |
301 | push @lines, "Makefile \$(ALL_MAKEFILES): config.status\n"; | |
274115f9 AJ |
302 | push @lines, "\t\@./config.status \$\@\n"; |
303 | push @lines, ".INIT: Makefile\n"; | |
304 | push @lines, ".BEGIN: Makefile\n\n"; | |
5eb38cf9 AJ |
305 | push @lines, "\$(RECURSE_TARGETS) \$(MAKEDEP): \$(ALL_MAKEFILES)\n\n"; |
306 | push @lines, "distclean::\n"; | |
307 | push @lines, "\t\$(RM) Makefile \$(ALL_MAKEFILES)\n\n"; | |
308 | push @lines, join ("\n", @depends ), "\n"; | |
309 | ||
310 | replace_in_file( "Makefile.in", '^ALL_MAKEFILES\s*=', undef, @lines ); | |
5ea4e5ba AJ |
311 | } |
312 | ||
5eb38cf9 AJ |
313 | |
314 | ################################################################ | |
315 | # process ignore targets for generic source files | |
316 | ||
317 | sub update_ignores(@) | |
5ea4e5ba | 318 | { |
5eb38cf9 | 319 | my @ignores; |
5ea4e5ba | 320 | |
5eb38cf9 AJ |
321 | foreach my $file (sort @_) |
322 | { | |
323 | my %makefile = %{$makefiles{$file}}; | |
324 | my @list; | |
5ea4e5ba | 325 | |
5eb38cf9 AJ |
326 | foreach my $src (@ignore_srcs) |
327 | { | |
328 | my @pattern = @{$src}; | |
329 | next unless defined $makefile{$pattern[0]}; | |
330 | push @list, map { (my $ret = $_) =~ s/$pattern[1]$/$pattern[2]/; $ret; } @{$makefile{$pattern[0]}}; | |
331 | } | |
332 | push @list, @{$makefile{"RC_BINARIES"}} if defined $makefile{"RC_BINARIES"}; | |
8c875111 AJ |
333 | foreach my $f (@list) |
334 | { | |
335 | push @ignores, $makefile{"=dir"} . $f unless $f =~ /\$\(.*\)/; # skip make variables | |
336 | } | |
5eb38cf9 AJ |
337 | } |
338 | return @ignores; | |
339 | } | |
5ea4e5ba | 340 | |
34618113 AJ |
341 | ################################################################ |
342 | # update dlls/Makefile.in | |
343 | ||
0134db6e AJ |
344 | sub update_dlls(@) |
345 | { | |
346 | my (%directories, %testdirs, %importlibs, %static_implibs, %staticlib_dirs, %altnames); | |
347 | my $text = ""; | |
bb7f2f9c | 348 | my @ignores = (); |
0134db6e | 349 | |
0134db6e AJ |
350 | foreach my $make (@_) |
351 | { | |
bb7f2f9c | 352 | my %makefile = %{$makefiles{$make}}; |
d44ed08d | 353 | next if defined $makefile{"=skip"}; |
bb7f2f9c | 354 | |
0134db6e AJ |
355 | if ($make =~ /dlls\/(.*)\/tests\/Makefile/) |
356 | { | |
8ef6b39c PS |
357 | $testdirs{$1} = "$1/tests"; |
358 | (my $crosstest = $makefile{"TESTDLL"}) =~ s/\.dll$//; | |
359 | push @ignores, $makefile{"=dir"} . $crosstest . "_crosstest.exe"; | |
bb7f2f9c AJ |
360 | push @ignores, $makefile{"=dir"} . "testlist.c"; |
361 | push @ignores, $makefile{"=dir"} . "*.ok"; | |
0134db6e AJ |
362 | next; |
363 | } | |
0134db6e AJ |
364 | |
365 | next unless defined $makefile{"MODULE"}; | |
366 | my $module = $makefile{"MODULE"}; | |
05ef63e8 | 367 | (my $dir = $makefile{"=dir"}) =~ s/^dlls\/(.*)\//$1/; |
0134db6e AJ |
368 | |
369 | if ($module =~ /^lib.*\.a$/) | |
370 | { | |
365a463b | 371 | $staticlib_dirs{$module} = $dir; |
0134db6e AJ |
372 | die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module; |
373 | } | |
374 | else | |
375 | { | |
05ef63e8 AJ |
376 | (my $mod = $module) =~ s/\.dll$//; |
377 | die "invalid directory $dir for module $module\n" unless $mod eq $dir; | |
365a463b | 378 | $directories{$module} = $dir; |
0134db6e AJ |
379 | } |
380 | ||
381 | if (defined $makefile{"IMPORTLIB"}) | |
382 | { | |
383 | if ($makefile{"IMPORTLIB"} =~ /^([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/) | |
384 | { | |
385 | $importlibs{$module} = $1; | |
386 | } | |
387 | else | |
388 | { | |
389 | die "invalid importlib name $makefile{IMPORTLIB} in $make"; | |
390 | } | |
391 | } | |
392 | ||
393 | $static_implibs{$module} = 1 if defined $makefile{"IMPLIB_SRCS"}; | |
394 | ||
395 | if (defined $makefile{"SPEC_SRCS16"}) | |
396 | { | |
365a463b | 397 | my @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @{$makefile{"SPEC_SRCS16"}}; |
0134db6e AJ |
398 | $altnames{$module} = \@list; |
399 | } | |
400 | } | |
401 | ||
402 | # output special dlls configure definitions | |
403 | ||
404 | $text .= "# special configure-dependent targets\n\n"; | |
405 | my %specials = (); | |
406 | foreach my $mod (sort keys %special_dlls) | |
407 | { | |
408 | $specials{$special_dlls{$mod}} .= " " . $mod; | |
409 | } | |
410 | foreach my $i (sort keys %specials) | |
411 | { | |
412 | $text .= $i . " =" . $specials{$i} . "\n"; | |
413 | } | |
414 | $text .= "EXTRADIRS ="; | |
415 | foreach my $i (sort keys %specials) { $text .= sprintf " \@%s\@", $i; } | |
416 | $text .= "\n\n"; | |
417 | ||
418 | # output the subdirs list | |
419 | ||
420 | $text .= "# Subdir list\n\n"; | |
421 | $text .= "BASEDIRS ="; | |
422 | foreach my $dir (sort values %directories) | |
423 | { | |
424 | next if defined($special_dlls{$dir}); # skip special dlls | |
425 | $text .= " \\\n\t" . $dir; | |
426 | } | |
427 | ||
428 | $text .= "\n\nIMPLIBSUBDIRS = \\\n\t"; | |
429 | $text .= join " \\\n\t", sort values %staticlib_dirs; | |
430 | ||
431 | $text .= "\n\nTESTSUBDIRS = \\\n\t"; | |
432 | $text .= join " \\\n\t", sort values %testdirs; | |
433 | ||
434 | $text .= "\n\nSUBDIRS = \\\n\t"; | |
435 | $text .= join " \\\n\t", "\$(BASEDIRS)", "\$(IMPLIBSUBDIRS)", "\$(TESTSUBDIRS)", sort keys %special_dlls; | |
436 | ||
437 | $text .= "\n\nBUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(TESTSUBDIRS)\n"; | |
438 | $text .= "INSTALLSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(IMPLIBSUBDIRS)\n"; | |
439 | $text .= "DOCSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)\n"; | |
440 | ||
05ef63e8 | 441 | # output the list of 16-bit files |
0134db6e | 442 | |
05ef63e8 | 443 | my @targets16 = (); |
0134db6e AJ |
444 | foreach my $mod (sort keys %directories) |
445 | { | |
0134db6e AJ |
446 | next unless defined $altnames{$mod}; |
447 | foreach my $i (sort @{$altnames{$mod}}) | |
448 | { | |
05ef63e8 | 449 | push @targets16, $i . "16"; |
0134db6e AJ |
450 | } |
451 | } | |
05ef63e8 | 452 | $text .= "\n# 16-bit dlls\n\n"; |
0134db6e | 453 | $text .= "WIN16_FILES = \\\n"; |
05ef63e8 AJ |
454 | $text .= "\t" . join( " \\\n\t", sort @targets16 ) . "\n\n"; |
455 | $text .= "\@MAKE_RULES\@\n\n"; | |
456 | ||
457 | # output the all: target | |
458 | ||
0134db6e | 459 | $text .= "# Main target\n\n"; |
05ef63e8 | 460 | $text .= "all: \$(BUILDSUBDIRS) \@WIN16_FILES\@\n\n"; |
0134db6e AJ |
461 | |
462 | # output the lib name -> directory rules | |
463 | ||
0134db6e AJ |
464 | $text .= "# Placeholders for 16-bit libraries\n\n"; |
465 | foreach my $mod (sort keys %directories) | |
466 | { | |
467 | next unless defined $altnames{$mod}; | |
468 | $text .= sprintf "%s:\n", join(" ", map { $_ . "16"; } sort @{$altnames{$mod}}); | |
469 | $text .= sprintf "\techo \"%s\" >\$\@\n\n", $mod; | |
470 | } | |
471 | ||
472 | # output the import libraries rules | |
473 | ||
474 | $text .= "# Import libraries\n\n"; | |
475 | $text .= "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n"; | |
476 | ||
477 | my @lib_symlinks = (); | |
478 | foreach my $mod (sort keys %importlibs) | |
479 | { | |
480 | my $dir = $directories{$mod}; | |
481 | my $lib = $importlibs{$mod}; | |
482 | if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; } | |
483 | } | |
484 | $text .= "IMPORT_SYMLINKS ="; | |
485 | foreach my $mod (sort @lib_symlinks) | |
486 | { | |
487 | $text .= sprintf " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod}; | |
488 | } | |
489 | ||
490 | $text .= "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)"; | |
491 | foreach my $mod (sort keys %staticlib_dirs) | |
492 | { | |
493 | $text .= sprintf " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod; | |
494 | } | |
495 | foreach my $mod (sort keys %importlibs) | |
496 | { | |
497 | my $dir = $directories{$mod}; | |
498 | my $def = $mod; | |
499 | $def =~ s/\.(dll|drv)$//; | |
500 | $text .= sprintf " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def; | |
501 | next unless defined $static_implibs{$mod}; | |
502 | $text .= sprintf " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def | |
503 | } | |
504 | $text .= "\n\n"; | |
505 | $text .= "implib: \$(IMPORT_LIBS)\n\n"; | |
05ef63e8 | 506 | $text .= ".PHONY: implib\n\n"; |
0134db6e AJ |
507 | |
508 | foreach my $mod (sort keys %importlibs) | |
509 | { | |
510 | my $dir = $directories{$mod}; | |
511 | my $lib = $importlibs{$mod}; | |
512 | my $spec = $mod; | |
513 | $spec =~ s/\.dll$//; | |
514 | $text .= sprintf "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec; | |
515 | $text .= sprintf "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib; | |
516 | next unless $static_implibs{$mod}; | |
517 | $text .= sprintf "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec; | |
518 | $text .= sprintf "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib; | |
519 | } | |
520 | foreach my $mod (sort @lib_symlinks) | |
521 | { | |
522 | my $dir = $directories{$mod}; | |
523 | my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)"; | |
524 | $text .= sprintf "%s: %s/%s\n", $lib, $dir, $lib; | |
525 | $text .= sprintf "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib; | |
526 | } | |
527 | ||
528 | $text .= "\$(BUILDSUBDIRS): \$(IMPORT_LIBS)\n"; | |
529 | $text .= "\$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)\n\n"; | |
530 | ||
531 | # output the inter-dll dependencies and rules | |
532 | ||
533 | $text .= "# Map library name to the corresponding directory\n\n"; | |
534 | ||
0134db6e AJ |
535 | foreach my $mod (sort keys %staticlib_dirs) |
536 | { | |
537 | $text .= sprintf "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod}; | |
538 | } | |
539 | $text .= "\n# Misc rules\n"; | |
540 | ||
541 | replace_in_file( "dlls/Makefile.in", | |
542 | '^# special configure-dependent targets', | |
543 | '^# Misc rules', | |
544 | $text ); | |
545 | ||
546 | # .gitignore file | |
547 | ||
548 | foreach my $mod (sort @lib_symlinks) | |
549 | { | |
6150fe19 | 550 | push @ignores, "dlls/$importlibs{$mod}.def"; |
0134db6e AJ |
551 | } |
552 | foreach my $mod (sort keys %directories) | |
553 | { | |
554 | next unless defined $altnames{$mod}; | |
6150fe19 | 555 | push @ignores, map { "dlls/" . $_ . "16"; } @{$altnames{$mod}}; |
0134db6e AJ |
556 | } |
557 | foreach my $mod (sort keys %importlibs) | |
558 | { | |
559 | my $dir = $directories{$mod}; | |
560 | my $def = $mod; | |
561 | $def =~ s/\.(dll|drv)$//; | |
6150fe19 | 562 | push @ignores, "dlls/$dir/lib$def.def"; |
0134db6e AJ |
563 | } |
564 | ||
6150fe19 | 565 | return @ignores; |
0134db6e AJ |
566 | } |
567 | ||
34618113 | 568 | |
34618113 | 569 | ################################################################ |
6150fe19 | 570 | # update programs/Makefile.in |
48c14238 AJ |
571 | |
572 | sub update_progs(@) | |
573 | { | |
574 | my (@subdirs, @install_subdirs, @install_progs); | |
575 | ||
7035aa50 | 576 | my @ignores = (); |
48c14238 AJ |
577 | |
578 | foreach my $make (@_) | |
579 | { | |
580 | my %makefile = %{$makefiles{$make}}; | |
581 | my $module = $makefile{"MODULE"}; | |
582 | (my $dir = $make) =~ s/^programs\/(.*)\/Makefile$/$1/; | |
583 | die "Invalid module $module in $make" unless "$dir.exe" eq $module; | |
584 | next if defined $makefile{"=skip"}; | |
585 | push @subdirs, $dir; | |
6150fe19 | 586 | push @ignores, "programs/$dir/$dir"; |
48c14238 AJ |
587 | push @install_subdirs, $dir unless $dont_install{$dir}; |
588 | push @install_progs, $dir if $bin_install{$dir}; | |
589 | } | |
590 | ||
591 | replace_in_file( "programs/Makefile.in", '^SUBDIRS\s*=', '^INSTALLDIRS', | |
592 | "SUBDIRS = \\\n\t", | |
593 | join( " \\\n\t", @subdirs ), | |
594 | "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS = \\\n\t", | |
595 | join( " \\\n\t", @install_subdirs ), | |
596 | "\n\n# Programs to install in bin directory\nINSTALLPROGS = \\\n\t", | |
597 | join( " \\\n\t", @install_progs ), | |
598 | "\n\nINSTALLDIRS = \$(DESTDIR)\$(bindir)\n" ); | |
599 | ||
6150fe19 | 600 | return @ignores; |
48c14238 | 601 | } |
34618113 | 602 | |
7035aa50 AJ |
603 | |
604 | ################################################################ | |
605 | # update the main .gitignore | |
606 | ||
6150fe19 | 607 | sub update_gitignore(@) |
7035aa50 | 608 | { |
6150fe19 | 609 | my @ignores = values %makerules; |
7035aa50 AJ |
610 | |
611 | foreach my $make (@makefiles) | |
612 | { | |
613 | my %makefile = %{$makefiles{$make}}; | |
614 | my $dir = $makefile{"=dir"}; | |
615 | if (defined $makefile{"MANPAGES"}) | |
616 | { | |
617 | push @ignores, map { $dir . $_; } @{$makefile{"MANPAGES"}}; | |
618 | } | |
619 | if (defined $makefile{"PROGRAMS"}) | |
620 | { | |
621 | push @ignores, map { s/\$\(EXEEXT\)//; $dir . $_; } @{$makefile{"PROGRAMS"}}; | |
622 | } | |
623 | } | |
624 | ||
625 | # prepend a slash to paths that don't have one | |
626 | @ignores = map { $_ =~ s/^([^\/]+)$/\/$1/; $_; } @ignores; | |
627 | ||
74bd17e9 AJ |
628 | # get rid of duplicates |
629 | my %ignores = (); | |
630 | foreach my $i (@ignores, @_) { $ignores{$i} = 1; } | |
6150fe19 AJ |
631 | |
632 | replace_in_file( ".gitignore", undef, undef, | |
633 | "# Automatically generated by make_makefiles; DO NOT EDIT!!\n", | |
74bd17e9 | 634 | join("\n", sort keys %ignores), "\n" ); |
7035aa50 AJ |
635 | } |
636 | ||
637 | ||
5eb38cf9 AJ |
638 | update_makefiles( @makefiles ); |
639 | push @ignores, update_ignores( @makefiles ); | |
6150fe19 AJ |
640 | push @ignores, update_winetest( @makefiles ); |
641 | push @ignores, update_dlls( sort grep /^dlls\//, @makefiles ); | |
642 | push @ignores, update_progs( sort grep /^programs\/.*\/Makefile$/, @makefiles ); | |
643 | update_gitignore( @ignores ); |