SetMenu should always call SetWindowPos whether the window is visible
[wine] / dlls / make_dlls
1 #!/usr/bin/perl -w
2 #
3 # Update the dll dependencies in the dlls main Makefile.in.
4 # Must be run in the dlls/ directory of the Wine tree.
5 #
6 # Copyright 2001 Alexandre Julliard
7 #
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.
12 #
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.
17 #
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
21 #
22
23 use strict;
24
25 my $makefiles = `find . -name Makefile.in -print`;
26
27 my %directories = ();
28 my %implib_dirs = ();
29 my %altnames = ();
30
31 # list of special dlls that can be switched on or off by configure
32 my %special_dlls =
33 (
34   "ddraw"    => "XFILES",
35   "glu32"    => "GLU32FILES",
36   "glut32"   => "GLUT32FILES",
37   "opengl32" => "OPENGLFILES",
38   "d3d8"     => "OPENGLFILES",
39   "d3d9"     => "OPENGLFILES",
40   "d3dx8"    => "OPENGLFILES",
41   "wined3d"  => "OPENGLFILES",
42   "x11drv"   => "XFILES"
43 );
44
45 foreach my $i (split(/\s/,$makefiles))
46 {
47     my $module;
48
49     next if $i =~ /\/tests\/Makefile.in/;
50
51     open MAKE,$i;
52
53     $module = undef;
54     while (<MAKE>)
55     {
56         chop;
57         # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
58         # at the very top of the Makefile.in
59         last if (/^\#\s*MKDLL_SKIP/);
60
61         if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
62         {
63             $module = $1;
64             if ($module =~ /^lib.*\.a$/)
65             {
66                 ($implib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
67             }
68             else
69             {
70                 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
71             }
72             next;
73         }
74         if (/^ALTNAMES\s*=\s*(.*)/)
75         {
76             my @list = split(/\s/,$1);
77             $altnames{$module} = \@list;
78             next;
79         }
80     }
81     close MAKE;
82 }
83
84 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
85
86 ################################################################
87 # makefile header
88
89 print NEWMAKE <<EOF;
90 # Automatically generated by make_dlls; DO NOT EDIT!!
91
92 TOPSRCDIR = \@top_srcdir\@
93 TOPOBJDIR = ..
94 SRCDIR    = \@srcdir\@
95 VPATH     = \@srcdir\@
96
97 EOF
98
99 ################################################################
100 # output special dlls configure definitions
101
102 printf NEWMAKE "# special configure-dependent targets\n\n";
103 my %specials = ();
104 foreach my $mod (sort keys %special_dlls)
105 {
106     $specials{$special_dlls{$mod}} .= " " . $mod;
107 }
108 foreach my $i (sort keys %specials)
109 {
110     printf NEWMAKE "%s =%s\n", $i, $specials{$i};
111 }
112 printf NEWMAKE "EXTRADIRS =";
113 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
114 printf NEWMAKE "\n\n";
115
116
117 ################################################################
118 # output the subdirs list
119
120 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
121 foreach my $dir (sort values %directories)
122 {
123     next if defined($special_dlls{$dir});  # skip special dlls
124     printf NEWMAKE " \\\n\t%s", $dir;
125 }
126
127 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
128 foreach my $dir (sort (keys %special_dlls, values %implib_dirs))
129 {
130     printf NEWMAKE " \\\n\t%s", $dir;
131 }
132 printf NEWMAKE <<EOF;
133
134
135 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
136
137 INSTALLSUBDIRS = \$(BUILDSUBDIRS)
138 EOF
139
140 ################################################################
141 # output the all: target
142
143 my %targets = ();  # use a hash to get rid of duplicate target names
144 my %targets16 = ();
145 foreach my $mod (sort keys %directories)
146 {
147     next if defined($special_dlls{$directories{$mod}});  # skip special dlls
148     $targets{$mod . "\$(DLLEXT)"} = 1;
149     next unless defined $altnames{$mod};
150     foreach my $i (sort @{$altnames{$mod}})
151     {
152         $targets16{sprintf("%s\$(DLLEXT)",$i)} = 1;
153     }
154 }
155 foreach my $mod (sort keys %implib_dirs) { $targets{$mod} = 1; }
156
157 print NEWMAKE <<EOF;
158
159 \@MAKE_RULES\@
160
161 # Symbolic links
162
163 WIN16_FILES = \\
164 EOF
165 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
166
167 print NEWMAKE <<EOF;
168
169 SYMLINKS = \\
170         \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
171         \@WIN16_FILES\@ \\
172 EOF
173 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
174
175 print NEWMAKE <<EOF;
176
177 # Main target
178
179 all: \$(SYMLINKS)
180 EOF
181
182 ################################################################
183 # output the lib name -> directory rules
184
185 print NEWMAKE <<EOF;
186
187 # Map symlink name to the corresponding library
188
189 EOF
190
191 foreach my $mod (sort keys %directories)
192 {
193     printf NEWMAKE "%s\$(DLLEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod;
194     printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
195
196     if (defined $altnames{$mod})
197     {
198         my $count = 0;
199         foreach my $i (sort @{$altnames{$mod}})
200         {
201             if ($count++ == 3) { printf NEWMAKE "\\\n  "; $count = 1; }
202             printf NEWMAKE "%s\$(DLLEXT) ", $i;
203         }
204         printf NEWMAKE ": %s\$(DLLEXT)\n", $mod;
205         printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s\$(DLLEXT) \$@\n\n", $mod;
206     }
207 }
208 foreach my $mod (sort keys %implib_dirs)
209 {
210     printf NEWMAKE "%s: %s/%s\n", $mod, $implib_dirs{$mod}, $mod;
211     printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $implib_dirs{$mod}, $mod;
212 }
213
214 ################################################################
215 # output the import libraries rules
216
217 my @implibs = grep /\.dll$/, keys %directories;
218 push @implibs, "winspool.drv";
219
220 print NEWMAKE "\n# Import libraries\n\nIMPORT_LIBS =";
221 foreach my $mod (sort @implibs)
222 {
223     my $def = $mod;
224     $def =~ s/\.(dll|drv)$//;
225     printf NEWMAKE " \\\n\tlib%s", $def;
226 }
227 print NEWMAKE "\n\nALL_IMPORT_LIBS = \\\n\t\$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))";
228 foreach my $mod (sort keys %implib_dirs)
229 {
230     printf NEWMAKE " \\\n\t%s", $mod;
231 }
232 print NEWMAKE "\n\n";
233
234 foreach my $mod (sort @implibs)
235 {
236     my $dir = $directories{$mod};
237     my $def = $mod;
238     my $spec = $mod;
239     $spec =~ s/\.dll$//;
240     $def =~ s/\.(dll|drv)$//;
241     printf NEWMAKE "lib%s.def: %s/%s.spec.def\n", $def, $dir, $spec;
242     printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.spec.def \$@\n", $dir, $spec;
243     printf NEWMAKE "lib%s.a: %s/%s.spec.def\n", $def, $dir, $spec;
244     printf NEWMAKE "\t\$(DLLTOOL) -k -l \$@ -d %s/%s.spec.def\n\n", $dir, $spec;
245 }
246 foreach my $mod (sort @implibs)
247 {
248     my $dir = $directories{$mod};
249     my $spec = $mod;
250     $spec =~ s/\.dll$//;
251     printf NEWMAKE "%s/%s.spec.def: \$(WINEBUILD)\n", $dir, $spec;
252 }
253
254
255 print NEWMAKE <<EOF;
256
257 \$(BUILDSUBDIRS): \$(ALL_IMPORT_LIBS)
258 \$(INSTALLSUBDIRS:%=%/__install__): \$(ALL_IMPORT_LIBS)
259
260 EOF
261
262 ################################################################
263 # output the inter-dll dependencies and rules
264
265 print NEWMAKE "# Map library name to the corresponding directory\n\n";
266
267 foreach my $mod (sort keys %directories)
268 {
269     printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
270 }
271 foreach my $mod (sort keys %implib_dirs)
272 {
273     printf NEWMAKE "%s/%s: %s\n", $implib_dirs{$mod}, $mod, $implib_dirs{$mod};
274 }
275
276 ################################################################
277 # makefile trailer
278
279 print NEWMAKE <<EOF;
280
281 # Rules for auto documentation
282
283 \$(SUBDIRS:%=%/__man__): dummy
284         cd `dirname \$@` && \$(MAKE) man
285
286 man: \$(SUBDIRS:%=%/__man__)
287
288 \$(SUBDIRS:%=%/__doc_html__): dummy
289         cd `dirname \$@` && \$(MAKE) doc-html
290
291 doc-html: \$(SUBDIRS:%=%/__doc_html__)
292
293 \$(SUBDIRS:%=%/__doc_sgml__): dummy
294         cd `dirname \$@` && \$(MAKE) doc-sgml
295
296 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
297
298 .PHONY: man doc-html doc-sgml implib \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
299
300 # Misc rules
301
302 install install-dev:: \$(ALL_IMPORT_LIBS)
303         \$(MKINSTALLDIRS) \$(dlldir)
304         for f in \$(ALL_IMPORT_LIBS); do \$(INSTALL_DATA) \$\$f \$(dlldir)/\$\$f; done
305
306 install install-lib:: \$(INSTALLSUBDIRS:%=%/__install__)
307
308 uninstall::
309         \$(RM) \$(ALL_IMPORT_LIBS:%=\$(dlldir)/%)
310         -rmdir \$(dlldir)
311
312 implib: \$(ALL_IMPORT_LIBS)
313
314 clean::
315         \$(RM) \$(ALL_IMPORT_LIBS) \$(SYMLINKS)
316
317 check test:: \$(BUILDSUBDIRS:%=%/__test__)
318
319 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
320
321 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
322
323 ### Dependencies:
324 EOF
325
326 close NEWMAKE;
327 rename "Makefile.in.new", "Makefile.in";
328 printf "Successfully updated Makefile.in\n";