Added LGPL standard comment, and copyright notices where necessary.
[wine/multimedia.git] / dlls / make_dlls
blobd0979914b67ea6541de3a0cae61fe43bb015fdf1
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 = ();
29 # list of special dlls that can be switched on or off by configure
30 %special_dlls =
32 "ddraw" => "XFILES",
33 "glu32" => "GLU32FILES",
34 "opengl32" => "OPENGLFILES",
35 "x11drv" => "XFILES"
38 foreach $i (split(/\s/,$makefiles))
40 open MAKE,$i;
41 while (<MAKE>)
43 chop;
44 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
46 $module = $1;
47 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
48 next;
50 if (/^ALTNAMES\s*=\s*(.*)/)
52 my @list = split(/\s/,$1);
53 $altnames{$module} = \@list;
54 next;
59 foreach $mod (sort keys %directories)
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>)
66 if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_]+)\.dll/)
68 my $imp = $2;
69 push @{$imports{$mod}}, $imp;
70 next;
72 if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_.]+)/)
74 my $imp = $2;
75 push @{$imports{$mod}}, $imp;
76 next;
81 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
83 ################################################################
84 # makefile header
86 print NEWMAKE <<EOF;
87 # Automatically generated by make_dlls; DO NOT EDIT!!
89 TOPSRCDIR = \@top_srcdir\@
90 TOPOBJDIR = ..
91 SRCDIR = \@srcdir\@
92 VPATH = \@srcdir\@
93 LIBEXT = \@LIBEXT\@
95 EOF
97 ################################################################
98 # output special dlls configure definitions
100 printf NEWMAKE "# special configure-dependent targets\n\n";
101 my %specials = ();
102 foreach $mod (sort keys %special_dlls)
104 $specials{$special_dlls{$mod}} .= " " . $mod;
106 foreach $i (sort keys %specials)
108 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
110 printf NEWMAKE "EXTRADIRS =";
111 foreach $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
112 printf NEWMAKE "\n\n";
115 ################################################################
116 # output the subdirs list
118 print NEWMAKE <<EOF;
119 # Subdir list
121 SUBDIRS = \\
123 printf NEWMAKE "\t\$(EXTRADIRS)";
124 foreach $dir (sort values %directories)
126 next if defined($special_dlls{$dir}); # skip special dlls
127 printf NEWMAKE " \\\n\t%s", $dir;
129 printf NEWMAKE "\n";
132 ################################################################
133 # output the all: target
135 my %targets = (); # use a hash to get rid of duplicate target names
136 foreach $mod (sort keys %directories)
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}})
143 $targets{sprintf("lib%s.\$(LIBEXT)",$i)} = 1;
146 print NEWMAKE <<EOF;
148 # Main target
150 all: \\
151 \$(EXTRADIRS:%=lib%.\$(LIBEXT)) \\
153 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
156 ################################################################
157 # output the lib name -> directory rules
159 print NEWMAKE <<EOF;
161 \@MAKE_RULES\@
163 # Map library name to directory
167 foreach $mod (sort keys %directories)
169 printf NEWMAKE "lib%s.\$(LIBEXT)", $mod;
170 if (defined $altnames{$mod})
172 my $count = 1;
173 foreach $i (sort @{$altnames{$mod}})
175 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
176 printf NEWMAKE " lib%s.\$(LIBEXT)", $i;
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;
184 ################################################################
185 # output the inter-dll dependencies and rules
187 print NEWMAKE "# Inter-dll dependencies\n\n";
189 my @depends = ();
190 foreach $mod (sort keys %imports)
192 my $count = 1;
193 my $dep = sprintf("%s/lib%s.\$(LIBEXT): dummy", $directories{$mod}, $mod);
194 foreach $i (@{$imports{$mod}})
196 if ($count++ >= 3)
198 $count = 0;
199 $dep .= " \\\n ";
201 $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
203 $dep .= sprintf("\n\t\@cd %s && \$(MAKE) lib%s.\$(LIBEXT)\n\n",$directories{$mod}, $mod);
204 push @depends, $dep;
206 print NEWMAKE sort @depends;
209 ################################################################
210 # makefile trailer
212 print NEWMAKE <<EOF;
213 # Misc rules
215 \$(SUBDIRS:%=%/__test__): dummy
216 \@cd `dirname \$\@` && \$(MAKE) test
218 \$(SUBDIRS:%=%/__checklink__): dummy
219 \@cd `dirname \$\@` && \$(MAKE) checklink
221 \$(SUBDIRS:%=%/__debug_channels__): dummy
222 \@cd `dirname \$\@` && \$(MAKE) debug_channels
224 install:: \$(SUBDIRS:%=%/__install__)
226 uninstall:: \$(SUBDIRS:%=%/__uninstall__)
228 check test:: \$(SUBDIRS:%=%/__test__)
230 checklink:: \$(SUBDIRS:%=%/__checklink__)
232 debug_channels:: \$(SUBDIRS:%=%/__debug_channels__)
235 close NEWMAKE;
236 rename "Makefile.in.new", "Makefile.in";
237 printf "Successfully updated Makefile.in\n";