Commit | Line | Data |
---|---|---|
f33f7f0e | 1 | #!/usr/bin/perl -w |
7c3dec92 AJ |
2 | # |
3 | # Update the dll dependencies in the dlls main Makefile.in. | |
4 | # Must be run in the dlls/ directory of the Wine tree. | |
5 | # | |
6 | # Copyright 2001 Alexandre Julliard | |
7 | # | |
0799c1a7 AJ |
8 | # This library is free software; you can redistribute it and/or |
9 | # modify it under the terms of the GNU Lesser General Public | |
10 | # License as published by the Free Software Foundation; either | |
11 | # version 2.1 of the License, or (at your option) any later version. | |
12 | # | |
13 | # This library is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | # Lesser General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU Lesser General Public | |
19 | # License along with this library; if not, write to the Free Software | |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | # | |
7c3dec92 | 22 | |
c0d955e8 | 23 | use strict; |
7c3dec92 | 24 | |
c0d955e8 EP |
25 | my $makefiles = `find . -name Makefile.in -print`; |
26 | ||
c0d955e8 | 27 | my %directories = (); |
15ac6847 AJ |
28 | my %importlibs = (); |
29 | my %static_implibs = (); | |
30 | my %staticlib_dirs = (); | |
c0d955e8 | 31 | my %altnames = (); |
7c3dec92 | 32 | |
f33f7f0e | 33 | # list of special dlls that can be switched on or off by configure |
c0d955e8 | 34 | my %special_dlls = |
f33f7f0e AJ |
35 | ( |
36 | "ddraw" => "XFILES", | |
37 | "glu32" => "GLU32FILES", | |
ef799c46 | 38 | "glut32" => "GLUT32FILES", |
f33f7f0e | 39 | "opengl32" => "OPENGLFILES", |
7cbb340a | 40 | "d3d8" => "OPENGLFILES", |
aa1bdc42 | 41 | "d3d9" => "OPENGLFILES", |
e31ae926 | 42 | "d3dx8" => "OPENGLFILES", |
01968613 | 43 | "wined3d" => "OPENGLFILES", |
f33f7f0e AJ |
44 | "x11drv" => "XFILES" |
45 | ); | |
46 | ||
c0d955e8 | 47 | foreach my $i (split(/\s/,$makefiles)) |
7c3dec92 | 48 | { |
c0d955e8 EP |
49 | my $module; |
50 | ||
edeee89c AJ |
51 | next if $i =~ /\/tests\/Makefile.in/; |
52 | ||
7c3dec92 | 53 | open MAKE,$i; |
c0d955e8 EP |
54 | |
55 | $module = undef; | |
7c3dec92 AJ |
56 | while (<MAKE>) |
57 | { | |
58 | chop; | |
c0d955e8 EP |
59 | # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear |
60 | # at the very top of the Makefile.in | |
61 | last if (/^\#\s*MKDLL_SKIP/); | |
62 | ||
7c3dec92 AJ |
63 | if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/) |
64 | { | |
65 | $module = $1; | |
c3eac438 AJ |
66 | if ($module =~ /^lib.*\.a$/) |
67 | { | |
15ac6847 | 68 | ($staticlib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/; |
c3eac438 AJ |
69 | } |
70 | else | |
71 | { | |
72 | ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/; | |
73 | } | |
7c3dec92 AJ |
74 | next; |
75 | } | |
15ac6847 AJ |
76 | if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/) |
77 | { | |
78 | $importlibs{$module} = $1; | |
79 | next; | |
80 | } | |
81 | if (/^IMPLIB_SRCS\s*=/) | |
82 | { | |
83 | $static_implibs{$module} = 1; | |
84 | next; | |
85 | } | |
8be0edb9 | 86 | if (/^SPEC_SRCS16\s*=\s*(.*)/) |
7c3dec92 | 87 | { |
8be0edb9 AJ |
88 | my $specs = $1; |
89 | while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; } | |
90 | my @list = split(/\s+/,$specs); | |
91 | @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list; | |
7c3dec92 AJ |
92 | $altnames{$module} = \@list; |
93 | next; | |
94 | } | |
7c3dec92 | 95 | } |
c0d955e8 | 96 | close MAKE; |
7c3dec92 AJ |
97 | } |
98 | ||
7c3dec92 AJ |
99 | open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new"; |
100 | ||
f33f7f0e AJ |
101 | ################################################################ |
102 | # makefile header | |
103 | ||
104 | print NEWMAKE <<EOF; | |
105 | # Automatically generated by make_dlls; DO NOT EDIT!! | |
106 | ||
107 | TOPSRCDIR = \@top_srcdir\@ | |
108 | TOPOBJDIR = .. | |
109 | SRCDIR = \@srcdir\@ | |
110 | VPATH = \@srcdir\@ | |
f33f7f0e AJ |
111 | |
112 | EOF | |
113 | ||
114 | ################################################################ | |
115 | # output special dlls configure definitions | |
116 | ||
117 | printf NEWMAKE "# special configure-dependent targets\n\n"; | |
118 | my %specials = (); | |
c0d955e8 | 119 | foreach my $mod (sort keys %special_dlls) |
7c3dec92 | 120 | { |
f33f7f0e | 121 | $specials{$special_dlls{$mod}} .= " " . $mod; |
7c3dec92 | 122 | } |
c0d955e8 | 123 | foreach my $i (sort keys %specials) |
7c3dec92 | 124 | { |
f33f7f0e | 125 | printf NEWMAKE "%s =%s\n", $i, $specials{$i}; |
7c3dec92 | 126 | } |
f33f7f0e | 127 | printf NEWMAKE "EXTRADIRS ="; |
c0d955e8 | 128 | foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; } |
f33f7f0e AJ |
129 | printf NEWMAKE "\n\n"; |
130 | ||
131 | ||
132 | ################################################################ | |
133 | # output the subdirs list | |
7c3dec92 | 134 | |
5852f7a1 | 135 | print NEWMAKE "# Subdir list\n\nBASEDIRS ="; |
c0d955e8 | 136 | foreach my $dir (sort values %directories) |
7c3dec92 | 137 | { |
f33f7f0e | 138 | next if defined($special_dlls{$dir}); # skip special dlls |
7c3dec92 AJ |
139 | printf NEWMAKE " \\\n\t%s", $dir; |
140 | } | |
7c3dec92 | 141 | |
5852f7a1 | 142 | printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)"; |
15ac6847 | 143 | foreach my $dir (sort (keys %special_dlls, values %staticlib_dirs)) |
5852f7a1 AJ |
144 | { |
145 | printf NEWMAKE " \\\n\t%s", $dir; | |
146 | } | |
147 | printf NEWMAKE <<EOF; | |
148 | ||
149 | ||
150 | BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) | |
f673b71e AJ |
151 | |
152 | INSTALLSUBDIRS = \$(BUILDSUBDIRS) | |
5852f7a1 | 153 | EOF |
f33f7f0e AJ |
154 | |
155 | ################################################################ | |
156 | # output the all: target | |
157 | ||
158 | my %targets = (); # use a hash to get rid of duplicate target names | |
c728efc3 | 159 | my %targets16 = (); |
c0d955e8 | 160 | foreach my $mod (sort keys %directories) |
f33f7f0e | 161 | { |
c1bfca04 | 162 | next if defined($special_dlls{$directories{$mod}}); # skip special dlls |
c2fbb406 | 163 | $targets{$mod . ".so"} = 1; |
f33f7f0e | 164 | next unless defined $altnames{$mod}; |
c0d955e8 | 165 | foreach my $i (sort @{$altnames{$mod}}) |
f33f7f0e | 166 | { |
c2fbb406 | 167 | $targets16{sprintf("%s.so",$i)} = 1; |
f33f7f0e AJ |
168 | } |
169 | } | |
15ac6847 | 170 | foreach my $mod (sort keys %staticlib_dirs) { $targets{$mod} = 1; } |
c3eac438 | 171 | |
f33f7f0e AJ |
172 | print NEWMAKE <<EOF; |
173 | ||
c1bfca04 AJ |
174 | \@MAKE_RULES\@ |
175 | ||
23829bea AJ |
176 | # Symbolic links |
177 | ||
c728efc3 AJ |
178 | WIN16_FILES = \\ |
179 | EOF | |
180 | printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 ); | |
181 | ||
182 | print NEWMAKE <<EOF; | |
183 | ||
c2fbb406 AJ |
184 | SYMLINKS_SO = \\ |
185 | \$(EXTRADIRS:%=%.dll.so) \\ | |
c728efc3 | 186 | \@WIN16_FILES\@ \\ |
f33f7f0e AJ |
187 | EOF |
188 | printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets ); | |
189 | ||
23829bea AJ |
190 | print NEWMAKE <<EOF; |
191 | ||
192 | # Main target | |
193 | ||
c2fbb406 AJ |
194 | all: symlinks\$(DLLEXT) |
195 | ||
196 | .PHONY: symlinks symlinks.so implib | |
197 | ||
198 | symlinks.so: \$(SYMLINKS_SO) | |
199 | ||
200 | symlinks: \$(BUILDSUBDIRS) | |
201 | ||
c3116c5e AJ |
202 | x11drv.dll.so: winex11.drv.so |
203 | \$(RM) \$@ && \$(LN_S) winex11.drv.so \$@ | |
204 | ||
23829bea | 205 | EOF |
f33f7f0e AJ |
206 | |
207 | ################################################################ | |
208 | # output the lib name -> directory rules | |
209 | ||
7c3dec92 AJ |
210 | print NEWMAKE <<EOF; |
211 | ||
45a795c0 | 212 | # Map symlink name to the corresponding library |
7c3dec92 AJ |
213 | |
214 | EOF | |
215 | ||
c0d955e8 | 216 | foreach my $mod (sort keys %directories) |
7c3dec92 | 217 | { |
c2fbb406 AJ |
218 | printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod; |
219 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod; | |
03b47d21 | 220 | |
f33f7f0e | 221 | if (defined $altnames{$mod}) |
7c3dec92 | 222 | { |
03b47d21 | 223 | my $count = 0; |
c0d955e8 | 224 | foreach my $i (sort @{$altnames{$mod}}) |
7c3dec92 | 225 | { |
03b47d21 | 226 | if ($count++ == 3) { printf NEWMAKE "\\\n "; $count = 1; } |
c2fbb406 | 227 | printf NEWMAKE "%s.so ", $i; |
7c3dec92 | 228 | } |
c2fbb406 AJ |
229 | printf NEWMAKE ": %s.so\n", $mod; |
230 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s.so \$@\n\n", $mod; | |
7c3dec92 | 231 | } |
7c3dec92 | 232 | } |
15ac6847 | 233 | foreach my $mod (sort keys %staticlib_dirs) |
c3eac438 | 234 | { |
15ac6847 AJ |
235 | printf NEWMAKE "%s: %s/%s\n", $mod, $staticlib_dirs{$mod}, $mod; |
236 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $staticlib_dirs{$mod}, $mod; | |
c3eac438 | 237 | } |
f33f7f0e | 238 | |
ada5e652 AJ |
239 | ################################################################ |
240 | # output the import libraries rules | |
241 | ||
15ac6847 AJ |
242 | print NEWMAKE "\n# Import libraries\n\n"; |
243 | print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n"; | |
ada5e652 | 244 | |
15ac6847 AJ |
245 | my @lib_symlinks = ("ntdll.dll"); |
246 | foreach my $mod (sort keys %importlibs) | |
ada5e652 | 247 | { |
15ac6847 AJ |
248 | my $dir = $directories{$mod}; |
249 | my $lib = $importlibs{$mod}; | |
250 | if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; } | |
ada5e652 | 251 | } |
15ac6847 AJ |
252 | print NEWMAKE "IMPORT_SYMLINKS ="; |
253 | foreach my $mod (sort @lib_symlinks) | |
254 | { | |
255 | printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod}; | |
256 | } | |
257 | foreach my $mod (sort keys %staticlib_dirs) | |
c3eac438 AJ |
258 | { |
259 | printf NEWMAKE " \\\n\t%s", $mod; | |
260 | } | |
15ac6847 AJ |
261 | |
262 | print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)"; | |
263 | foreach my $mod (sort keys %importlibs) | |
264 | { | |
265 | my $dir = $directories{$mod}; | |
266 | my $def = $mod; | |
267 | $def =~ s/\.(dll|drv)$//; | |
268 | printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def; | |
269 | printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod}; | |
270 | } | |
ada5e652 | 271 | print NEWMAKE "\n\n"; |
06233cfb | 272 | print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n"; |
ada5e652 | 273 | |
15ac6847 | 274 | foreach my $mod (sort keys %importlibs) |
ada5e652 AJ |
275 | { |
276 | my $dir = $directories{$mod}; | |
15ac6847 | 277 | my $lib = $importlibs{$mod}; |
ada5e652 AJ |
278 | my $spec = $mod; |
279 | $spec =~ s/\.dll$//; | |
15ac6847 AJ |
280 | printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec; |
281 | printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib; | |
282 | next unless $static_implibs{$mod}; | |
283 | printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec; | |
284 | printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib; | |
285 | } | |
286 | foreach my $mod (sort @lib_symlinks) | |
287 | { | |
288 | my $dir = $directories{$mod}; | |
289 | my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)"; | |
290 | printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib; | |
291 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib; | |
ada5e652 | 292 | } |
ada5e652 AJ |
293 | |
294 | print NEWMAKE <<EOF; | |
06233cfb | 295 | \$(BUILDSUBDIRS): \$(IMPORT_LIBS) |
71ff4c4f | 296 | \$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS) |
ada5e652 AJ |
297 | |
298 | EOF | |
299 | ||
f33f7f0e AJ |
300 | ################################################################ |
301 | # output the inter-dll dependencies and rules | |
302 | ||
45a795c0 AJ |
303 | print NEWMAKE "# Map library name to the corresponding directory\n\n"; |
304 | ||
305 | foreach my $mod (sort keys %directories) | |
306 | { | |
c2fbb406 | 307 | printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod}; |
45a795c0 | 308 | } |
15ac6847 | 309 | foreach my $mod (sort keys %staticlib_dirs) |
c3eac438 | 310 | { |
15ac6847 | 311 | printf NEWMAKE "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod}; |
c3eac438 | 312 | } |
45a795c0 | 313 | |
f33f7f0e AJ |
314 | ################################################################ |
315 | # makefile trailer | |
7c3dec92 | 316 | |
f33f7f0e | 317 | print NEWMAKE <<EOF; |
c3eac438 | 318 | |
78e33111 AJ |
319 | # Rules for auto documentation |
320 | ||
321 | \$(SUBDIRS:%=%/__man__): dummy | |
322 | cd `dirname \$@` && \$(MAKE) man | |
323 | ||
324 | man: \$(SUBDIRS:%=%/__man__) | |
325 | ||
326 | \$(SUBDIRS:%=%/__doc_html__): dummy | |
327 | cd `dirname \$@` && \$(MAKE) doc-html | |
328 | ||
329 | doc-html: \$(SUBDIRS:%=%/__doc_html__) | |
330 | ||
331 | \$(SUBDIRS:%=%/__doc_sgml__): dummy | |
332 | cd `dirname \$@` && \$(MAKE) doc-sgml | |
333 | ||
334 | doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__) | |
335 | ||
c2fbb406 | 336 | .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__) |
78e33111 | 337 | |
f33f7f0e | 338 | # Misc rules |
7c3dec92 | 339 | |
34fa35dc | 340 | install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__) |
ada5e652 | 341 | |
34fa35dc | 342 | install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__) |
e8dae9c0 | 343 | |
f673b71e | 344 | uninstall:: |
c1bfca04 | 345 | -rmdir \$(dlldir) |
7c3dec92 | 346 | |
ada5e652 | 347 | clean:: |
15ac6847 | 348 | \$(RM) \$(IMPORT_SYMLINKS) |
ada5e652 | 349 | |
5852f7a1 | 350 | check test:: \$(BUILDSUBDIRS:%=%/__test__) |
9384184a | 351 | |
c3c587eb AJ |
352 | crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__) |
353 | ||
5852f7a1 | 354 | checklink:: \$(BUILDSUBDIRS:%=%/__checklink__) |
f673b71e | 355 | |
f673b71e | 356 | ### Dependencies: |
7c3dec92 AJ |
357 | EOF |
358 | ||
359 | close NEWMAKE; | |
360 | rename "Makefile.in.new", "Makefile.in"; | |
361 | printf "Successfully updated Makefile.in\n"; |