oleaut32: Implement GetTypeAttr_Proxy and friends.
[wine] / dlls / make_dlls
CommitLineData
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 23use strict;
7c3dec92 24
c0d955e8
EP
25my $makefiles = `find . -name Makefile.in -print`;
26
c0d955e8 27my %directories = ();
15ac6847
AJ
28my %importlibs = ();
29my %static_implibs = ();
30my %staticlib_dirs = ();
c0d955e8 31my %altnames = ();
7c3dec92 32
f33f7f0e 33# list of special dlls that can be switched on or off by configure
c0d955e8 34my %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
02fa42dc
AJ
47sub needs_symlink($)
48{
49 (my $mod = $_[0]) =~ s/\.dll$//;
50 return $mod ne $directories{$_[0]};
51}
52
c0d955e8 53foreach my $i (split(/\s/,$makefiles))
7c3dec92 54{
c0d955e8
EP
55 my $module;
56
edeee89c
AJ
57 next if $i =~ /\/tests\/Makefile.in/;
58
7c3dec92 59 open MAKE,$i;
c0d955e8
EP
60
61 $module = undef;
7c3dec92
AJ
62 while (<MAKE>)
63 {
64 chop;
c0d955e8
EP
65 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
66 # at the very top of the Makefile.in
67 last if (/^\#\s*MKDLL_SKIP/);
68
7c3dec92
AJ
69 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
70 {
71 $module = $1;
c3eac438
AJ
72 if ($module =~ /^lib.*\.a$/)
73 {
15ac6847 74 ($staticlib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
7fb2ae6e 75 die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module;
c3eac438
AJ
76 }
77 else
78 {
79 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
80 }
7c3dec92
AJ
81 next;
82 }
15ac6847
AJ
83 if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
84 {
85 $importlibs{$module} = $1;
86 next;
87 }
88 if (/^IMPLIB_SRCS\s*=/)
89 {
90 $static_implibs{$module} = 1;
91 next;
92 }
8be0edb9 93 if (/^SPEC_SRCS16\s*=\s*(.*)/)
7c3dec92 94 {
8be0edb9
AJ
95 my $specs = $1;
96 while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; }
97 my @list = split(/\s+/,$specs);
98 @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
7c3dec92
AJ
99 $altnames{$module} = \@list;
100 next;
101 }
7c3dec92 102 }
c0d955e8 103 close MAKE;
7c3dec92
AJ
104}
105
7c3dec92
AJ
106open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
107
f33f7f0e
AJ
108################################################################
109# makefile header
110
111print NEWMAKE <<EOF;
112# Automatically generated by make_dlls; DO NOT EDIT!!
113
114TOPSRCDIR = \@top_srcdir\@
115TOPOBJDIR = ..
116SRCDIR = \@srcdir\@
117VPATH = \@srcdir\@
f33f7f0e
AJ
118
119EOF
120
121################################################################
122# output special dlls configure definitions
123
124printf NEWMAKE "# special configure-dependent targets\n\n";
125my %specials = ();
c0d955e8 126foreach my $mod (sort keys %special_dlls)
7c3dec92 127{
f33f7f0e 128 $specials{$special_dlls{$mod}} .= " " . $mod;
7c3dec92 129}
c0d955e8 130foreach my $i (sort keys %specials)
7c3dec92 131{
f33f7f0e 132 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
7c3dec92 133}
f33f7f0e 134printf NEWMAKE "EXTRADIRS =";
c0d955e8 135foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
f33f7f0e
AJ
136printf NEWMAKE "\n\n";
137
138
139################################################################
140# output the subdirs list
7c3dec92 141
5852f7a1 142print NEWMAKE "# Subdir list\n\nBASEDIRS =";
c0d955e8 143foreach my $dir (sort values %directories)
7c3dec92 144{
f33f7f0e 145 next if defined($special_dlls{$dir}); # skip special dlls
7c3dec92
AJ
146 printf NEWMAKE " \\\n\t%s", $dir;
147}
7c3dec92 148
fd75880b
AJ
149printf NEWMAKE "\n\nIMPLIBSUBDIRS =";
150foreach my $dir (sort values %staticlib_dirs)
151{
152 printf NEWMAKE " \\\n\t%s", $dir;
153}
154
155printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS) \\\n\t\$(IMPLIBSUBDIRS)";
156foreach my $dir (sort keys %special_dlls)
5852f7a1
AJ
157{
158 printf NEWMAKE " \\\n\t%s", $dir;
159}
160printf NEWMAKE <<EOF;
161
162
163BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
f673b71e 164
fd75880b 165INSTALLSUBDIRS = \$(BUILDSUBDIRS) \$(IMPLIBSUBDIRS)
5852f7a1 166EOF
f33f7f0e
AJ
167
168################################################################
169# output the all: target
170
171my %targets = (); # use a hash to get rid of duplicate target names
c728efc3 172my %targets16 = ();
c0d955e8 173foreach my $mod (sort keys %directories)
f33f7f0e 174{
c1bfca04 175 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
02fa42dc 176 $targets{$mod . ".so"} = 1 if needs_symlink($mod);
f33f7f0e 177 next unless defined $altnames{$mod};
c0d955e8 178 foreach my $i (sort @{$altnames{$mod}})
f33f7f0e 179 {
aed49d43 180 $targets16{$i . "16"} = $mod;
f33f7f0e
AJ
181 }
182}
c3eac438 183
f33f7f0e
AJ
184print NEWMAKE <<EOF;
185
c1bfca04
AJ
186\@MAKE_RULES\@
187
23829bea
AJ
188# Symbolic links
189
c728efc3
AJ
190WIN16_FILES = \\
191EOF
192printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
193
194print NEWMAKE <<EOF;
195
c2fbb406 196SYMLINKS_SO = \\
02fa42dc 197 \$(XFILES:%=%.dll.so) \\
c728efc3 198 \@WIN16_FILES\@ \\
f33f7f0e
AJ
199EOF
200printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
201
23829bea
AJ
202print NEWMAKE <<EOF;
203
204# Main target
205
02fa42dc 206all: \$(BUILDSUBDIRS) symlinks\$(DLLEXT)
c2fbb406
AJ
207
208.PHONY: symlinks symlinks.so implib
209
210symlinks.so: \$(SYMLINKS_SO)
211
212symlinks: \$(BUILDSUBDIRS)
213
c3116c5e
AJ
214x11drv.dll.so: winex11.drv.so
215 \$(RM) \$@ && \$(LN_S) winex11.drv.so \$@
216
23829bea 217EOF
f33f7f0e
AJ
218
219################################################################
220# output the lib name -> directory rules
221
02fa42dc 222print NEWMAKE "# Map symlink name to the corresponding library\n\n";
c0d955e8 223foreach my $mod (sort keys %directories)
7c3dec92 224{
02fa42dc 225 next unless (needs_symlink($mod) || $mod eq "ddraw.dll"); # FIXME: hack because of x11drv
c2fbb406
AJ
226 printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
227 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
02fa42dc 228}
03b47d21 229
02fa42dc
AJ
230print NEWMAKE "# Placeholders for 16-bit libraries\n\n";
231foreach my $mod (sort keys %directories)
232{
233 next unless defined $altnames{$mod};
2c1d6968 234 printf NEWMAKE "%s:\n", join(" ", map { $_ . "16"; } sort @{$altnames{$mod}});
02fa42dc 235 printf NEWMAKE "\techo \"%s\" >\$\@\n\n", $mod;
7c3dec92 236}
f33f7f0e 237
ada5e652
AJ
238################################################################
239# output the import libraries rules
240
02fa42dc 241print NEWMAKE "# Import libraries\n\n";
15ac6847 242print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
ada5e652 243
12c9b501 244my @lib_symlinks = ();
15ac6847 245foreach my $mod (sort keys %importlibs)
ada5e652 246{
15ac6847
AJ
247 my $dir = $directories{$mod};
248 my $lib = $importlibs{$mod};
249 if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
ada5e652 250}
15ac6847
AJ
251print NEWMAKE "IMPORT_SYMLINKS =";
252foreach my $mod (sort @lib_symlinks)
253{
254 printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
255}
7fb2ae6e
AJ
256
257print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
15ac6847 258foreach my $mod (sort keys %staticlib_dirs)
c3eac438 259{
7fb2ae6e 260 printf NEWMAKE " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod;
c3eac438 261}
15ac6847
AJ
262foreach my $mod (sort keys %importlibs)
263{
264 my $dir = $directories{$mod};
265 my $def = $mod;
266 $def =~ s/\.(dll|drv)$//;
267 printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
268 printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
269}
ada5e652 270print NEWMAKE "\n\n";
06233cfb 271print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n";
ada5e652 272
15ac6847 273foreach my $mod (sort keys %importlibs)
ada5e652
AJ
274{
275 my $dir = $directories{$mod};
15ac6847 276 my $lib = $importlibs{$mod};
ada5e652
AJ
277 my $spec = $mod;
278 $spec =~ s/\.dll$//;
15ac6847
AJ
279 printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
280 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
281 next unless $static_implibs{$mod};
282 printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
283 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
284}
285foreach my $mod (sort @lib_symlinks)
286{
287 my $dir = $directories{$mod};
288 my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
289 printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib;
290 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
ada5e652 291}
ada5e652
AJ
292
293print NEWMAKE <<EOF;
06233cfb 294\$(BUILDSUBDIRS): \$(IMPORT_LIBS)
71ff4c4f 295\$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
ada5e652
AJ
296
297EOF
298
f33f7f0e
AJ
299################################################################
300# output the inter-dll dependencies and rules
301
45a795c0
AJ
302print NEWMAKE "# Map library name to the corresponding directory\n\n";
303
304foreach my $mod (sort keys %directories)
305{
2c1d6968 306 next unless (needs_symlink($mod) || $mod eq "ddraw.dll"); # FIXME: hack because of x11drv
c2fbb406 307 printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
45a795c0 308}
15ac6847 309foreach 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 317print NEWMAKE <<EOF;
c3eac438 318
78e33111
AJ
319# Rules for auto documentation
320
321\$(SUBDIRS:%=%/__man__): dummy
322 cd `dirname \$@` && \$(MAKE) man
323
324man: \$(SUBDIRS:%=%/__man__)
325
326\$(SUBDIRS:%=%/__doc_html__): dummy
327 cd `dirname \$@` && \$(MAKE) doc-html
328
329doc-html: \$(SUBDIRS:%=%/__doc_html__)
330
331\$(SUBDIRS:%=%/__doc_sgml__): dummy
332 cd `dirname \$@` && \$(MAKE) doc-sgml
333
334doc-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 340install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
ada5e652 341
34fa35dc 342install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
e8dae9c0 343
f673b71e 344uninstall::
53928443 345 -rmdir \$(DESTDIR)\$(dlldir)
7c3dec92 346
ada5e652 347clean::
ca21f154 348 \$(RM) \$(IMPORT_SYMLINKS) \$(WIN16_FILES)
ada5e652 349
5852f7a1 350check test:: \$(BUILDSUBDIRS:%=%/__test__)
9384184a 351
c3c587eb
AJ
352crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
353
5852f7a1 354checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
f673b71e 355
f673b71e 356### Dependencies:
7c3dec92
AJ
357EOF
358
359close NEWMAKE;
360rename "Makefile.in.new", "Makefile.in";
361printf "Successfully updated Makefile.in\n";