Sql tokens are case insensitive in msi.dll.
[wine/wine64.git] / dlls / make_dlls
blob6c3c01a99919bce0c7eb4749c28fb40271ae4e2d
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 = ();
31 # list of special dlls that can be switched on or off by configure
32 my %special_dlls =
34 "ddraw" => "XFILES",
35 "glu32" => "GLU32FILES",
36 "opengl32" => "OPENGLFILES",
37 "d3d8" => "OPENGLFILES",
38 "d3d9" => "OPENGLFILES",
39 "d3dx8" => "OPENGLFILES",
40 "x11drv" => "XFILES"
43 foreach my $i (split(/\s/,$makefiles))
45 my $module;
47 next if $i =~ /\/tests\/Makefile.in/;
49 open MAKE,$i;
51 $module = undef;
52 while (<MAKE>)
54 chop;
55 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
56 # at the very top of the Makefile.in
57 last if (/^\#\s*MKDLL_SKIP/);
59 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
61 $module = $1;
62 $imports{$module} = [ ];
63 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
64 next;
66 if (/^ALTNAMES\s*=\s*(.*)/)
68 my @list = split(/\s/,$1);
69 $altnames{$module} = \@list;
70 next;
72 if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
74 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
75 push @{$imports{$module}}, @list;
76 next;
79 close MAKE;
80 push @{$imports{$module}}, "kernel32.dll" unless !defined($module) || @{$imports{$module}} || $module eq "ntdll.dll";
83 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
85 ################################################################
86 # makefile header
88 print NEWMAKE <<EOF;
89 # Automatically generated by make_dlls; DO NOT EDIT!!
91 TOPSRCDIR = \@top_srcdir\@
92 TOPOBJDIR = ..
93 SRCDIR = \@srcdir\@
94 VPATH = \@srcdir\@
96 EOF
98 ################################################################
99 # output special dlls configure definitions
101 printf NEWMAKE "# special configure-dependent targets\n\n";
102 my %specials = ();
103 foreach my $mod (sort keys %special_dlls)
105 $specials{$special_dlls{$mod}} .= " " . $mod;
107 foreach my $i (sort keys %specials)
109 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
111 printf NEWMAKE "EXTRADIRS =";
112 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
113 printf NEWMAKE "\n\n";
116 ################################################################
117 # output the subdirs list
119 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
120 foreach my $dir (sort values %directories)
122 next if defined($special_dlls{$dir}); # skip special dlls
123 printf NEWMAKE " \\\n\t%s", $dir;
126 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
127 foreach my $dir (sort keys %special_dlls)
129 printf NEWMAKE " \\\n\t%s", $dir;
131 printf NEWMAKE <<EOF;
134 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
136 INSTALLSUBDIRS = \$(BUILDSUBDIRS)
139 ################################################################
140 # output the all: target
142 my %targets = (); # use a hash to get rid of duplicate target names
143 my %targets16 = ();
144 foreach my $mod (sort keys %directories)
146 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
147 $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
148 next unless defined $altnames{$mod};
149 foreach my $i (sort @{$altnames{$mod}})
151 $targets16{sprintf("%s\$(DLLEXT)",$i)} = 1;
154 print NEWMAKE <<EOF;
156 \@MAKE_RULES\@
158 # Symbolic links
160 WIN16_FILES = \\
162 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
164 print NEWMAKE <<EOF;
166 SYMLINKS = \\
167 \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
168 \@WIN16_FILES\@ \\
170 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
172 print NEWMAKE <<EOF;
174 # Main target
176 all: \$(SYMLINKS)
179 ################################################################
180 # output the lib name -> directory rules
182 print NEWMAKE <<EOF;
184 # Map symlink name to the corresponding library
188 foreach my $mod (sort keys %directories)
190 printf NEWMAKE "%s\$(DLLEXT)", $mod;
191 if (defined $altnames{$mod})
193 my $count = 1;
194 foreach my $i (sort @{$altnames{$mod}})
196 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
197 printf NEWMAKE " %s\$(DLLEXT)", $i;
200 printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
201 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
205 ################################################################
206 # output the import libraries rules
208 my @implibs = grep /\.dll$/, keys %directories;
209 push @implibs, "winspool.drv";
211 print NEWMAKE "\n# Import libraries\n\nIMPORT_LIBS =";
212 foreach my $mod (sort @implibs)
214 my $def = $mod;
215 $def =~ s/\.(dll|drv)$//;
216 printf NEWMAKE " \\\n\tlib%s", $def;
218 print NEWMAKE "\n\n";
220 foreach my $mod (sort @implibs)
222 my $dir = $directories{$mod};
223 my $def = $mod;
224 my $spec = $mod;
225 $spec =~ s/\.dll$//;
226 $def =~ s/\.(dll|drv)$//;
227 printf NEWMAKE "lib%s.def: %s/%s.spec.def\n", $def, $dir, $spec;
228 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.spec.def \$@\n", $dir, $spec;
229 printf NEWMAKE "lib%s.a: %s/%s.spec.def\n", $def, $dir, $spec;
230 printf NEWMAKE "\t\$(DLLTOOL) -k -l \$@ -d %s/%s.spec.def\n\n", $dir, $spec;
232 foreach my $mod (sort @implibs)
234 my $dir = $directories{$mod};
235 my $spec = $mod;
236 $spec =~ s/\.dll$//;
237 printf NEWMAKE "%s/%s.spec.def: \$(WINEBUILD)\n", $dir, $spec;
241 print NEWMAKE <<EOF;
243 \$(SUBDIRS): \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))
244 \$(SUBDIRS:%=%/__install__): \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))
245 \$(SUBDIRS:%=%/__crosstest__): \$(IMPORT_LIBS:%=%.a)
249 ################################################################
250 # output the inter-dll dependencies and rules
252 print NEWMAKE "# Map library name to the corresponding directory\n\n";
254 foreach my $mod (sort keys %directories)
256 printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
259 ################################################################
260 # makefile trailer
262 print NEWMAKE <<EOF;
263 # Rules for auto documentation
265 \$(SUBDIRS:%=%/__man__): dummy
266 cd `dirname \$@` && \$(MAKE) man
268 man: \$(SUBDIRS:%=%/__man__)
270 \$(SUBDIRS:%=%/__doc_html__): dummy
271 cd `dirname \$@` && \$(MAKE) doc-html
273 doc-html: \$(SUBDIRS:%=%/__doc_html__)
275 \$(SUBDIRS:%=%/__doc_sgml__): dummy
276 cd `dirname \$@` && \$(MAKE) doc-sgml
278 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
280 .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
282 # Misc rules
284 install install-dev:: \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))
285 \$(MKINSTALLDIRS) \$(dlldir)
286 for f in \$(IMPORT_LIBS:%=%.\$(IMPLIBEXT)); do \$(INSTALL_DATA) \$\$f \$(dlldir)/\$\$f; done
288 install install-lib:: \$(INSTALLSUBDIRS:%=%/__install__)
290 uninstall::
291 \$(RM) \$(IMPORT_LIBS:%=\$(dlldir)/%.\$(IMPLIBEXT))
292 -rmdir \$(dlldir)
294 clean::
295 \$(RM) \$(IMPORT_LIBS:%=%.a) \$(IMPORT_LIBS:%=%.def) \$(SYMLINKS)
297 check test:: \$(BUILDSUBDIRS:%=%/__test__)
299 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
301 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
303 ### Dependencies:
306 close NEWMAKE;
307 rename "Makefile.in.new", "Makefile.in";
308 printf "Successfully updated Makefile.in\n";