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
|
|
|
|
#
|
|
|
|
|
|
|
|
$makefiles = `find . -name Makefile.in -print`;
|
|
|
|
|
|
|
|
%imports = ();
|
|
|
|
%directories = ();
|
|
|
|
%altnames = ();
|
|
|
|
|
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;
|
|
|
|
($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^ALTNAMES\s*=\s*(.*)/)
|
|
|
|
{
|
|
|
|
my @list = split(/\s/,$1);
|
|
|
|
$altnames{$module} = \@list;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach $mod (sort keys %directories)
|
|
|
|
{
|
|
|
|
my $spec = sprintf("%s/%s.spec", $directories{$mod}, $mod);
|
|
|
|
open SPEC,$spec or die "cannot open $spec";
|
|
|
|
$imports{$mod} = [ ];
|
|
|
|
while (<SPEC>)
|
|
|
|
{
|
|
|
|
if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_]+)\.dll/)
|
|
|
|
{
|
|
|
|
my $imp = $2;
|
|
|
|
push @{$imports{$mod}}, $imp;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_.]+)/)
|
|
|
|
{
|
|
|
|
my $imp = $2;
|
|
|
|
push @{$imports{$mod}}, $imp;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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\@
|
|
|
|
LIBEXT = \@LIBEXT\@
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
next if defined($special_dlls{$mod}); # skip special dlls
|
|
|
|
$targets{sprintf("lib%s.\$(LIBEXT)",$mod)} = 1;
|
|
|
|
next unless defined $altnames{$mod};
|
|
|
|
foreach $i (sort @{$altnames{$mod}})
|
|
|
|
{
|
|
|
|
$targets{sprintf("lib%s.\$(LIBEXT)",$i)} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print NEWMAKE <<EOF;
|
|
|
|
|
|
|
|
# Main target
|
|
|
|
|
|
|
|
all: \\
|
|
|
|
\$(EXTRADIRS:%=lib%.\$(LIBEXT)) \\
|
|
|
|
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;
|
|
|
|
|
|
|
|
\@MAKE_RULES\@
|
|
|
|
|
|
|
|
# Map library name to directory
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
foreach $mod (sort keys %directories)
|
|
|
|
{
|
2001-09-17 22:09:08 +02:00
|
|
|
printf NEWMAKE "lib%s.\$(LIBEXT)", $mod;
|
|
|
|
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 "; }
|
|
|
|
printf NEWMAKE " lib%s.\$(LIBEXT)", $i;
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
|
|
|
}
|
2001-09-17 22:09:08 +02:00
|
|
|
printf NEWMAKE ": %s/lib%s.\$(LIBEXT)\n", $directories{$mod}, $mod;
|
|
|
|
printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/lib%s.\$(LIBEXT) \$@\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;
|
|
|
|
my $dep = sprintf("%s/lib%s.\$(LIBEXT): dummy", $directories{$mod}, $mod);
|
2001-06-08 21:09:44 +02:00
|
|
|
foreach $i (@{$imports{$mod}})
|
|
|
|
{
|
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
|
|
|
}
|
2001-09-17 22:09:08 +02:00
|
|
|
$dep .= sprintf("\n\t\@cd %s && \$(MAKE) lib%s.\$(LIBEXT)\n\n",$directories{$mod}, $mod);
|
|
|
|
push @depends, $dep;
|
2001-06-08 21:09:44 +02:00
|
|
|
}
|
|
|
|
print NEWMAKE sort @depends;
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2002-01-14 20:56:46 +01:00
|
|
|
\$(SUBDIRS:%=%/__test__): dummy
|
|
|
|
\@cd `dirname \$\@` && \$(MAKE) test
|
|
|
|
|
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
|
|
|
\$(SUBDIRS:%=%/__debug_channels__): dummy
|
|
|
|
\@cd `dirname \$\@` && \$(MAKE) debug_channels
|
|
|
|
|
|
|
|
install:: \$(SUBDIRS:%=%/__install__)
|
|
|
|
|
|
|
|
uninstall:: \$(SUBDIRS:%=%/__uninstall__)
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2002-01-14 20:56:46 +01:00
|
|
|
test:: \$(SUBDIRS:%=%/__test__)
|
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
checklink:: \$(SUBDIRS:%=%/__checklink__)
|
2001-06-08 21:09:44 +02:00
|
|
|
|
2001-09-17 22:09:08 +02:00
|
|
|
debug_channels:: \$(SUBDIRS:%=%/__debug_channels__)
|
2001-06-08 21:09:44 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
close NEWMAKE;
|
|
|
|
rename "Makefile.in.new", "Makefile.in";
|
|
|
|
printf "Successfully updated Makefile.in\n";
|