3 # Update the dll dependencies in the dlls main Makefile.in.
5 # Copyright 2001 Alexandre Julliard
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 my %static_implibs = ();
28 my %staticlib_dirs = ();
31 # list of special dlls that can be switched on or off by configure
34 "glu32" => "GLU32FILES",
35 "glut32" => "GLUT32FILES",
36 "opengl32" => "OPENGLFILES",
37 "wined3d" => "OPENGLFILES",
38 "winex11.drv" => "XFILES"
43 (my $mod = $_[0]) =~ s/\.dll$//;
44 return $mod ne $directories{$_[0]};
50 if (!system "cmp $file $file.new >/dev/null")
53 print "$file is unchanged\n";
57 rename "$file.new", "$file";
58 print "$file updated\n";
59 if (-x "./config.status" && $file =~ /(.*Makefile)\.in$/)
61 system "./config.status", $1;
66 # if we are inside the dlls dir, go up one level
67 if (! -f "configure.ac" && -f "../configure.ac") { chdir(".."); }
70 if (!@args) { @args = map { s/^(.*)\.in/$1/; $_; } split(/\s/,`find dlls -name Makefile.in -print`); }
74 if ($i =~ /dlls\/(.*)\/tests\/Makefile/)
76 $testdirs{$1} = "$1/tests";
80 open MAKE, "$i.in" or die "cannot open $i.in\n";
88 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
89 # at the very top of the Makefile.in
90 last if (/^\#\s*MKDLL_SKIP/);
92 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
95 if ($module =~ /^lib.*\.a$/)
97 ($staticlib_dirs{$module} = $i) =~ s/^dlls\/(.*)\/[^\/]+$/$1/;
98 die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module;
102 ($directories{$module} = $i) =~ s/^dlls\/(.*)\/[^\/]+$/$1/;
106 if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
108 $importlibs{$module} = $1;
111 if (/^IMPLIB_SRCS\s*=/)
113 $static_implibs{$module} = 1;
116 if (/^SPEC_SRCS16\s*=\s*(.*)/)
119 while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; }
120 my @list = split(/\s+/,$specs);
121 @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
122 $altnames{$module} = \@list;
129 open NEWMAKE,">dlls/Makefile.in.new" or die "cannot create dlls/Makefile.in.new";
131 ################################################################
135 # Automatically generated by make_dlls; DO NOT EDIT!!
137 TOPSRCDIR = \@top_srcdir\@
144 ################################################################
145 # output special dlls configure definitions
147 printf NEWMAKE "# special configure-dependent targets\n\n";
149 foreach my $mod (sort keys %special_dlls)
151 $specials{$special_dlls{$mod}} .= " " . $mod;
153 foreach my $i (sort keys %specials)
155 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
157 printf NEWMAKE "EXTRADIRS =";
158 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
159 printf NEWMAKE "\n\n";
162 ################################################################
163 # output the subdirs list
165 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
166 foreach my $dir (sort values %directories)
168 next if defined($special_dlls{$dir}); # skip special dlls
169 printf NEWMAKE " \\\n\t%s", $dir;
172 print NEWMAKE "\n\nIMPLIBSUBDIRS = \\\n\t";
173 print NEWMAKE join " \\\n\t", sort values %staticlib_dirs;
175 print NEWMAKE "\n\nTESTSUBDIRS = \\\n\t";
176 print NEWMAKE join " \\\n\t", sort values %testdirs;
178 print NEWMAKE "\n\nSUBDIRS = \\\n\t";
179 print NEWMAKE join " \\\n\t", "\$(BASEDIRS)", "\$(IMPLIBSUBDIRS)", "\$(TESTSUBDIRS)",
180 sort keys %special_dlls;
184 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(TESTSUBDIRS)
185 INSTALLSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(IMPLIBSUBDIRS)
186 DOCSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
189 ################################################################
190 # output the all: target
192 my %targets = (); # use a hash to get rid of duplicate target names
194 foreach my $mod (sort keys %directories)
196 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
197 $targets{$mod . ".so"} = 1 if needs_symlink($mod);
198 next unless defined $altnames{$mod};
199 foreach my $i (sort @{$altnames{$mod}})
201 $targets16{$i . "16"} = $mod;
213 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
220 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
226 all: \$(BUILDSUBDIRS) symlinks\$(DLLEXT)
228 .PHONY: symlinks symlinks.so implib
230 symlinks.so: \$(SYMLINKS_SO)
232 symlinks: \$(BUILDSUBDIRS)
236 ################################################################
237 # output the lib name -> directory rules
239 print NEWMAKE "# Map symlink name to the corresponding library\n\n";
240 foreach my $mod (sort keys %directories)
242 next unless needs_symlink($mod);
243 printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
244 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
247 print NEWMAKE "# Placeholders for 16-bit libraries\n\n";
248 foreach my $mod (sort keys %directories)
250 next unless defined $altnames{$mod};
251 printf NEWMAKE "%s:\n", join(" ", map { $_ . "16"; } sort @{$altnames{$mod}});
252 printf NEWMAKE "\techo \"%s\" >\$\@\n\n", $mod;
255 ################################################################
256 # output the import libraries rules
258 print NEWMAKE "# Import libraries\n\n";
259 print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
261 my @lib_symlinks = ();
262 foreach my $mod (sort keys %importlibs)
264 my $dir = $directories{$mod};
265 my $lib = $importlibs{$mod};
266 if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
268 print NEWMAKE "IMPORT_SYMLINKS =";
269 foreach my $mod (sort @lib_symlinks)
271 printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
274 print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
275 foreach my $mod (sort keys %staticlib_dirs)
277 printf NEWMAKE " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod;
279 foreach my $mod (sort keys %importlibs)
281 my $dir = $directories{$mod};
283 $def =~ s/\.(dll|drv)$//;
284 printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
285 printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
287 print NEWMAKE "\n\n";
288 print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n";
290 foreach my $mod (sort keys %importlibs)
292 my $dir = $directories{$mod};
293 my $lib = $importlibs{$mod};
296 printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
297 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
298 next unless $static_implibs{$mod};
299 printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
300 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
302 foreach my $mod (sort @lib_symlinks)
304 my $dir = $directories{$mod};
305 my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
306 printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib;
307 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
311 \$(BUILDSUBDIRS): \$(IMPORT_LIBS)
312 \$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
316 ################################################################
317 # output the inter-dll dependencies and rules
319 print NEWMAKE "# Map library name to the corresponding directory\n\n";
321 foreach my $mod (sort keys %directories)
323 next unless needs_symlink($mod);
324 printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
326 foreach my $mod (sort keys %staticlib_dirs)
328 printf NEWMAKE "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod};
331 ################################################################
338 install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
340 install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
343 -rmdir \$(DESTDIR)\$(dlldir)
346 \$(RM) \$(IMPORT_SYMLINKS) \$(WIN16_FILES)
352 update_file("dlls/Makefile.in");
354 ################################################################
357 open GITIGNORE, ">dlls/.gitignore.new" or die "cannot create dlls/.gitignore.new";
358 print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n";
365 "*/tests/testlist.c",
369 foreach my $mod (sort @lib_symlinks)
371 push @ignores, "/$importlibs{$mod}.def";
373 foreach my $mod (sort keys %directories)
375 next unless defined $altnames{$mod};
376 push @ignores, map { "/" . $_ . "16"; } @{$altnames{$mod}};
378 foreach my $mod (sort keys %importlibs)
380 my $dir = $directories{$mod};
382 $def =~ s/\.(dll|drv)$//;
383 push @ignores, "$dir/lib$def.def";
386 print GITIGNORE join("\n", sort @ignores) . "\n";
389 update_file("dlls/.gitignore");