Update shell xxxAW wrapper prototypes for fixed SHLWAPI functions.
[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 $makefiles = `find . -name Makefile.in -print`;
24
25 %imports = ();
26 %directories = ();
27 %altnames = ();
28
29 # list of special dlls that can be switched on or off by configure
30 %special_dlls =
31 (
32   "ddraw"    => "XFILES",
33   "glu32"    => "GLU32FILES",
34   "opengl32" => "OPENGLFILES",
35   "x11drv"   => "XFILES"
36 );
37
38 foreach $i (split(/\s/,$makefiles))
39 {
40     open MAKE,$i;
41     while (<MAKE>)
42     {
43         chop;
44         if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
45         {
46             $module = $1;
47             ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
48             next;
49         }
50         if (/^ALTNAMES\s*=\s*(.*)/)
51         {
52             my @list = split(/\s/,$1);
53             $altnames{$module} = \@list;
54             next;
55         }
56     }
57 }
58
59 foreach $mod (sort keys %directories)
60 {
61     my $spec = sprintf("%s/%s.spec", $directories{$mod}, $mod);
62     open SPEC,$spec or die "cannot open $spec";
63     $imports{$mod} = [ ];
64     while (<SPEC>)
65     {
66         if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_]+)\.dll/)
67         {
68             my $imp = $2;
69             push @{$imports{$mod}}, $imp;
70             next;
71         }
72         if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_.]+)/)
73         {
74             my $imp = $2;
75             push @{$imports{$mod}}, $imp;
76             next;
77         }
78     }
79 }
80
81 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
82
83 ################################################################
84 # makefile header
85
86 print NEWMAKE <<EOF;
87 # Automatically generated by make_dlls; DO NOT EDIT!!
88
89 TOPSRCDIR = \@top_srcdir\@
90 TOPOBJDIR = ..
91 SRCDIR    = \@srcdir\@
92 VPATH     = \@srcdir\@
93 LIBEXT    = \@LIBEXT\@
94
95 EOF
96
97 ################################################################
98 # output special dlls configure definitions
99
100 printf NEWMAKE "# special configure-dependent targets\n\n";
101 my %specials = ();
102 foreach $mod (sort keys %special_dlls)
103 {
104     $specials{$special_dlls{$mod}} .= " " . $mod;
105 }
106 foreach $i (sort keys %specials)
107 {
108     printf NEWMAKE "%s =%s\n", $i, $specials{$i};
109 }
110 printf NEWMAKE "EXTRADIRS =";
111 foreach $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
112 printf NEWMAKE "\n\n";
113
114
115 ################################################################
116 # output the subdirs list
117
118 print NEWMAKE <<EOF;
119 # Subdir list
120
121 SUBDIRS = \\
122 EOF
123 printf NEWMAKE "\t\$(EXTRADIRS)";
124 foreach $dir (sort values %directories)
125 {
126     next if defined($special_dlls{$dir});  # skip special dlls
127     printf NEWMAKE " \\\n\t%s", $dir;
128 }
129 printf NEWMAKE "\n";
130
131
132 ################################################################
133 # output the all: target
134
135 my %targets = ();  # use a hash to get rid of duplicate target names
136 foreach $mod (sort keys %directories)
137 {
138     next if defined($special_dlls{$mod});  # skip special dlls
139     $targets{sprintf("lib%s.\$(LIBEXT)",$mod)} = 1;
140     next unless defined $altnames{$mod};
141     foreach $i (sort @{$altnames{$mod}})
142     {
143         $targets{sprintf("lib%s.\$(LIBEXT)",$i)} = 1;
144     }
145 }
146 print NEWMAKE <<EOF;
147
148 # Main target
149
150 all: \\
151         \$(EXTRADIRS:%=lib%.\$(LIBEXT)) \\
152 EOF
153 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
154
155
156 ################################################################
157 # output the lib name -> directory rules
158
159 print NEWMAKE <<EOF;
160
161 \@MAKE_RULES\@
162
163 # Map library name to directory
164
165 EOF
166
167 foreach $mod (sort keys %directories)
168 {
169     printf NEWMAKE "lib%s.\$(LIBEXT)", $mod;
170     if (defined $altnames{$mod})
171     {
172         my $count = 1;
173         foreach $i (sort @{$altnames{$mod}})
174         {
175             if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
176             printf NEWMAKE " lib%s.\$(LIBEXT)", $i;
177         }
178     }
179     printf NEWMAKE ": %s/lib%s.\$(LIBEXT)\n", $directories{$mod}, $mod;
180     printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/lib%s.\$(LIBEXT) \$@\n\n", $directories{$mod}, $mod;
181 }
182
183
184 ################################################################
185 # output the inter-dll dependencies and rules
186
187 print NEWMAKE "# Inter-dll dependencies\n\n";
188
189 my @depends = ();
190 foreach $mod (sort keys %imports)
191 {
192     my $count = 1;
193     my $dep = sprintf("%s/lib%s.\$(LIBEXT): dummy", $directories{$mod}, $mod);
194     foreach $i (@{$imports{$mod}})
195     {
196         if ($count++ >= 3)
197         {
198             $count = 0;
199             $dep .= " \\\n ";
200         }
201         $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
202     }
203     $dep .= sprintf("\n\t\@cd %s && \$(MAKE) lib%s.\$(LIBEXT)\n\n",$directories{$mod}, $mod);
204     push @depends, $dep;
205 }
206 print NEWMAKE sort @depends;
207
208
209 ################################################################
210 # makefile trailer
211
212 print NEWMAKE <<EOF;
213 # Misc rules
214
215 \$(SUBDIRS:%=%/__test__): dummy
216         \@cd `dirname \$\@` && \$(MAKE) test
217
218 \$(SUBDIRS:%=%/__checklink__): dummy
219         \@cd `dirname \$\@` && \$(MAKE) checklink
220
221 \$(SUBDIRS:%=%/__debug_channels__): dummy
222         \@cd `dirname \$\@` && \$(MAKE) debug_channels
223
224 install:: \$(SUBDIRS:%=%/__install__)
225
226 uninstall:: \$(SUBDIRS:%=%/__uninstall__)
227
228 check test:: \$(SUBDIRS:%=%/__test__)
229
230 checklink:: \$(SUBDIRS:%=%/__checklink__)
231
232 debug_channels:: \$(SUBDIRS:%=%/__debug_channels__)
233 EOF
234
235 close NEWMAKE;
236 rename "Makefile.in.new", "Makefile.in";
237 printf "Successfully updated Makefile.in\n";