msi: Add a FIXME for join queries.
[wine/hacks.git] / dlls / make_dlls
blob9bd371096c550b2a3b6aae72cc05e1d80051dd2b
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 "glu32" => "GLU32FILES",
37 "glut32" => "GLUT32FILES",
38 "opengl32" => "OPENGLFILES",
39 "wined3d" => "OPENGLFILES",
40 "winex11.drv" => "XFILES"
43 sub needs_symlink($)
45 (my $mod = $_[0]) =~ s/\.dll$//;
46 return $mod ne $directories{$_[0]};
49 foreach my $i (split(/\s/,$makefiles))
51 my $module;
53 next if $i =~ /\/tests\/Makefile.in/;
55 open MAKE,$i;
57 $module = undef;
58 while (<MAKE>)
60 chop;
61 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
62 # at the very top of the Makefile.in
63 last if (/^\#\s*MKDLL_SKIP/);
65 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
67 $module = $1;
68 if ($module =~ /^lib.*\.a$/)
70 ($staticlib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
71 die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module;
73 else
75 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
77 next;
79 if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
81 $importlibs{$module} = $1;
82 next;
84 if (/^IMPLIB_SRCS\s*=/)
86 $static_implibs{$module} = 1;
87 next;
89 if (/^SPEC_SRCS16\s*=\s*(.*)/)
91 my $specs = $1;
92 while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; }
93 my @list = split(/\s+/,$specs);
94 @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
95 $altnames{$module} = \@list;
96 next;
99 close MAKE;
102 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
104 ################################################################
105 # makefile header
107 print NEWMAKE <<EOF;
108 # Automatically generated by make_dlls; DO NOT EDIT!!
110 TOPSRCDIR = \@top_srcdir\@
111 TOPOBJDIR = ..
112 SRCDIR = \@srcdir\@
113 VPATH = \@srcdir\@
117 ################################################################
118 # output special dlls configure definitions
120 printf NEWMAKE "# special configure-dependent targets\n\n";
121 my %specials = ();
122 foreach my $mod (sort keys %special_dlls)
124 $specials{$special_dlls{$mod}} .= " " . $mod;
126 foreach my $i (sort keys %specials)
128 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
130 printf NEWMAKE "EXTRADIRS =";
131 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
132 printf NEWMAKE "\n\n";
135 ################################################################
136 # output the subdirs list
138 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
139 foreach my $dir (sort values %directories)
141 next if defined($special_dlls{$dir}); # skip special dlls
142 printf NEWMAKE " \\\n\t%s", $dir;
145 printf NEWMAKE "\n\nIMPLIBSUBDIRS =";
146 foreach my $dir (sort values %staticlib_dirs)
148 printf NEWMAKE " \\\n\t%s", $dir;
151 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS) \\\n\t\$(IMPLIBSUBDIRS)";
152 foreach my $dir (sort keys %special_dlls)
154 printf NEWMAKE " \\\n\t%s", $dir;
156 printf NEWMAKE <<EOF;
159 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
161 INSTALLSUBDIRS = \$(BUILDSUBDIRS) \$(IMPLIBSUBDIRS)
164 ################################################################
165 # output the all: target
167 my %targets = (); # use a hash to get rid of duplicate target names
168 my %targets16 = ();
169 foreach my $mod (sort keys %directories)
171 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
172 $targets{$mod . ".so"} = 1 if needs_symlink($mod);
173 next unless defined $altnames{$mod};
174 foreach my $i (sort @{$altnames{$mod}})
176 $targets16{$i . "16"} = $mod;
180 print NEWMAKE <<EOF;
182 \@MAKE_RULES\@
184 # Symbolic links
186 WIN16_FILES = \\
188 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
190 print NEWMAKE <<EOF;
192 SYMLINKS_SO = \\
193 \@WIN16_FILES\@ \\
195 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
197 print NEWMAKE <<EOF;
199 # Main target
201 all: \$(BUILDSUBDIRS) symlinks\$(DLLEXT)
203 .PHONY: symlinks symlinks.so implib
205 symlinks.so: \$(SYMLINKS_SO)
207 symlinks: \$(BUILDSUBDIRS)
211 ################################################################
212 # output the lib name -> directory rules
214 print NEWMAKE "# Map symlink name to the corresponding library\n\n";
215 foreach my $mod (sort keys %directories)
217 next unless needs_symlink($mod);
218 printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
219 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
222 print NEWMAKE "# Placeholders for 16-bit libraries\n\n";
223 foreach my $mod (sort keys %directories)
225 next unless defined $altnames{$mod};
226 printf NEWMAKE "%s:\n", join(" ", map { $_ . "16"; } sort @{$altnames{$mod}});
227 printf NEWMAKE "\techo \"%s\" >\$\@\n\n", $mod;
230 ################################################################
231 # output the import libraries rules
233 print NEWMAKE "# Import libraries\n\n";
234 print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
236 my @lib_symlinks = ();
237 foreach my $mod (sort keys %importlibs)
239 my $dir = $directories{$mod};
240 my $lib = $importlibs{$mod};
241 if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
243 print NEWMAKE "IMPORT_SYMLINKS =";
244 foreach my $mod (sort @lib_symlinks)
246 printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
249 print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
250 foreach my $mod (sort keys %staticlib_dirs)
252 printf NEWMAKE " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod;
254 foreach my $mod (sort keys %importlibs)
256 my $dir = $directories{$mod};
257 my $def = $mod;
258 $def =~ s/\.(dll|drv)$//;
259 printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
260 printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
262 print NEWMAKE "\n\n";
263 print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n";
265 foreach my $mod (sort keys %importlibs)
267 my $dir = $directories{$mod};
268 my $lib = $importlibs{$mod};
269 my $spec = $mod;
270 $spec =~ s/\.dll$//;
271 printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
272 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
273 next unless $static_implibs{$mod};
274 printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
275 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
277 foreach my $mod (sort @lib_symlinks)
279 my $dir = $directories{$mod};
280 my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
281 printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib;
282 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
285 print NEWMAKE <<EOF;
286 \$(BUILDSUBDIRS): \$(IMPORT_LIBS)
287 \$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
291 ################################################################
292 # output the inter-dll dependencies and rules
294 print NEWMAKE "# Map library name to the corresponding directory\n\n";
296 foreach my $mod (sort keys %directories)
298 next unless needs_symlink($mod);
299 printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
301 foreach my $mod (sort keys %staticlib_dirs)
303 printf NEWMAKE "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod};
306 ################################################################
307 # makefile trailer
309 print NEWMAKE <<EOF;
311 # Rules for auto documentation
313 \$(SUBDIRS:%=%/__man__): dummy
314 cd `dirname \$@` && \$(MAKE) man
316 man: \$(SUBDIRS:%=%/__man__)
318 \$(SUBDIRS:%=%/__doc_html__): dummy
319 cd `dirname \$@` && \$(MAKE) doc-html
321 doc-html: \$(SUBDIRS:%=%/__doc_html__)
323 \$(SUBDIRS:%=%/__doc_sgml__): dummy
324 cd `dirname \$@` && \$(MAKE) doc-sgml
326 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
328 .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
330 # Misc rules
332 install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
334 install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
336 uninstall::
337 -rmdir \$(DESTDIR)\$(dlldir)
339 clean::
340 \$(RM) \$(IMPORT_SYMLINKS) \$(WIN16_FILES)
342 check test:: \$(BUILDSUBDIRS:%=%/__test__)
344 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
346 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
348 ### Dependencies:
351 close NEWMAKE;
352 rename "Makefile.in.new", "Makefile.in";
353 printf "Successfully updated Makefile.in\n";
355 ################################################################
356 # .gitignore file
358 open GITIGNORE, ">.gitignore.new" or die "cannot create .gitignore.new";
359 print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n";
361 my @ignores =
363 "/Makedll.rules",
364 "/Makeimplib.rules",
365 "/Maketest.rules",
366 "*/tests/testlist.c",
367 "*/tests/*.ok",
370 foreach my $mod (sort @lib_symlinks)
372 push @ignores, "/$importlibs{$mod}.def";
374 foreach my $mod (sort keys %directories)
376 next unless defined $altnames{$mod};
377 push @ignores, map { "/" . $_ . "16"; } @{$altnames{$mod}};
379 foreach my $mod (sort keys %importlibs)
381 my $dir = $directories{$mod};
382 my $def = $mod;
383 $def =~ s/\.(dll|drv)$//;
384 push @ignores, "$dir/lib$def.def";
387 print GITIGNORE join("\n", sort @ignores) . "\n";
389 close GITIGNORE;
390 rename ".gitignore.new", ".gitignore";
391 printf "Successfully updated .gitignore\n";