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";
62 # if we are inside the dlls dir, go up one level
63 if (! -f
"configure.ac" && -f
"../configure.ac") { chdir(".."); }
65 my $makefiles = `find dlls -name Makefile.in -print`;
67 foreach my $i (split(/\s/,$makefiles))
69 if ($i =~ /dlls\/(.*)\
/tests\/Makefile
.in/)
71 $testdirs{$1} = "$1/tests";
83 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
84 # at the very top of the Makefile.in
85 last if (/^\#\s*MKDLL_SKIP/);
87 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
90 if ($module =~ /^lib.*\.a$/)
92 ($staticlib_dirs{$module} = $i) =~ s/^dlls\/(.*)\/[^\
/]+$/$1/;
93 die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module;
97 ($directories{$module} = $i) =~ s/^dlls\/(.*)\/[^\
/]+$/$1/;
101 if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
103 $importlibs{$module} = $1;
106 if (/^IMPLIB_SRCS\s*=/)
108 $static_implibs{$module} = 1;
111 if (/^SPEC_SRCS16\s*=\s*(.*)/)
114 while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE
>; }
115 my @list = split(/\s+/,$specs);
116 @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
117 $altnames{$module} = \
@list;
124 open NEWMAKE
,">dlls/Makefile.in.new" or die "cannot create dlls/Makefile.in.new";
126 ################################################################
130 # Automatically generated by make_dlls; DO NOT EDIT!!
132 TOPSRCDIR = \@top_srcdir\@
139 ################################################################
140 # output special dlls configure definitions
142 printf NEWMAKE
"# special configure-dependent targets\n\n";
144 foreach my $mod (sort keys %special_dlls)
146 $specials{$special_dlls{$mod}} .= " " . $mod;
148 foreach my $i (sort keys %specials)
150 printf NEWMAKE
"%s =%s\n", $i, $specials{$i};
152 printf NEWMAKE
"EXTRADIRS =";
153 foreach my $i (sort keys %specials) { printf NEWMAKE
" \@%s\@", $i; }
154 printf NEWMAKE
"\n\n";
157 ################################################################
158 # output the subdirs list
160 print NEWMAKE
"# Subdir list\n\nBASEDIRS =";
161 foreach my $dir (sort values %directories)
163 next if defined($special_dlls{$dir}); # skip special dlls
164 printf NEWMAKE
" \\\n\t%s", $dir;
167 printf NEWMAKE
"\n\nIMPLIBSUBDIRS =";
168 foreach my $dir (sort values %staticlib_dirs)
170 printf NEWMAKE
" \\\n\t%s", $dir;
173 printf NEWMAKE
"\n\nSUBDIRS = \\\n\t\$(BASEDIRS) \\\n\t\$(IMPLIBSUBDIRS)";
174 foreach my $dir (sort keys %special_dlls)
176 printf NEWMAKE
" \\\n\t%s", $dir;
178 printf NEWMAKE
<<EOF;
181 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
183 INSTALLSUBDIRS = \$(BUILDSUBDIRS) \$(IMPLIBSUBDIRS)
186 ################################################################
187 # output the all: target
189 my %targets = (); # use a hash to get rid of duplicate target names
191 foreach my $mod (sort keys %directories)
193 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
194 $targets{$mod . ".so"} = 1 if needs_symlink
($mod);
195 next unless defined $altnames{$mod};
196 foreach my $i (sort @
{$altnames{$mod}})
198 $targets16{$i . "16"} = $mod;
210 printf NEWMAKE
"\t%s\n", join( " \\\n\t", sort keys %targets16 );
217 printf NEWMAKE
"\t%s\n", join( " \\\n\t", sort keys %targets );
223 all: \$(BUILDSUBDIRS) symlinks\$(DLLEXT)
225 .PHONY: symlinks symlinks.so implib
227 symlinks.so: \$(SYMLINKS_SO)
229 symlinks: \$(BUILDSUBDIRS)
233 ################################################################
234 # output the lib name -> directory rules
236 print NEWMAKE
"# Map symlink name to the corresponding library\n\n";
237 foreach my $mod (sort keys %directories)
239 next unless needs_symlink
($mod);
240 printf NEWMAKE
"%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
241 printf NEWMAKE
"\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
244 print NEWMAKE
"# Placeholders for 16-bit libraries\n\n";
245 foreach my $mod (sort keys %directories)
247 next unless defined $altnames{$mod};
248 printf NEWMAKE
"%s:\n", join(" ", map { $_ . "16"; } sort @
{$altnames{$mod}});
249 printf NEWMAKE
"\techo \"%s\" >\$\@\n\n", $mod;
252 ################################################################
253 # output the import libraries rules
255 print NEWMAKE
"# Import libraries\n\n";
256 print NEWMAKE
"STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
258 my @lib_symlinks = ();
259 foreach my $mod (sort keys %importlibs)
261 my $dir = $directories{$mod};
262 my $lib = $importlibs{$mod};
263 if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
265 print NEWMAKE
"IMPORT_SYMLINKS =";
266 foreach my $mod (sort @lib_symlinks)
268 printf NEWMAKE
" \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
271 print NEWMAKE
"\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
272 foreach my $mod (sort keys %staticlib_dirs)
274 printf NEWMAKE
" \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod;
276 foreach my $mod (sort keys %importlibs)
278 my $dir = $directories{$mod};
280 $def =~ s/\.(dll|drv)$//;
281 printf NEWMAKE
" \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
282 printf NEWMAKE
" \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
284 print NEWMAKE
"\n\n";
285 print NEWMAKE
"implib: \$(IMPORT_LIBS)\n\n";
287 foreach my $mod (sort keys %importlibs)
289 my $dir = $directories{$mod};
290 my $lib = $importlibs{$mod};
293 printf NEWMAKE
"%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
294 printf NEWMAKE
"\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
295 next unless $static_implibs{$mod};
296 printf NEWMAKE
"%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
297 printf NEWMAKE
"\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
299 foreach my $mod (sort @lib_symlinks)
301 my $dir = $directories{$mod};
302 my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
303 printf NEWMAKE
"%s: %s/%s\n", $lib, $dir, $lib;
304 printf NEWMAKE
"\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
308 \$(BUILDSUBDIRS): \$(IMPORT_LIBS)
309 \$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
313 ################################################################
314 # output the inter-dll dependencies and rules
316 print NEWMAKE
"# Map library name to the corresponding directory\n\n";
318 foreach my $mod (sort keys %directories)
320 next unless needs_symlink
($mod);
321 printf NEWMAKE
"%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
323 foreach my $mod (sort keys %staticlib_dirs)
325 printf NEWMAKE
"%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod};
328 ################################################################
333 # Rules for auto documentation
335 \$(SUBDIRS:%=%/__man__): dummy
336 cd `dirname \$@` && \$(MAKE) man
338 man: \$(SUBDIRS:%=%/__man__)
340 \$(SUBDIRS:%=%/__doc_html__): dummy
341 cd `dirname \$@` && \$(MAKE) doc-html
343 doc-html: \$(SUBDIRS:%=%/__doc_html__)
345 \$(SUBDIRS:%=%/__doc_sgml__): dummy
346 cd `dirname \$@` && \$(MAKE) doc-sgml
348 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
350 .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
354 install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
356 install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
359 -rmdir \$(DESTDIR)\$(dlldir)
362 \$(RM) \$(IMPORT_SYMLINKS) \$(WIN16_FILES)
364 check test:: \$(BUILDSUBDIRS:%=%/__test__)
366 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
368 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
374 update_file
("dlls/Makefile.in");
376 ################################################################
379 open GITIGNORE
, ">dlls/.gitignore.new" or die "cannot create dlls/.gitignore.new";
380 print GITIGNORE
"# Automatically generated by make_dlls; DO NOT EDIT!!\n";
387 "*/tests/testlist.c",
391 foreach my $mod (sort @lib_symlinks)
393 push @ignores, "/$importlibs{$mod}.def";
395 foreach my $mod (sort keys %directories)
397 next unless defined $altnames{$mod};
398 push @ignores, map { "/" . $_ . "16"; } @
{$altnames{$mod}};
400 foreach my $mod (sort keys %importlibs)
402 my $dir = $directories{$mod};
404 $def =~ s/\.(dll|drv)$//;
405 push @ignores, "$dir/lib$def.def";
408 print GITIGNORE
join("\n", sort @ignores) . "\n";
411 update_file
("dlls/.gitignore");
413 ################################################################
416 open OLD_CONFIG
, "configure.ac" or die "cannot open configure.ac";
417 open NEW_CONFIG
, ">configure.ac.new" or die "cannot create configure.ac.new";
422 last if /^dlls\/Makefile
/;
425 foreach my $dir (sort (values %directories, values %staticlib_dirs, values %testdirs))
427 print NEW_CONFIG
"dlls/$dir/Makefile\n";
433 $skip = 0 unless /^dlls\//;
434 print NEW_CONFIG
$_ unless $skip;
439 update_file
("configure.ac");