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
25 my $makefiles = `find . -name Makefile.in -print`;
32 # list of special dlls that can be switched on or off by configure
36 "glu32" => "GLU32FILES",
37 "opengl32" => "OPENGLFILES",
41 foreach my $i (split(/\s/,$makefiles))
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_.]+)/)
58 $imports{$module} = [ ];
59 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
62 if (/^ALTNAMES\s*=\s*(.*)/)
64 my @list = split(/\s/,$1);
65 $altnames{$module} = \@list;
68 if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
70 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
71 push @{$imports{$module}}, @list;
74 if (/^LDIMPORTS\s*=\s*(.*)/)
76 my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1);
77 $linked_dlls{$module} = \@list;
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 ################################################################
91 # Automatically generated by make_dlls; DO NOT EDIT!!
93 TOPSRCDIR = \@top_srcdir\@
100 ################################################################
101 # output special dlls configure definitions
103 printf NEWMAKE "# special configure-dependent targets\n\n";
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 "# Subdir list\n\nBASEDIRS =";
122 foreach my $dir (sort values %directories)
124 next if defined($special_dlls{$dir}); # skip special dlls
125 printf NEWMAKE " \\\n\t%s", $dir;
128 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
129 foreach my $dir (sort keys %special_dlls)
131 printf NEWMAKE " \\\n\t%s", $dir;
133 printf NEWMAKE <<EOF;
136 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
139 ################################################################
140 # output the all: target
142 my %targets = (); # use a hash to get rid of duplicate target names
143 foreach my $mod (sort keys %directories)
145 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
146 $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
147 next unless defined $altnames{$mod};
148 foreach my $i (sort @{$altnames{$mod}})
150 $targets{sprintf("%s\$(DLLEXT)",$i)} = 1;
160 \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
162 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
165 ################################################################
166 # output the lib name -> directory rules
170 # Map library name to directory
174 foreach my $mod (sort keys %directories)
176 printf NEWMAKE "%s\$(DLLEXT)", $mod;
177 if (defined $altnames{$mod})
180 foreach my $i (sort @{$altnames{$mod}})
182 if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
183 printf NEWMAKE " %s\$(DLLEXT)", $i;
186 printf NEWMAKE ": %s\n", $directories{$mod};
187 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
191 ################################################################
192 # output the inter-dll dependencies and rules
194 print NEWMAKE "# Inter-dll dependencies\n\n";
197 foreach my $mod (sort keys %imports)
200 my $dep = sprintf("%s:", $directories{$mod});
201 $dep .= " " x (8-length($directories{$mod}));
202 foreach my $i (@{$imports{$mod}})
207 $dep .= " \\\n" . " " x 9;
209 $dep .= sprintf(" %s\$(DLLEXT)", $i);
211 foreach my $i (@{$linked_dlls{$mod}})
216 $dep .= " \\\n" . " " x 9;
218 $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
220 push @depends, $dep . "\n";
222 print NEWMAKE sort @depends;
225 ################################################################
226 # output the linkable dlls special links
228 my %linkable_dlls = ();
229 foreach my $mod (keys %imports)
231 foreach my $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
234 print NEWMAKE "\n# Special targets for dlls that we need to link to\n\n";
235 foreach my $mod (keys %linkable_dlls)
237 printf NEWMAKE "lib%s.\$(LIBEXT): %s\n", $mod, $directories{$mod};
238 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
241 ################################################################
247 \$(BUILDSUBDIRS:%=%/__checklink__): dummy
248 \@cd `dirname \$\@` && \$(MAKE) checklink
250 install:: \$(BUILDSUBDIRS:%=%/__install__)
252 uninstall:: \$(BUILDSUBDIRS:%=%/__uninstall__)
255 check test:: \$(BUILDSUBDIRS:%=%/__test__)
257 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
261 rename "Makefile.in.new", "Makefile.in";
262 printf "Successfully updated Makefile.in\n";