2001-09-17 22:09:08 +02:00
|
|
|
#!/usr/bin/perl -w
|
2001-06-08 21:09:44 +02:00
|
|
|
#
|
|
|
|
# Update the dll dependencies in the dlls main Makefile.in.
|
|
|
|
# Must be run in the dlls/ directory of the Wine tree.
|
|
|
|
#
|
|
|
|
# Copyright 2001 Alexandre Julliard
|
|
|
|
#
|
2002-03-10 00:29:33 +01:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
2001-06-08 21:09:44 +02:00
|
|
|
|
|
|
|
$makefiles = `find . -name Makefile.in -print`;
|
|
|
|
|
|
|
|
%imports = ();
|
|
|
|
%directories = ();
|
|
|
|
%altnames = ();
|
2002-03-20 23:19:06 +01:00
|
|
|
%linked_dlls = ();
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
# list of special dlls that can be switched on or off by configure
|
|
|
|
%special_dlls =
|
|
|
|
(
|
|
|
|
"ddraw" => "XFILES",
|
|
|
|
"glu32" => "GLU32FILES",
|
|
|
|
"opengl32" => "OPENGLFILES",
|
|
|
|
"x11drv" => "XFILES"
|
|
|
|
);
|
|
|
|
|
2001-06-08 21:09:44 +02:00
|
|
|
foreach $i (split(/\s/,$makefiles))
|
|
|
|
{
|
|
|
|
open MAKE,$i;
|
|
|
|
while (<MAKE>)
|
|
|
|
{
|
|
|
|
chop;
|
|
|
|
if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
|
|
|
|
{
|
|
|
|
$module = $1;
|
2002-05-14 22:42:52 +02:00
|
|
|
$imports{$module} = [ ];
|
2001-06-08 21:09:44 +02:00
|
|
|
($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^ALTNAMES\s*=\s*(.*)/)
|
|
|
|
{
|
|
|
|
my @list = split(/\s/,$1);
|
|
|
|
$altnames{$module} = \@list;
|
|
|
|
next;
|
|
|
|
}
|
2002-05-14 22:42:52 +02:00
|
|
|
if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
|
2002-03-20 23:19:06 +01:00
|
|
|
{
|
2002-05-14 22:42:52 +02:00
|
|
|
my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
|
|
|
|
push @{$imports{$module}}, @list;
|
2001-06-08 21:09:44 +02:00
|
|
|
next;
|
|
|
|
}
|
2002-05-14 22:42:52 +02:00
|
|
|
if (/^LDIMPORTS\s*=\s*(.*)/)
|
2001-06-08 21:09:44 +02:00
|
|
|
{
|
2002-05-14 22:42:52 +02:00
|
|
|
my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1);
|
|
|
|
$linked_dlls{$module} = \@list;
|
2001-06-08 21:09:44 +02:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
2002-05-17 06:32:20 +02:00
|
|
|
push @{$imports{$module}}, "kernel32.dll" unless @{$imports{$module}} || $module eq "ntdll.dll";
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
################################################################
|
|
|
|
# makefile header
|
|
|
|
|
|
|
|
print NEWMAKE <<EOF;
|
|
|
|
# Automatically generated by make_dlls; DO NOT EDIT!!
|
|
|
|
|
|
|
|
TOPSRCDIR = \@top_srcdir\@
|
|
|
|
TOPOBJDIR = ..
|
|
|
|
SRCDIR = \@srcdir\@
|
|
|
|
VPATH = \@srcdir\@
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# output special dlls configure definitions
|
|
|
|
|
|
|
|
printf NEWMAKE "# special configure-dependent targets\n\n";
|
|
|
|
my %specials = ();
|
|
|
|
foreach $mod (sort keys %special_dlls)
|
2001-06-08 21:09:44 +02:00
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
$specials{$special_dlls{$mod}} .= " " . $mod;
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
2001-09-17 22:09:08 +02:00
|
|
|
foreach $i (sort keys %specials)
|
2001-06-08 21:09:44 +02:00
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
printf NEWMAKE "%s =%s\n", $i, $specials{$i};
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
2001-09-17 22:09:08 +02:00
|
|
|
printf NEWMAKE "EXTRADIRS =";
|
|
|
|
foreach $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
|
|
|
|
printf NEWMAKE "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# output the subdirs list
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
print NEWMAKE <<EOF;
|
|
|
|
# Subdir list
|
|
|
|
|
|
|
|
SUBDIRS = \\
|
|
|
|
EOF
|
|
|
|
printf NEWMAKE "\t\$(EXTRADIRS)";
|
2001-06-08 21:09:44 +02:00
|
|
|
foreach $dir (sort values %directories)
|
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
next if defined($special_dlls{$dir}); # skip special dlls
|
2001-06-08 21:09:44 +02:00
|
|
|
printf NEWMAKE " \\\n\t%s", $dir;
|
|
|
|
}
|
|
|
|
printf NEWMAKE "\n";
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
# output the all: target
|
|
|
|
|
|
|
|
my %targets = (); # use a hash to get rid of duplicate target names
|
|
|
|
foreach $mod (sort keys %directories)
|
|
|
|
{
|
2002-03-20 23:19:06 +01:00
|
|
|
next if defined($special_dlls{$directories{$mod}}); # skip special dlls
|
|
|
|
$targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
|
2001-09-17 22:09:08 +02:00
|
|
|
next unless defined $altnames{$mod};
|
|
|
|
foreach $i (sort @{$altnames{$mod}})
|
|
|
|
{
|
2002-03-20 23:19:06 +01:00
|
|
|
$targets{sprintf("%s\$(DLLEXT)",$i)} = 1;
|
2001-09-17 22:09:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print NEWMAKE <<EOF;
|
|
|
|
|
|
|
|
# Main target
|
|
|
|
|
2002-03-20 23:19:06 +01:00
|
|
|
\@MAKE_RULES\@
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
all: \\
|
2002-03-20 23:19:06 +01:00
|
|
|
\$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
|
2001-09-17 22:09:08 +02:00
|
|
|
EOF
|
|
|
|
printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# output the lib name -> directory rules
|
|
|
|
|
2001-06-08 21:09:44 +02:00
|
|
|
print NEWMAKE <<EOF;
|
|
|
|
|
|
|
|
# Map library name to directory
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
foreach $mod (sort keys %directories)
|
|
|
|
{
|
2002-03-20 23:19:06 +01:00
|
|
|
printf NEWMAKE "%s\$(DLLEXT)", $mod;
|
2001-09-17 22:09:08 +02:00
|
|
|
if (defined $altnames{$mod})
|
2001-06-08 21:09:44 +02:00
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
my $count = 1;
|
|
|
|
foreach $i (sort @{$altnames{$mod}})
|
2001-06-08 21:09:44 +02:00
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
|
2002-03-20 23:19:06 +01:00
|
|
|
printf NEWMAKE " %s\$(DLLEXT)", $i;
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
|
|
|
}
|
2002-03-20 23:19:06 +01:00
|
|
|
printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
|
|
|
|
printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
# output the inter-dll dependencies and rules
|
|
|
|
|
|
|
|
print NEWMAKE "# Inter-dll dependencies\n\n";
|
2001-06-08 21:09:44 +02:00
|
|
|
|
|
|
|
my @depends = ();
|
|
|
|
foreach $mod (sort keys %imports)
|
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
my $count = 1;
|
2002-03-20 23:19:06 +01:00
|
|
|
my $dep = sprintf("%s/%s\$(DLLEXT): dummy", $directories{$mod}, $mod);
|
2001-06-08 21:09:44 +02:00
|
|
|
foreach $i (@{$imports{$mod}})
|
2002-03-20 23:19:06 +01:00
|
|
|
{
|
|
|
|
if ($count++ >= 3)
|
|
|
|
{
|
|
|
|
$count = 0;
|
|
|
|
$dep .= " \\\n ";
|
|
|
|
}
|
|
|
|
$dep .= sprintf(" %s\$(DLLEXT)", $i);
|
|
|
|
}
|
|
|
|
foreach $i (@{$linked_dlls{$mod}})
|
2001-06-08 21:09:44 +02:00
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
if ($count++ >= 3)
|
|
|
|
{
|
|
|
|
$count = 0;
|
|
|
|
$dep .= " \\\n ";
|
|
|
|
}
|
|
|
|
$dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
2002-03-20 23:19:06 +01:00
|
|
|
$dep .= sprintf("\n\t\@cd %s && \$(MAKE) %s\$(DLLEXT)\n\n",$directories{$mod}, $mod);
|
2001-09-17 22:09:08 +02:00
|
|
|
push @depends, $dep;
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
|
|
|
print NEWMAKE sort @depends;
|
|
|
|
|
|
|
|
|
2002-03-20 23:19:06 +01:00
|
|
|
################################################################
|
|
|
|
# output the linkable dlls special links
|
|
|
|
|
|
|
|
%linkable_dlls = ();
|
|
|
|
foreach $mod (keys %imports)
|
|
|
|
{
|
|
|
|
foreach $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
print NEWMAKE "# Special targets for dlls that we need to link to\n\n";
|
|
|
|
foreach $mod (keys %linkable_dlls)
|
|
|
|
{
|
|
|
|
printf NEWMAKE "lib%s.\$(LIBEXT): %s/%s\$(DLLEXT)\n", $mod, $directories{$mod}, $mod;
|
|
|
|
printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
|
|
|
|
}
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
################################################################
|
|
|
|
# makefile trailer
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
print NEWMAKE <<EOF;
|
|
|
|
# Misc rules
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
\$(SUBDIRS:%=%/__checklink__): dummy
|
2001-06-08 21:09:44 +02:00
|
|
|
\@cd `dirname \$\@` && \$(MAKE) checklink
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
install:: \$(SUBDIRS:%=%/__install__)
|
|
|
|
|
|
|
|
uninstall:: \$(SUBDIRS:%=%/__uninstall__)
|
2002-03-20 23:19:06 +01:00
|
|
|
-rmdir \$(dlldir)
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2002-02-28 22:43:46 +01:00
|
|
|
check test:: \$(SUBDIRS:%=%/__test__)
|
2002-01-14 20:56:46 +01:00
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
checklink:: \$(SUBDIRS:%=%/__checklink__)
|
2001-06-08 21:09:44 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
close NEWMAKE;
|
|
|
|
rename "Makefile.in.new", "Makefile.in";
|
|
|
|
printf "Successfully updated Makefile.in\n";
|