wcmd: Try executing the process even if the exe file doesn't exist.
[wine/multimedia.git] / dlls / make_dlls
blobccc98d2fe204d5dbda4567f17568e25927ac445a
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 %directories = ();
28 my %importlibs = ();
29 my %static_implibs = ();
30 my %staticlib_dirs = ();
31 my %altnames = ();
33 # list of special dlls that can be switched on or off by configure
34 my %special_dlls =
36 "ddraw" => "XFILES",
37 "glu32" => "GLU32FILES",
38 "glut32" => "GLUT32FILES",
39 "opengl32" => "OPENGLFILES",
40 "d3d8" => "OPENGLFILES",
41 "d3d9" => "OPENGLFILES",
42 "d3dx8" => "OPENGLFILES",
43 "wined3d" => "OPENGLFILES",
44 "x11drv" => "XFILES"
47 foreach my $i (split(/\s/,$makefiles))
49 my $module;
51 next if $i =~ /\/tests\/Makefile.in/;
53 open MAKE,$i;
55 $module = undef;
56 while (<MAKE>)
58 chop;
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/);
63 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
65 $module = $1;
66 if ($module =~ /^lib.*\.a$/)
68 ($staticlib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
69 die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module;
71 else
73 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
75 next;
77 if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
79 $importlibs{$module} = $1;
80 next;
82 if (/^IMPLIB_SRCS\s*=/)
84 $static_implibs{$module} = 1;
85 next;
87 if (/^SPEC_SRCS16\s*=\s*(.*)/)
89 my $specs = $1;
90 while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; }
91 my @list = split(/\s+/,$specs);
92 @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
93 $altnames{$module} = \@list;
94 next;
97 close MAKE;
100 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
102 ################################################################
103 # makefile header
105 print NEWMAKE <<EOF;
106 # Automatically generated by make_dlls; DO NOT EDIT!!
108 TOPSRCDIR = \@top_srcdir\@
109 TOPOBJDIR = ..
110 SRCDIR = \@srcdir\@
111 VPATH = \@srcdir\@
115 ################################################################
116 # output special dlls configure definitions
118 printf NEWMAKE "# special configure-dependent targets\n\n";
119 my %specials = ();
120 foreach my $mod (sort keys %special_dlls)
122 $specials{$special_dlls{$mod}} .= " " . $mod;
124 foreach my $i (sort keys %specials)
126 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
128 printf NEWMAKE "EXTRADIRS =";
129 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
130 printf NEWMAKE "\n\n";
133 ################################################################
134 # output the subdirs list
136 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
137 foreach my $dir (sort values %directories)
139 next if defined($special_dlls{$dir}); # skip special dlls
140 printf NEWMAKE " \\\n\t%s", $dir;
143 printf NEWMAKE "\n\nIMPLIBSUBDIRS =";
144 foreach my $dir (sort values %staticlib_dirs)
146 printf NEWMAKE " \\\n\t%s", $dir;
149 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS) \\\n\t\$(IMPLIBSUBDIRS)";
150 foreach my $dir (sort keys %special_dlls)
152 printf NEWMAKE " \\\n\t%s", $dir;
154 printf NEWMAKE <<EOF;
157 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
159 INSTALLSUBDIRS = \$(BUILDSUBDIRS) \$(IMPLIBSUBDIRS)
162 ################################################################
163 # output the all: target
165 my %targets = (); # use a hash to get rid of duplicate target names
166 my %targets16 = ();
167 foreach my $mod (sort keys %directories)
169 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
170 $targets{$mod . ".so"} = 1;
171 next unless defined $altnames{$mod};
172 foreach my $i (sort @{$altnames{$mod}})
174 $targets16{$i . "16"} = $mod;
178 print NEWMAKE <<EOF;
180 \@MAKE_RULES\@
182 # Symbolic links
184 WIN16_FILES = \\
186 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
188 print NEWMAKE <<EOF;
190 SYMLINKS_SO = \\
191 \$(EXTRADIRS:%=%.dll.so) \\
192 \@WIN16_FILES\@ \\
194 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
196 print NEWMAKE <<EOF;
198 # Main target
200 all: symlinks\$(DLLEXT)
202 .PHONY: symlinks symlinks.so implib
204 symlinks.so: \$(SYMLINKS_SO)
206 symlinks: \$(BUILDSUBDIRS)
208 x11drv.dll.so: winex11.drv.so
209 \$(RM) \$@ && \$(LN_S) winex11.drv.so \$@
213 ################################################################
214 # output the lib name -> directory rules
216 print NEWMAKE <<EOF;
218 # Map symlink name to the corresponding library
222 foreach my $mod (sort keys %directories)
224 printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
225 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
227 if (defined $altnames{$mod})
229 my $count = 0;
230 foreach my $i (sort @{$altnames{$mod}})
232 if ($count++ == 3) { printf NEWMAKE "\\\n "; $count = 1; }
233 printf NEWMAKE "%s16 ", $i;
235 printf NEWMAKE ": %s.so\n", $mod;
236 printf NEWMAKE "\techo \"%s\" >\$\@\n\n", $mod;
240 ################################################################
241 # output the import libraries rules
243 print NEWMAKE "\n# Import libraries\n\n";
244 print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
246 my @lib_symlinks = ();
247 foreach my $mod (sort keys %importlibs)
249 my $dir = $directories{$mod};
250 my $lib = $importlibs{$mod};
251 if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
253 print NEWMAKE "IMPORT_SYMLINKS =";
254 foreach my $mod (sort @lib_symlinks)
256 printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
259 print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
260 foreach my $mod (sort keys %staticlib_dirs)
262 printf NEWMAKE " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod;
264 foreach my $mod (sort keys %importlibs)
266 my $dir = $directories{$mod};
267 my $def = $mod;
268 $def =~ s/\.(dll|drv)$//;
269 printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
270 printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
272 print NEWMAKE "\n\n";
273 print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n";
275 foreach my $mod (sort keys %importlibs)
277 my $dir = $directories{$mod};
278 my $lib = $importlibs{$mod};
279 my $spec = $mod;
280 $spec =~ s/\.dll$//;
281 printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
282 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
283 next unless $static_implibs{$mod};
284 printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
285 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
287 foreach my $mod (sort @lib_symlinks)
289 my $dir = $directories{$mod};
290 my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
291 printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib;
292 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
295 print NEWMAKE <<EOF;
296 \$(BUILDSUBDIRS): \$(IMPORT_LIBS)
297 \$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
301 ################################################################
302 # output the inter-dll dependencies and rules
304 print NEWMAKE "# Map library name to the corresponding directory\n\n";
306 foreach my $mod (sort keys %directories)
308 printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
310 foreach my $mod (sort keys %staticlib_dirs)
312 printf NEWMAKE "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod};
315 ################################################################
316 # makefile trailer
318 print NEWMAKE <<EOF;
320 # Rules for auto documentation
322 \$(SUBDIRS:%=%/__man__): dummy
323 cd `dirname \$@` && \$(MAKE) man
325 man: \$(SUBDIRS:%=%/__man__)
327 \$(SUBDIRS:%=%/__doc_html__): dummy
328 cd `dirname \$@` && \$(MAKE) doc-html
330 doc-html: \$(SUBDIRS:%=%/__doc_html__)
332 \$(SUBDIRS:%=%/__doc_sgml__): dummy
333 cd `dirname \$@` && \$(MAKE) doc-sgml
335 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
337 .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
339 # Misc rules
341 install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
343 install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
345 uninstall::
346 -rmdir \$(DESTDIR)\$(dlldir)
348 clean::
349 \$(RM) \$(IMPORT_SYMLINKS) \$(WIN16_FILES)
351 check test:: \$(BUILDSUBDIRS:%=%/__test__)
353 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
355 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
357 ### Dependencies:
360 close NEWMAKE;
361 rename "Makefile.in.new", "Makefile.in";
362 printf "Successfully updated Makefile.in\n";