- Added f8 (history retrieval from partial command) support
[wine/multimedia.git] / dlls / make_dlls
blobf08af42880a432c61f4bdc9feba3d4925302a37f
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 $makefiles = `find . -name Makefile.in -print`;
25 %imports = ();
26 %directories = ();
27 %altnames = ();
28 %linked_dlls = ();
30 # list of special dlls that can be switched on or off by configure
31 %special_dlls =
33 "ddraw" => "XFILES",
34 "glu32" => "GLU32FILES",
35 "opengl32" => "OPENGLFILES",
36 "x11drv" => "XFILES"
39 foreach $i (split(/\s/,$makefiles))
41 open MAKE,$i;
42 while (<MAKE>)
44 chop;
45 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
47 $module = $1;
48 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
49 next;
51 if (/^ALTNAMES\s*=\s*(.*)/)
53 my @list = split(/\s/,$1);
54 $altnames{$module} = \@list;
55 next;
57 if (/^IMPORTS\s*=\s*(.*)/)
59 my @list = split(/\s/,$1);
60 $linked_dlls{$module} = \@list;
61 next;
66 foreach $mod (sort keys %directories)
68 my $dll = $mod;
69 $dll =~ s/\.dll$//;
70 my $spec = sprintf("%s/%s.spec", $directories{$mod}, $dll);
71 open SPEC,$spec or die "cannot open $spec";
72 $imports{$mod} = [ ];
73 while (<SPEC>)
75 if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_]+)\.dll/)
77 my $imp = $2 . ".dll";
78 push @{$imports{$mod}}, $imp;
79 next;
81 if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_.]+)/)
83 my $imp = $2;
84 $imp .= ".dll" unless ($imp =~ /\./);
85 push @{$imports{$mod}}, $imp;
86 next;
91 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
93 ################################################################
94 # makefile header
96 print NEWMAKE <<EOF;
97 # Automatically generated by make_dlls; DO NOT EDIT!!
99 TOPSRCDIR = \@top_srcdir\@
100 TOPOBJDIR = ..
101 SRCDIR = \@srcdir\@
102 VPATH = \@srcdir\@
106 ################################################################
107 # output special dlls configure definitions
109 printf NEWMAKE "# special configure-dependent targets\n\n";
110 my %specials = ();
111 foreach $mod (sort keys %special_dlls)
113 $specials{$special_dlls{$mod}} .= " " . $mod;
115 foreach $i (sort keys %specials)
117 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
119 printf NEWMAKE "EXTRADIRS =";
120 foreach $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
121 printf NEWMAKE "\n\n";
124 ################################################################
125 # output the subdirs list
127 print NEWMAKE <<EOF;
128 # Subdir list
130 SUBDIRS = \\
132 printf NEWMAKE "\t\$(EXTRADIRS)";
133 foreach $dir (sort values %directories)
135 next if defined($special_dlls{$dir}); # skip special dlls
136 printf NEWMAKE " \\\n\t%s", $dir;
138 printf NEWMAKE "\n";
141 ################################################################
142 # output the all: target
144 my %targets = (); # use a hash to get rid of duplicate target names
145 foreach $mod (sort keys %directories)
147 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
148 $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
149 next unless defined $altnames{$mod};
150 foreach $i (sort @{$altnames{$mod}})
152 $targets{sprintf("%s\$(DLLEXT)",$i)} = 1;
155 print NEWMAKE <<EOF;
157 # Main target
159 \@MAKE_RULES\@
161 all: \\
162 \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
164 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
167 ################################################################
168 # output the lib name -> directory rules
170 print NEWMAKE <<EOF;
172 # Map library name to directory
176 foreach $mod (sort keys %directories)
178 printf NEWMAKE "%s\$(DLLEXT)", $mod;
179 if (defined $altnames{$mod})
181 my $count = 1;
182 foreach $i (sort @{$altnames{$mod}})
184 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
185 printf NEWMAKE " %s\$(DLLEXT)", $i;
188 printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
189 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
193 ################################################################
194 # output the inter-dll dependencies and rules
196 print NEWMAKE "# Inter-dll dependencies\n\n";
198 my @depends = ();
199 foreach $mod (sort keys %imports)
201 my $count = 1;
202 my $dep = sprintf("%s/%s\$(DLLEXT): dummy", $directories{$mod}, $mod);
203 foreach $i (@{$imports{$mod}})
205 if ($count++ >= 3)
207 $count = 0;
208 $dep .= " \\\n ";
210 $dep .= sprintf(" %s\$(DLLEXT)", $i);
212 foreach $i (@{$linked_dlls{$mod}})
214 if ($count++ >= 3)
216 $count = 0;
217 $dep .= " \\\n ";
219 $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
221 $dep .= sprintf("\n\t\@cd %s && \$(MAKE) %s\$(DLLEXT)\n\n",$directories{$mod}, $mod);
222 push @depends, $dep;
224 print NEWMAKE sort @depends;
227 ################################################################
228 # output the linkable dlls special links
230 %linkable_dlls = ();
231 foreach $mod (keys %imports)
233 foreach $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
236 print NEWMAKE "# Special targets for dlls that we need to link to\n\n";
237 foreach $mod (keys %linkable_dlls)
239 printf NEWMAKE "lib%s.\$(LIBEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod;
240 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
243 ################################################################
244 # makefile trailer
246 print NEWMAKE <<EOF;
247 # Misc rules
249 \$(SUBDIRS:%=%/__checklink__): dummy
250 \@cd `dirname \$\@` && \$(MAKE) checklink
252 \$(SUBDIRS:%=%/__debug_channels__): dummy
253 \@cd `dirname \$\@` && \$(MAKE) debug_channels
255 install:: \$(SUBDIRS:%=%/__install__)
257 uninstall:: \$(SUBDIRS:%=%/__uninstall__)
258 -rmdir \$(dlldir)
260 check test:: \$(SUBDIRS:%=%/__test__)
262 checklink:: \$(SUBDIRS:%=%/__checklink__)
264 debug_channels:: \$(SUBDIRS:%=%/__debug_channels__)
267 close NEWMAKE;
268 rename "Makefile.in.new", "Makefile.in";
269 printf "Successfully updated Makefile.in\n";