Rewrite EscapeCommFunction16 to use EscapeCommFunction.
[wine/wine-kai.git] / dlls / make_dlls
blob05dd5a25e63bfec745a0e646b0ad7c7c477f92d4
1 #!/usr/bin/perl
3 # Update the dll dependencies in the dlls main Makefile.in.
4 # Must be run in the dlls/ directory of the Wine tree.
6 # Copyright 2001 Alexandre Julliard
9 $makefiles = `find . -name Makefile.in -print`;
11 %imports = ();
12 %directories = ();
13 %altnames = ();
15 foreach $i (split(/\s/,$makefiles))
17 open MAKE,$i;
18 while (<MAKE>)
20 chop;
21 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
23 $module = $1;
24 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
25 next;
27 if (/^ALTNAMES\s*=\s*(.*)/)
29 my @list = split(/\s/,$1);
30 $altnames{$module} = \@list;
31 next;
36 foreach $mod (sort keys %directories)
38 my $spec = sprintf("%s/%s.spec", $directories{$mod}, $mod);
39 open SPEC,$spec or die "cannot open $spec";
40 $imports{$mod} = [ ];
41 while (<SPEC>)
43 if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_]+)\.dll/)
45 my $imp = $2;
46 push @{$imports{$mod}}, $imp;
47 next;
49 if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_.]+)/)
51 my $imp = $2;
52 push @{$imports{$mod}}, $imp;
53 next;
58 open OLDMAKE,"Makefile.in" or die "cannot open Makefile.in";
59 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
61 while (<OLDMAKE>)
63 last if (/^EXTRADLLNAMES/);
64 print NEWMAKE $_;
66 close OLDMAKE;
68 printf NEWMAKE "EXTRADLLNAMES =";
69 foreach $extra (values %altnames) { push @extra, @$extra; }
70 foreach $extra (sort @extra)
72 printf NEWMAKE " \\\n\t%s", $extra;
75 printf NEWMAKE "\n\nSUBDIRS =";
76 foreach $dir (sort values %directories)
78 printf NEWMAKE " \\\n\t%s", $dir;
80 printf NEWMAKE "\n";
82 print NEWMAKE <<EOF;
84 \@MAKE_RULES\@
86 all: \$(DLLS:%=lib%.\@LIBEXT\@) \$(EXTRADLLNAMES:%=lib%.\@LIBEXT\@)
88 # Map library name to directory
90 EOF
92 foreach $mod (sort keys %directories)
94 my $count = 0;
95 printf NEWMAKE "lib%s.\@LIBEXT\@", $mod;
96 foreach $i (sort @{$altnames{$mod}})
98 if ($count++ >= 3)
100 $count = 0;
101 printf NEWMAKE " \\\n ";
103 printf NEWMAKE " lib%s.\@LIBEXT\@", $i;
105 printf NEWMAKE ": %s/lib%s.\@LIBEXT\@\n", $directories{$mod}, $mod;
106 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/lib%s.\@LIBEXT\@ \$@\n\n", $directories{$mod}, $mod;
109 print NEWMAKE "# Inter-dll dependencies (only necessary for dynamic libs)\n\n";
111 my @depends = ();
112 foreach $mod (sort keys %imports)
114 next unless $#{$imports{$mod}} >= 0;
115 my $dep = sprintf("%s/lib%s.\@LIBEXT\@:", $directories{$mod}, $mod);
116 foreach $i (@{$imports{$mod}})
118 $dep .= sprintf(" lib%s.\@LIBEXT\@", $i);
120 push @depends, $dep . "\n";
122 print NEWMAKE sort @depends;
124 print NEWMAKE <<EOF;
126 \$(DLLFILES): dummy
127 \@cd `dirname \$\@` && \$(MAKE)
129 \$(DLLFILES:%=%_install_): dummy
130 \@cd `dirname \$\@` && \$(MAKE) install
132 \$(DLLFILES:%=%_uninstall_): dummy
133 \@cd `dirname \$\@` && \$(MAKE) uninstall
135 \$(DLLFILES:%=%_checklink_): dummy
136 \@cd `dirname \$\@` && \$(MAKE) checklink
138 install:: \$(DLLFILES:%=%_install_)
140 uninstall:: \$(DLLFILES:%=%_uninstall_)
142 checklink:: \$(DLLFILES:%=%_checklink_)
145 close NEWMAKE;
146 rename "Makefile.in.new", "Makefile.in";
147 printf "Successfully updated Makefile.in\n";