my $makefiles = `find . -name Makefile.in -print`;
-my %imports = ();
my %directories = ();
+my %importlibs = ();
+my %static_implibs = ();
+my %staticlib_dirs = ();
my %altnames = ();
-my %linked_dlls = ();
# list of special dlls that can be switched on or off by configure
my %special_dlls =
(
"ddraw" => "XFILES",
"glu32" => "GLU32FILES",
+ "glut32" => "GLUT32FILES",
"opengl32" => "OPENGLFILES",
"d3d8" => "OPENGLFILES",
+ "d3d9" => "OPENGLFILES",
+ "d3dx8" => "OPENGLFILES",
+ "wined3d" => "OPENGLFILES",
"x11drv" => "XFILES"
);
if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
{
$module = $1;
- $imports{$module} = [ ];
- ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
+ if ($module =~ /^lib.*\.a$/)
+ {
+ ($staticlib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
+ }
+ else
+ {
+ ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
+ }
next;
}
- if (/^ALTNAMES\s*=\s*(.*)/)
+ if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
{
- my @list = split(/\s/,$1);
- $altnames{$module} = \@list;
+ $importlibs{$module} = $1;
next;
}
- if (/^(DELAYIMPORTS|IMPORTS)\s*=\s*(.*)/)
+ if (/^IMPLIB_SRCS\s*=/)
{
- my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$2);
- push @{$imports{$module}}, @list;
+ $static_implibs{$module} = 1;
next;
}
- if (/^LDIMPORTS\s*=\s*(.*)/)
+ if (/^SPEC_SRCS16\s*=\s*(.*)/)
{
- my @list = map { /\./ ? $_ : $_ . ".dll"; } split(/\s/,$1);
- $linked_dlls{$module} = \@list;
+ my $specs = $1;
+ while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; }
+ my @list = split(/\s+/,$specs);
+ @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
+ $altnames{$module} = \@list;
next;
}
}
close MAKE;
- push @{$imports{$module}}, "kernel32.dll" unless !defined($module) || @{$imports{$module}} || $module eq "ntdll.dll";
}
open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
}
printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
-foreach my $dir (sort keys %special_dlls)
+foreach my $dir (sort (keys %special_dlls, values %staticlib_dirs))
{
printf NEWMAKE " \\\n\t%s", $dir;
}
foreach my $mod (sort keys %directories)
{
next if defined($special_dlls{$directories{$mod}}); # skip special dlls
- $targets{sprintf("%s\$(DLLEXT)",$mod)} = 1;
+ $targets{$mod . ".so"} = 1;
next unless defined $altnames{$mod};
foreach my $i (sort @{$altnames{$mod}})
{
- $targets16{sprintf("%s\$(DLLEXT)",$i)} = 1;
+ $targets16{sprintf("%s.so",$i)} = 1;
}
}
-print NEWMAKE <<EOF;
+foreach my $mod (sort keys %staticlib_dirs) { $targets{$mod} = 1; }
-# Main target
+print NEWMAKE <<EOF;
\@MAKE_RULES\@
+# Symbolic links
+
WIN16_FILES = \\
EOF
printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
print NEWMAKE <<EOF;
-all: \\
- \$(EXTRADIRS:%=%.dll\$(DLLEXT)) \\
+SYMLINKS_SO = \\
+ \$(EXTRADIRS:%=%.dll.so) \\
\@WIN16_FILES\@ \\
EOF
printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
+print NEWMAKE <<EOF;
+
+# Main target
+
+all: symlinks\$(DLLEXT)
+
+.PHONY: symlinks symlinks.so implib
+
+symlinks.so: \$(SYMLINKS_SO)
+
+symlinks: \$(BUILDSUBDIRS)
+
+x11drv.dll.so: winex11.drv.so
+ \$(RM) \$@ && \$(LN_S) winex11.drv.so \$@
+
+EOF
################################################################
# output the lib name -> directory rules
foreach my $mod (sort keys %directories)
{
- printf NEWMAKE "%s\$(DLLEXT)", $mod;
+ printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
+ printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
+
if (defined $altnames{$mod})
{
- my $count = 1;
+ my $count = 0;
foreach my $i (sort @{$altnames{$mod}})
{
- if (!($count++ % 3)) { printf NEWMAKE " \\\n "; }
- printf NEWMAKE " %s\$(DLLEXT)", $i;
+ if ($count++ == 3) { printf NEWMAKE "\\\n "; $count = 1; }
+ printf NEWMAKE "%s.so ", $i;
}
+ printf NEWMAKE ": %s.so\n", $mod;
+ printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s.so \$@\n\n", $mod;
}
- printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
- printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
}
-
+foreach my $mod (sort keys %staticlib_dirs)
+{
+ printf NEWMAKE "%s: %s/%s\n", $mod, $staticlib_dirs{$mod}, $mod;
+ printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $staticlib_dirs{$mod}, $mod;
+}
################################################################
-# output the inter-dll dependencies and rules
+# output the import libraries rules
-print NEWMAKE "# Map library name to the corresponding directory\n\n";
+print NEWMAKE "\n# Import libraries\n\n";
+print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
-foreach my $mod (sort keys %directories)
+my @lib_symlinks = ("ntdll.dll");
+foreach my $mod (sort keys %importlibs)
{
- printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
+ my $dir = $directories{$mod};
+ my $lib = $importlibs{$mod};
+ if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
}
-
-print NEWMAKE "\n# Install dependencies\n\n";
-
-foreach my $mod (sort keys %directories)
+print NEWMAKE "IMPORT_SYMLINKS =";
+foreach my $mod (sort @lib_symlinks)
{
- printf NEWMAKE "%s/__install__: %s\$(DLLEXT)\n", $directories{$mod}, $mod;
+ printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
}
-
-print NEWMAKE "\n# Inter-dll dependencies\n\n";
-
-my @depends = ();
-foreach my $mod (sort keys %imports)
+foreach my $mod (sort keys %staticlib_dirs)
{
- next unless @{$imports{$mod}};
- my $count = 0;
- my $dep = sprintf("%s:", $directories{$mod});
- $dep .= " " x (8-length($directories{$mod}));
- foreach my $i (@{$imports{$mod}})
- {
- if ($count++ >= 4)
- {
- $count = 1;
- $dep .= " \\\n" . " " x 9;
- }
- $dep .= sprintf(" %s\$(DLLEXT)", $i);
- }
- foreach my $i (@{$linked_dlls{$mod}})
- {
- if ($count++ >= 4)
- {
- $count = 1;
- $dep .= " \\\n" . " " x 9;
- }
- $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
- }
- push @depends, $dep . "\n";
+ printf NEWMAKE " \\\n\t%s", $mod;
}
-print NEWMAKE sort @depends;
-
-
-################################################################
-# output the linkable dlls special links
-my %linkable_dlls = ();
-foreach my $mod (keys %imports)
+print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
+foreach my $mod (sort keys %importlibs)
{
- foreach my $i (@{$linked_dlls{$mod}}) { $linkable_dlls{$i} = 1; }
+ my $dir = $directories{$mod};
+ my $def = $mod;
+ $def =~ s/\.(dll|drv)$//;
+ printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
+ printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
}
+print NEWMAKE "\n\n";
+print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n";
-print NEWMAKE "\n# Special targets for dlls that we need to link to\n\n";
-printf NEWMAKE "LINKABLE_DLLS = %s\n\n", join( " ", keys %linkable_dlls );
-
-foreach my $mod (keys %linkable_dlls)
+foreach my $mod (sort keys %importlibs)
+{
+ my $dir = $directories{$mod};
+ my $lib = $importlibs{$mod};
+ my $spec = $mod;
+ $spec =~ s/\.dll$//;
+ printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
+ printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
+ next unless $static_implibs{$mod};
+ printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
+ printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
+}
+foreach my $mod (sort @lib_symlinks)
{
- 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;
+ my $dir = $directories{$mod};
+ my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
+ printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib;
+ printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
}
print NEWMAKE <<EOF;
-uninstall::
- \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
+\$(BUILDSUBDIRS): \$(IMPORT_LIBS)
+\$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
-install::
- \$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
- cd \$(libdir) && if [ "\$(dlldir)" = "\$(libdir)/wine" ]; \\
- then \\
EOF
-foreach my $mod (keys %linkable_dlls)
+
+################################################################
+# output the inter-dll dependencies and rules
+
+print NEWMAKE "# Map library name to the corresponding directory\n\n";
+
+foreach my $mod (sort keys %directories)
{
- printf NEWMAKE "\t \$(LN_S) wine/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod;
+ printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
}
-print NEWMAKE "\telse \\\n";
-foreach my $mod (keys %linkable_dlls)
+foreach my $mod (sort keys %staticlib_dirs)
{
- printf NEWMAKE "\t \$(LN_S) \$(dlldir)/%s\$(DLLEXT) lib%s.\$(LIBEXT); \\\n", $mod, $mod;
+ printf NEWMAKE "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod};
}
-print NEWMAKE "\tfi\n\n";
################################################################
# makefile trailer
print NEWMAKE <<EOF;
+
+# Rules for auto documentation
+
+\$(SUBDIRS:%=%/__man__): dummy
+ cd `dirname \$@` && \$(MAKE) man
+
+man: \$(SUBDIRS:%=%/__man__)
+
+\$(SUBDIRS:%=%/__doc_html__): dummy
+ cd `dirname \$@` && \$(MAKE) doc-html
+
+doc-html: \$(SUBDIRS:%=%/__doc_html__)
+
+\$(SUBDIRS:%=%/__doc_sgml__): dummy
+ cd `dirname \$@` && \$(MAKE) doc-sgml
+
+doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
+
+.PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
+
# Misc rules
+install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
+
+install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
+
uninstall::
-rmdir \$(dlldir)
+clean::
+ \$(RM) \$(IMPORT_SYMLINKS)
+
check test:: \$(BUILDSUBDIRS:%=%/__test__)
crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)