Return empty string on error in WM_GETTEXT.
[wine/multimedia.git] / dlls / make_dlls
blob38cdf7256d4061dc80c9c103d190561e44400426
1 #!/usr/bin/perl -w
3 # Update the dll dependencies in the dlls main Makefile.in.
4 # Must be run in the dlls/ directory of the Wine tree.
6 # Copyright 2001 Alexandre Julliard
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.
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.
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
23 use strict;
25 my $makefiles = `find . -name Makefile.in -print`;
27 my %imports = ();
28 my %directories = ();
29 my %altnames = ();
30 my %linked_dlls = ();
32 # list of special dlls that can be switched on or off by configure
33 my %special_dlls =
35 "ddraw" => "XFILES",
36 "glu32" => "GLU32FILES",
37 "opengl32" => "OPENGLFILES",
38 "x11drv" => "XFILES"
41 foreach my $i (split(/\s/,$makefiles))
43 my $module;
45 open MAKE,$i;
47 $module = undef;
48 while (<MAKE>)
50 chop;
51 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
52 # at the very top of the Makefile.in
53 last if (/^\#\s*MKDLL_SKIP/);
55 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
57 $module = $1;
58 $imports{$module} = [ ];
59 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
60 next;
62 if (/^ALTNAMES\s*=\s*(.*)/)
64 my @list = split(/\s/,$1);
65 $altnames{$module} = \@list;
66 next;
68 if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
70 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
71 push @{$imports{$module}}, @list;
72 next;
74 if (/^LDIMPORTS\s*=\s*(.*)/)
76 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1);
77 $linked_dlls{$module} = \@list;
78 next;
81 close MAKE;
82 push @{$imports{$module}}, "kernel32.dll" unless !defined($module) || @{$imports{$module}} || $module eq "ntdll.dll";
85 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
87 ################################################################
88 # makefile header
90 print NEWMAKE <<EOF;
91 # Automatically generated by make_dlls; DO NOT EDIT!!
93 TOPSRCDIR = \@top_srcdir\@
94 TOPOBJDIR = ..
95 SRCDIR = \@srcdir\@
96 VPATH = \@srcdir\@
98 EOF
100 ################################################################
101 # output special dlls configure definitions
103 printf NEWMAKE "# special configure-dependent targets\n\n";
104 my %specials = ();
105 foreach my $mod (sort keys %special_dlls)
107 $specials{$special_dlls{$mod}} .= " " . $mod;
109 foreach my $i (sort keys %specials)
111 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
113 printf NEWMAKE "EXTRADIRS =";
114 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
115 printf NEWMAKE "\n\n";
118 ################################################################
119 # output the subdirs list
121 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
122 foreach my $dir (sort values %directories)
124 next if defined($special_dlls{$dir}); # skip special dlls
125 printf NEWMAKE " \\\n\t%s", $dir;
128 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
129 foreach my $dir (sort keys %special_dlls)
131 printf NEWMAKE " \\\n\t%s", $dir;
133 printf NEWMAKE <<EOF;
136 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
138 INSTALLSUBDIRS = \$(BUILDSUBDIRS)
141 ################################################################
142 # output the all: target
144 my %targets = (); # use a hash to get rid of duplicate target names
145 foreach my $mod (sort keys %directories)
147 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
148 $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
149 next unless defined $altnames{$mod};
150 foreach my $i (sort @{$altnames{$mod}})
152 $targets{sprintf("%s\$(DLLEXT)",$i)} = 1;
155 print NEWMAKE <<EOF;
157 # Main target
159 \@MAKE_RULES\@
161 all: \\
162 \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
164 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
167 ################################################################
168 # output the lib name -> directory rules
170 print NEWMAKE <<EOF;
172 # Map symlink name to the corresponding library
176 foreach my $mod (sort keys %directories)
178 printf NEWMAKE "%s\$(DLLEXT)", $mod;
179 if (defined $altnames{$mod})
181 my $count = 1;
182 foreach my $i (sort @{$altnames{$mod}})
184 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
185 printf NEWMAKE " %s\$(DLLEXT)", $i;
188 printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
189 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
193 ################################################################
194 # output the inter-dll dependencies and rules
196 print NEWMAKE "# Map library name to the corresponding directory\n\n";
198 foreach my $mod (sort keys %directories)
200 printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
203 print NEWMAKE "\n# Install dependencies\n\n";
205 foreach my $mod (sort keys %directories)
207 printf NEWMAKE "%s/__install__: %s\$(DLLEXT)\n", $directories{$mod}, $mod;
210 print NEWMAKE "\n# Inter-dll dependencies\n\n";
212 my @depends = ();
213 foreach my $mod (sort keys %imports)
215 next unless @{$imports{$mod}};
216 my $count = 0;
217 my $dep = sprintf("%s:", $directories{$mod});
218 $dep .= " " x (8-length($directories{$mod}));
219 foreach my $i (@{$imports{$mod}})
221 if ($count++ >= 4)
223 $count = 1;
224 $dep .= " \\\n" . " " x 9;
226 $dep .= sprintf(" %s\$(DLLEXT)", $i);
228 foreach my $i (@{$linked_dlls{$mod}})
230 if ($count++ >= 4)
232 $count = 1;
233 $dep .= " \\\n" . " " x 9;
235 $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
237 push @depends, $dep . "\n";
239 print NEWMAKE sort @depends;
242 ################################################################
243 # output the linkable dlls special links
245 my %linkable_dlls = ();
246 foreach my $mod (keys %imports)
248 foreach my $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
251 print NEWMAKE "\n# Special targets for dlls that we need to link to\n\n";
252 printf NEWMAKE "LINKABLE_DLLS = %s\n\n", join( " ", keys %linkable_dlls );
254 foreach my $mod (keys %linkable_dlls)
256 printf NEWMAKE "lib%s.\$(LIBEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod;
257 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
260 print NEWMAKE <<EOF;
261 uninstall::
262 \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
264 install::
265 \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
266 cd \$(libdir) && if [ "\$(dlldir)" = "\$(libdir)/wine" ]; \\
267 then \\
269 foreach my $mod (keys %linkable_dlls)
271 printf NEWMAKE "\t \$(LN_S) wine/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod;
273 print NEWMAKE "\telse \\\n";
274 foreach my $mod (keys %linkable_dlls)
276 printf NEWMAKE "\t \$(LN_S) \$(dlldir)/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod;
278 print NEWMAKE "\tfi\n\n";
280 ################################################################
281 # makefile trailer
283 print NEWMAKE <<EOF;
284 # Misc rules
286 \$(BUILDSUBDIRS:%=%/__checklink__): dummy
287 \@cd `dirname \$\@` && \$(MAKE) checklink
289 uninstall::
290 -rmdir \$(dlldir)
292 check test:: \$(BUILDSUBDIRS:%=%/__test__)
294 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
296 .PHONY: checklink \$(BUILDSUBDIRS:%=%/__checklink__)
298 ### Dependencies:
301 close NEWMAKE;
302 rename "Makefile.in.new", "Makefile.in";
303 printf "Successfully updated Makefile.in\n";