Created an ACM MS ADPCM codec.
[wine/wine-kai.git] / dlls / make_dlls
blob35f42fcf6631a83eb695748de31e2186a1e2c825
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 = ();
30 my %linked_dlls = ();
32 # list of special dlls that can be switched on or off by configure
33 my %special_dlls =
35 "ddraw" => "XFILES",
36 "glu32" => "GLU32FILES",
37 "opengl32" => "OPENGLFILES",
38 "x11drv" => "XFILES"
41 foreach my $i (split(/\s/,$makefiles))
43 my $module;
45 open MAKE,$i;
47 $module = undef;
48 while (<MAKE>)
50 chop;
51 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
52 # at the very top of the Makefile.in
53 last if (/^\#\s*MKDLL_SKIP/);
55 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
57 $module = $1;
58 $imports{$module} = [ ];
59 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
60 next;
62 if (/^ALTNAMES\s*=\s*(.*)/)
64 my @list = split(/\s/,$1);
65 $altnames{$module} = \@list;
66 next;
68 if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
70 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
71 push @{$imports{$module}}, @list;
72 next;
74 if (/^LDIMPORTS\s*=\s*(.*)/)
76 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1);
77 $linked_dlls{$module} = \@list;
78 next;
81 close MAKE;
82 push @{$imports{$module}}, "kernel32.dll" unless !defined($module) || @{$imports{$module}} || $module eq "ntdll.dll";
85 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
87 ################################################################
88 # makefile header
90 print NEWMAKE <<EOF;
91 # Automatically generated by make_dlls; DO NOT EDIT!!
93 TOPSRCDIR = \@top_srcdir\@
94 TOPOBJDIR = ..
95 SRCDIR = \@srcdir\@
96 VPATH = \@srcdir\@
98 EOF
100 ################################################################
101 # output special dlls configure definitions
103 printf NEWMAKE "# special configure-dependent targets\n\n";
104 my %specials = ();
105 foreach my $mod (sort keys %special_dlls)
107 $specials{$special_dlls{$mod}} .= " " . $mod;
109 foreach my $i (sort keys %specials)
111 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
113 printf NEWMAKE "EXTRADIRS =";
114 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
115 printf NEWMAKE "\n\n";
118 ################################################################
119 # output the subdirs list
121 print NEWMAKE <<EOF;
122 # Subdir list
124 SUBDIRS = \\
126 printf NEWMAKE "\t\$(EXTRADIRS)";
127 foreach my $dir (sort values %directories)
129 next if defined($special_dlls{$dir}); # skip special dlls
130 printf NEWMAKE " \\\n\t%s", $dir;
132 printf NEWMAKE "\n";
135 ################################################################
136 # output the all: target
138 my %targets = (); # use a hash to get rid of duplicate target names
139 foreach my $mod (sort keys %directories)
141 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
142 $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
143 next unless defined $altnames{$mod};
144 foreach my $i (sort @{$altnames{$mod}})
146 $targets{sprintf("%s\$(DLLEXT)",$i)} = 1;
149 print NEWMAKE <<EOF;
151 # Main target
153 \@MAKE_RULES\@
155 all: \\
156 \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
158 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
161 ################################################################
162 # output the lib name -> directory rules
164 print NEWMAKE <<EOF;
166 # Map library name to directory
170 foreach my $mod (sort keys %directories)
172 printf NEWMAKE "%s\$(DLLEXT)", $mod;
173 if (defined $altnames{$mod})
175 my $count = 1;
176 foreach my $i (sort @{$altnames{$mod}})
178 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
179 printf NEWMAKE " %s\$(DLLEXT)", $i;
182 printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
183 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
187 ################################################################
188 # output the inter-dll dependencies and rules
190 print NEWMAKE "# Inter-dll dependencies\n\n";
192 my @depends = ();
193 foreach my $mod (sort keys %imports)
195 my $count = 1;
196 my $dep = sprintf("%s/%s\$(DLLEXT): dummy", $directories{$mod}, $mod);
197 foreach my $i (@{$imports{$mod}})
199 if ($count++ >= 3)
201 $count = 0;
202 $dep .= " \\\n ";
204 $dep .= sprintf(" %s\$(DLLEXT)", $i);
206 foreach my $i (@{$linked_dlls{$mod}})
208 if ($count++ >= 3)
210 $count = 0;
211 $dep .= " \\\n ";
213 $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
215 $dep .= sprintf("\n\t\@cd %s && \$(MAKE) %s\$(DLLEXT)\n\n",$directories{$mod}, $mod);
216 push @depends, $dep;
218 print NEWMAKE sort @depends;
221 ################################################################
222 # output the linkable dlls special links
224 my %linkable_dlls = ();
225 foreach my $mod (keys %imports)
227 foreach my $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
230 print NEWMAKE "# Special targets for dlls that we need to link to\n\n";
231 foreach my $mod (keys %linkable_dlls)
233 printf NEWMAKE "lib%s.\$(LIBEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod;
234 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
237 ################################################################
238 # makefile trailer
240 print NEWMAKE <<EOF;
241 # Misc rules
243 \$(SUBDIRS:%=%/__checklink__): dummy
244 \@cd `dirname \$\@` && \$(MAKE) checklink
246 install:: \$(SUBDIRS:%=%/__install__)
248 uninstall:: \$(SUBDIRS:%=%/__uninstall__)
249 -rmdir \$(dlldir)
251 check test:: \$(SUBDIRS:%=%/__test__)
253 checklink:: \$(SUBDIRS:%=%/__checklink__)
256 close NEWMAKE;
257 rename "Makefile.in.new", "Makefile.in";
258 printf "Successfully updated Makefile.in\n";