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 | ||
27 | my %imports = (); | |
28 | my %directories = (); | |
29 | my %altnames = (); | |
30 | my %linked_dlls = (); | |
7c3dec92 | 31 | |
f33f7f0e | 32 | # list of special dlls that can be switched on or off by configure |
c0d955e8 | 33 | my %special_dlls = |
f33f7f0e AJ |
34 | ( |
35 | "ddraw" => "XFILES", | |
36 | "glu32" => "GLU32FILES", | |
37 | "opengl32" => "OPENGLFILES", | |
7cbb340a | 38 | "d3d8" => "OPENGLFILES", |
aa1bdc42 | 39 | "d3d9" => "OPENGLFILES", |
e31ae926 | 40 | "d3dx8" => "OPENGLFILES", |
f33f7f0e AJ |
41 | "x11drv" => "XFILES" |
42 | ); | |
43 | ||
c0d955e8 | 44 | foreach my $i (split(/\s/,$makefiles)) |
7c3dec92 | 45 | { |
c0d955e8 EP |
46 | my $module; |
47 | ||
edeee89c AJ |
48 | next if $i =~ /\/tests\/Makefile.in/; |
49 | ||
7c3dec92 | 50 | open MAKE,$i; |
c0d955e8 EP |
51 | |
52 | $module = undef; | |
7c3dec92 AJ |
53 | while (<MAKE>) |
54 | { | |
55 | chop; | |
c0d955e8 EP |
56 | # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear |
57 | # at the very top of the Makefile.in | |
58 | last if (/^\#\s*MKDLL_SKIP/); | |
59 | ||
7c3dec92 AJ |
60 | if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/) |
61 | { | |
62 | $module = $1; | |
ec329ab3 | 63 | $imports{$module} = [ ]; |
7c3dec92 AJ |
64 | ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/; |
65 | next; | |
66 | } | |
67 | if (/^ALTNAMES\s*=\s*(.*)/) | |
68 | { | |
69 | my @list = split(/\s/,$1); | |
70 | $altnames{$module} = \@list; | |
71 | next; | |
72 | } | |
ec329ab3 | 73 | if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/) |
c1bfca04 | 74 | { |
ec329ab3 AJ |
75 | my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2); |
76 | push @{$imports{$module}}, @list; | |
7c3dec92 AJ |
77 | next; |
78 | } | |
ec329ab3 | 79 | if (/^LDIMPORTS\s*=\s*(.*)/) |
7c3dec92 | 80 | { |
ec329ab3 AJ |
81 | my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1); |
82 | $linked_dlls{$module} = \@list; | |
7c3dec92 AJ |
83 | next; |
84 | } | |
85 | } | |
c0d955e8 EP |
86 | close MAKE; |
87 | push @{$imports{$module}}, "kernel32.dll" unless !defined($module) || @{$imports{$module}} || $module eq "ntdll.dll"; | |
7c3dec92 AJ |
88 | } |
89 | ||
7c3dec92 AJ |
90 | open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new"; |
91 | ||
f33f7f0e AJ |
92 | ################################################################ |
93 | # makefile header | |
94 | ||
95 | print NEWMAKE <<EOF; | |
96 | # Automatically generated by make_dlls; DO NOT EDIT!! | |
97 | ||
98 | TOPSRCDIR = \@top_srcdir\@ | |
99 | TOPOBJDIR = .. | |
100 | SRCDIR = \@srcdir\@ | |
101 | VPATH = \@srcdir\@ | |
f33f7f0e AJ |
102 | |
103 | EOF | |
104 | ||
105 | ################################################################ | |
106 | # output special dlls configure definitions | |
107 | ||
108 | printf NEWMAKE "# special configure-dependent targets\n\n"; | |
109 | my %specials = (); | |
c0d955e8 | 110 | foreach my $mod (sort keys %special_dlls) |
7c3dec92 | 111 | { |
f33f7f0e | 112 | $specials{$special_dlls{$mod}} .= " " . $mod; |
7c3dec92 | 113 | } |
c0d955e8 | 114 | foreach my $i (sort keys %specials) |
7c3dec92 | 115 | { |
f33f7f0e | 116 | printf NEWMAKE "%s =%s\n", $i, $specials{$i}; |
7c3dec92 | 117 | } |
f33f7f0e | 118 | printf NEWMAKE "EXTRADIRS ="; |
c0d955e8 | 119 | foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; } |
f33f7f0e AJ |
120 | printf NEWMAKE "\n\n"; |
121 | ||
122 | ||
123 | ################################################################ | |
124 | # output the subdirs list | |
7c3dec92 | 125 | |
5852f7a1 | 126 | print NEWMAKE "# Subdir list\n\nBASEDIRS ="; |
c0d955e8 | 127 | foreach my $dir (sort values %directories) |
7c3dec92 | 128 | { |
f33f7f0e | 129 | next if defined($special_dlls{$dir}); # skip special dlls |
7c3dec92 AJ |
130 | printf NEWMAKE " \\\n\t%s", $dir; |
131 | } | |
7c3dec92 | 132 | |
5852f7a1 AJ |
133 | printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)"; |
134 | foreach my $dir (sort keys %special_dlls) | |
135 | { | |
136 | printf NEWMAKE " \\\n\t%s", $dir; | |
137 | } | |
138 | printf NEWMAKE <<EOF; | |
139 | ||
140 | ||
141 | BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) | |
f673b71e AJ |
142 | |
143 | INSTALLSUBDIRS = \$(BUILDSUBDIRS) | |
5852f7a1 | 144 | EOF |
f33f7f0e AJ |
145 | |
146 | ################################################################ | |
147 | # output the all: target | |
148 | ||
149 | my %targets = (); # use a hash to get rid of duplicate target names | |
c728efc3 | 150 | my %targets16 = (); |
c0d955e8 | 151 | foreach my $mod (sort keys %directories) |
f33f7f0e | 152 | { |
c1bfca04 AJ |
153 | next if defined($special_dlls{$directories{$mod}}); # skip special dlls |
154 | $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1; | |
f33f7f0e | 155 | next unless defined $altnames{$mod}; |
c0d955e8 | 156 | foreach my $i (sort @{$altnames{$mod}}) |
f33f7f0e | 157 | { |
c728efc3 | 158 | $targets16{sprintf("%s\$(DLLEXT)",$i)} = 1; |
f33f7f0e AJ |
159 | } |
160 | } | |
161 | print NEWMAKE <<EOF; | |
162 | ||
c1bfca04 AJ |
163 | \@MAKE_RULES\@ |
164 | ||
23829bea AJ |
165 | # Symbolic links |
166 | ||
c728efc3 AJ |
167 | WIN16_FILES = \\ |
168 | EOF | |
169 | printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 ); | |
170 | ||
171 | print NEWMAKE <<EOF; | |
172 | ||
23829bea | 173 | SYMLINKS = \\ |
c1bfca04 | 174 | \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\ |
c728efc3 | 175 | \@WIN16_FILES\@ \\ |
f33f7f0e AJ |
176 | EOF |
177 | printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets ); | |
178 | ||
23829bea AJ |
179 | print NEWMAKE <<EOF; |
180 | ||
181 | # Main target | |
182 | ||
183 | all: \$(SYMLINKS) | |
184 | EOF | |
f33f7f0e AJ |
185 | |
186 | ################################################################ | |
187 | # output the lib name -> directory rules | |
188 | ||
7c3dec92 AJ |
189 | print NEWMAKE <<EOF; |
190 | ||
45a795c0 | 191 | # Map symlink name to the corresponding library |
7c3dec92 AJ |
192 | |
193 | EOF | |
194 | ||
c0d955e8 | 195 | foreach my $mod (sort keys %directories) |
7c3dec92 | 196 | { |
c1bfca04 | 197 | printf NEWMAKE "%s\$(DLLEXT)", $mod; |
f33f7f0e | 198 | if (defined $altnames{$mod}) |
7c3dec92 | 199 | { |
f33f7f0e | 200 | my $count = 1; |
c0d955e8 | 201 | foreach my $i (sort @{$altnames{$mod}}) |
7c3dec92 | 202 | { |
f33f7f0e | 203 | if (!($count++ % 3)) { printf NEWMAKE " \\\n "; } |
c1bfca04 | 204 | printf NEWMAKE " %s\$(DLLEXT)", $i; |
7c3dec92 | 205 | } |
7c3dec92 | 206 | } |
45a795c0 | 207 | printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod; |
c1bfca04 | 208 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod; |
7c3dec92 AJ |
209 | } |
210 | ||
f33f7f0e | 211 | |
ada5e652 AJ |
212 | ################################################################ |
213 | # output the import libraries rules | |
214 | ||
215 | my @implibs = grep /\.dll$/, keys %directories; | |
216 | push @implibs, "winspool.drv"; | |
217 | ||
218 | print NEWMAKE "\n# Import libraries\n\nIMPORT_LIBS ="; | |
219 | foreach my $mod (sort @implibs) | |
220 | { | |
221 | my $def = $mod; | |
f1b4819e | 222 | $def =~ s/\.(dll|drv)$//; |
ada5e652 AJ |
223 | printf NEWMAKE " \\\n\tlib%s", $def; |
224 | } | |
225 | print NEWMAKE "\n\n"; | |
226 | ||
227 | foreach my $mod (sort @implibs) | |
228 | { | |
229 | my $dir = $directories{$mod}; | |
230 | my $def = $mod; | |
231 | my $spec = $mod; | |
232 | $spec =~ s/\.dll$//; | |
233 | $def =~ s/\.(dll|drv)$//; | |
234 | printf NEWMAKE "lib%s.def: %s/%s.spec.def\n", $def, $dir, $spec; | |
235 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.spec.def \$@\n", $dir, $spec; | |
236 | printf NEWMAKE "lib%s.a: %s/%s.spec.def\n", $def, $dir, $spec; | |
237 | printf NEWMAKE "\t\$(DLLTOOL) -k -l \$@ -d %s/%s.spec.def\n\n", $dir, $spec; | |
238 | } | |
239 | foreach my $mod (sort @implibs) | |
240 | { | |
241 | my $dir = $directories{$mod}; | |
242 | my $spec = $mod; | |
243 | $spec =~ s/\.dll$//; | |
244 | printf NEWMAKE "%s/%s.spec.def: \$(WINEBUILD)\n", $dir, $spec; | |
245 | } | |
246 | ||
247 | ||
248 | print NEWMAKE <<EOF; | |
249 | ||
f1b4819e | 250 | \$(SUBDIRS): \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT)) |
635b09f9 | 251 | \$(SUBDIRS:%=%/__install__): \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT)) |
f1b4819e | 252 | \$(SUBDIRS:%=%/__crosstest__): \$(IMPORT_LIBS:%=%.a) |
ada5e652 AJ |
253 | |
254 | EOF | |
255 | ||
f33f7f0e AJ |
256 | ################################################################ |
257 | # output the inter-dll dependencies and rules | |
258 | ||
45a795c0 AJ |
259 | print NEWMAKE "# Map library name to the corresponding directory\n\n"; |
260 | ||
261 | foreach my $mod (sort keys %directories) | |
262 | { | |
263 | printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod}; | |
264 | } | |
265 | ||
c1bfca04 AJ |
266 | ################################################################ |
267 | # output the linkable dlls special links | |
268 | ||
c0d955e8 EP |
269 | my %linkable_dlls = (); |
270 | foreach my $mod (keys %imports) | |
c1bfca04 | 271 | { |
c0d955e8 | 272 | foreach my $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; } |
c1bfca04 AJ |
273 | } |
274 | ||
5852f7a1 | 275 | print NEWMAKE "\n# Special targets for dlls that we need to link to\n\n"; |
1c40426e AJ |
276 | printf NEWMAKE "LINKABLE_DLLS = %s\n\n", join( " ", keys %linkable_dlls ); |
277 | ||
c0d955e8 | 278 | foreach my $mod (keys %linkable_dlls) |
c1bfca04 | 279 | { |
5b80ce35 | 280 | printf NEWMAKE "lib%s.\$(LIBEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod; |
c1bfca04 AJ |
281 | printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod; |
282 | } | |
283 | ||
ada5e652 AJ |
284 | foreach my $mod (keys %imports) |
285 | { | |
286 | my $deps = ""; | |
287 | foreach my $i (@{$linked_dlls{$mod}}) { $deps .= " lib$i.\$(LIBEXT)"; } | |
717e8f45 | 288 | if ($deps) { printf NEWMAKE "%s %s/__install__:%s\n", $directories{$mod}, $directories{$mod}, $deps; } |
ada5e652 AJ |
289 | } |
290 | ||
1c40426e | 291 | print NEWMAKE <<EOF; |
ada5e652 | 292 | |
f673b71e | 293 | uninstall:: |
1c40426e AJ |
294 | \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT)) |
295 | ||
76c30657 | 296 | install install-lib:: \$(INSTALLSUBDIRS:%=%/__install__) |
f673b71e | 297 | \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT)) |
1c40426e AJ |
298 | cd \$(libdir) && if [ "\$(dlldir)" = "\$(libdir)/wine" ]; \\ |
299 | then \\ | |
300 | EOF | |
301 | foreach my $mod (keys %linkable_dlls) | |
302 | { | |
303 | printf NEWMAKE "\t \$(LN_S) wine/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod; | |
304 | } | |
305 | print NEWMAKE "\telse \\\n"; | |
306 | foreach my $mod (keys %linkable_dlls) | |
307 | { | |
308 | printf NEWMAKE "\t \$(LN_S) \$(dlldir)/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod; | |
309 | } | |
310 | print NEWMAKE "\tfi\n\n"; | |
311 | ||
f33f7f0e AJ |
312 | ################################################################ |
313 | # makefile trailer | |
7c3dec92 | 314 | |
f33f7f0e | 315 | print NEWMAKE <<EOF; |
78e33111 AJ |
316 | # Rules for auto documentation |
317 | ||
318 | \$(SUBDIRS:%=%/__man__): dummy | |
319 | cd `dirname \$@` && \$(MAKE) man | |
320 | ||
321 | man: \$(SUBDIRS:%=%/__man__) | |
322 | ||
323 | \$(SUBDIRS:%=%/__doc_html__): dummy | |
324 | cd `dirname \$@` && \$(MAKE) doc-html | |
325 | ||
326 | doc-html: \$(SUBDIRS:%=%/__doc_html__) | |
327 | ||
328 | \$(SUBDIRS:%=%/__doc_sgml__): dummy | |
329 | cd `dirname \$@` && \$(MAKE) doc-sgml | |
330 | ||
331 | doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__) | |
332 | ||
333 | .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__) | |
334 | ||
f33f7f0e | 335 | # Misc rules |
7c3dec92 | 336 | |
f1b4819e | 337 | install install-dev:: \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT)) |
ada5e652 | 338 | \$(MKINSTALLDIRS) \$(dlldir) |
f1b4819e | 339 | for f in \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT)); do \$(INSTALL_DATA) \$\$f \$(dlldir)/\$\$f; done |
ada5e652 | 340 | |
f673b71e | 341 | uninstall:: |
f1b4819e | 342 | \$(RM) \$(IMPORT_LIBS:%=\$(dlldir)/%.\$(IMPLIBEXT)) |
c1bfca04 | 343 | -rmdir \$(dlldir) |
7c3dec92 | 344 | |
ada5e652 | 345 | clean:: |
23829bea | 346 | \$(RM) \$(IMPORT_LIBS:%=%.a) \$(IMPORT_LIBS:%=%.def) \$(SYMLINKS) |
ada5e652 | 347 | |
5852f7a1 | 348 | check test:: \$(BUILDSUBDIRS:%=%/__test__) |
9384184a | 349 | |
c3c587eb AJ |
350 | crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__) |
351 | ||
5852f7a1 | 352 | checklink:: \$(BUILDSUBDIRS:%=%/__checklink__) |
f673b71e | 353 | |
f673b71e | 354 | ### Dependencies: |
7c3dec92 AJ |
355 | EOF |
356 | ||
357 | close NEWMAKE; | |
358 | rename "Makefile.in.new", "Makefile.in"; | |
359 | printf "Successfully updated Makefile.in\n"; |