Fix French translation.
[wine/multimedia.git] / dlls / make_dlls
blob69b7f91d1717a84b12a76747b6b8719310ef77a3
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 "d3d8" => "OPENGLFILES",
39 "d3d9" => "OPENGLFILES",
40 "d3dx8" => "OPENGLFILES",
41 "x11drv" => "XFILES"
44 foreach my $i (split(/\s/,$makefiles))
46 my $module;
48 next if $i =~ /\/tests\/Makefile.in/;
50 open MAKE,$i;
52 $module = undef;
53 while (<MAKE>)
55 chop;
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/);
60 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
62 $module = $1;
63 $imports{$module} = [ ];
64 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
65 next;
67 if (/^ALTNAMES\s*=\s*(.*)/)
69 my @list = split(/\s/,$1);
70 $altnames{$module} = \@list;
71 next;
73 if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
75 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
76 push @{$imports{$module}}, @list;
77 next;
79 if (/^LDIMPORTS\s*=\s*(.*)/)
81 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1);
82 $linked_dlls{$module} = \@list;
83 next;
86 close MAKE;
87 push @{$imports{$module}}, "kernel32.dll" unless !defined($module) || @{$imports{$module}} || $module eq "ntdll.dll";
90 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
92 ################################################################
93 # makefile header
95 print NEWMAKE <<EOF;
96 # Automatically generated by make_dlls; DO NOT EDIT!!
98 TOPSRCDIR = \@top_srcdir\@
99 TOPOBJDIR = ..
100 SRCDIR = \@srcdir\@
101 VPATH = \@srcdir\@
105 ################################################################
106 # output special dlls configure definitions
108 printf NEWMAKE "# special configure-dependent targets\n\n";
109 my %specials = ();
110 foreach my $mod (sort keys %special_dlls)
112 $specials{$special_dlls{$mod}} .= " " . $mod;
114 foreach my $i (sort keys %specials)
116 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
118 printf NEWMAKE "EXTRADIRS =";
119 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
120 printf NEWMAKE "\n\n";
123 ################################################################
124 # output the subdirs list
126 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
127 foreach my $dir (sort values %directories)
129 next if defined($special_dlls{$dir}); # skip special dlls
130 printf NEWMAKE " \\\n\t%s", $dir;
133 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
134 foreach my $dir (sort keys %special_dlls)
136 printf NEWMAKE " \\\n\t%s", $dir;
138 printf NEWMAKE <<EOF;
141 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
143 INSTALLSUBDIRS = \$(BUILDSUBDIRS)
146 ################################################################
147 # output the all: target
149 my %targets = (); # use a hash to get rid of duplicate target names
150 my %targets16 = ();
151 foreach my $mod (sort keys %directories)
153 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
154 $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
155 next unless defined $altnames{$mod};
156 foreach my $i (sort @{$altnames{$mod}})
158 $targets16{sprintf("%s\$(DLLEXT)",$i)} = 1;
161 print NEWMAKE <<EOF;
163 \@MAKE_RULES\@
165 # Symbolic links
167 WIN16_FILES = \\
169 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
171 print NEWMAKE <<EOF;
173 SYMLINKS = \\
174 \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
175 \@WIN16_FILES\@ \\
177 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
179 print NEWMAKE <<EOF;
181 # Main target
183 all: \$(SYMLINKS)
186 ################################################################
187 # output the lib name -> directory rules
189 print NEWMAKE <<EOF;
191 # Map symlink name to the corresponding library
195 foreach my $mod (sort keys %directories)
197 printf NEWMAKE "%s\$(DLLEXT)", $mod;
198 if (defined $altnames{$mod})
200 my $count = 1;
201 foreach my $i (sort @{$altnames{$mod}})
203 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
204 printf NEWMAKE " %s\$(DLLEXT)", $i;
207 printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
208 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
212 ################################################################
213 # output the import libraries rules
215 my @implibs = grep /\.dll$/, keys %directories;
216 push @implibs, "winspool.drv";
218 print NEWMAKE "\n# Import libraries\n\nIMPORT_LIBS =";
219 foreach my $mod (sort @implibs)
221 my $def = $mod;
222 $def =~ s/\.(dll|drv)$//;
223 printf NEWMAKE " \\\n\tlib%s", $def;
225 print NEWMAKE "\n\n";
227 foreach my $mod (sort @implibs)
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;
239 foreach my $mod (sort @implibs)
241 my $dir = $directories{$mod};
242 my $spec = $mod;
243 $spec =~ s/\.dll$//;
244 printf NEWMAKE "%s/%s.spec.def: \$(WINEBUILD)\n", $dir, $spec;
248 print NEWMAKE <<EOF;
250 \$(SUBDIRS): \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))
251 \$(SUBDIRS:%=%/__install__): \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))
252 \$(SUBDIRS:%=%/__crosstest__): \$(IMPORT_LIBS:%=%.a)
256 ################################################################
257 # output the inter-dll dependencies and rules
259 print NEWMAKE "# Map library name to the corresponding directory\n\n";
261 foreach my $mod (sort keys %directories)
263 printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
266 ################################################################
267 # output the linkable dlls special links
269 my %linkable_dlls = ();
270 foreach my $mod (keys %imports)
272 foreach my $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
275 print NEWMAKE "\n# Special targets for dlls that we need to link to\n\n";
276 printf NEWMAKE "LINKABLE_DLLS = %s\n\n", join( " ", keys %linkable_dlls );
278 foreach my $mod (keys %linkable_dlls)
280 printf NEWMAKE "lib%s.\$(LIBEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod;
281 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
284 foreach my $mod (keys %imports)
286 my $deps = "";
287 foreach my $i (@{$linked_dlls{$mod}}) { $deps .= " lib$i.\$(LIBEXT)"; }
288 if ($deps) { printf NEWMAKE "%s %s/__install__:%s\n", $directories{$mod}, $directories{$mod}, $deps; }
291 print NEWMAKE <<EOF;
293 uninstall::
294 \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
296 install install-lib:: \$(INSTALLSUBDIRS:%=%/__install__)
297 \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
298 cd \$(libdir) && if [ "\$(dlldir)" = "\$(libdir)/wine" ]; \\
299 then \\
301 foreach my $mod (keys %linkable_dlls)
303 printf NEWMAKE "\t \$(LN_S) wine/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod;
305 print NEWMAKE "\telse \\\n";
306 foreach my $mod (keys %linkable_dlls)
308 printf NEWMAKE "\t \$(LN_S) \$(dlldir)/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod;
310 print NEWMAKE "\tfi\n\n";
312 ################################################################
313 # makefile trailer
315 print NEWMAKE <<EOF;
316 # Rules for auto documentation
318 \$(SUBDIRS:%=%/__man__): dummy
319 cd `dirname \$@` && \$(MAKE) man
321 man: \$(SUBDIRS:%=%/__man__)
323 \$(SUBDIRS:%=%/__doc_html__): dummy
324 cd `dirname \$@` && \$(MAKE) doc-html
326 doc-html: \$(SUBDIRS:%=%/__doc_html__)
328 \$(SUBDIRS:%=%/__doc_sgml__): dummy
329 cd `dirname \$@` && \$(MAKE) doc-sgml
331 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
333 .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
335 # Misc rules
337 install install-dev:: \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))
338 \$(MKINSTALLDIRS) \$(dlldir)
339 for f in \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT)); do \$(INSTALL_DATA) \$\$f \$(dlldir)/\$\$f; done
341 uninstall::
342 \$(RM) \$(IMPORT_LIBS:%=\$(dlldir)/%.\$(IMPLIBEXT))
343 -rmdir \$(dlldir)
345 clean::
346 \$(RM) \$(IMPORT_LIBS:%=%.a) \$(IMPORT_LIBS:%=%.def) \$(SYMLINKS)
348 check test:: \$(BUILDSUBDIRS:%=%/__test__)
350 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
352 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
354 ### Dependencies:
357 close NEWMAKE;
358 rename "Makefile.in.new", "Makefile.in";
359 printf "Successfully updated Makefile.in\n";