Remove unused character width array.
[wine] / dlls / make_dlls
1 #!/usr/bin/perl
2 #
3 # Update the dll dependencies in the dlls main Makefile.in.
4 # Must be run in the dlls/ directory of the Wine tree.
5 #
6 # Copyright 2001 Alexandre Julliard
7 #
8
9 $makefiles = `find . -name Makefile.in -print`;
10
11 %imports = ();
12 %directories = ();
13 %altnames = ();
14
15 foreach $i (split(/\s/,$makefiles))
16 {
17     open MAKE,$i;
18     while (<MAKE>)
19     {
20         chop;
21         if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
22         {
23             $module = $1;
24             ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
25             next;
26         }
27         if (/^ALTNAMES\s*=\s*(.*)/)
28         {
29             my @list = split(/\s/,$1);
30             $altnames{$module} = \@list;
31             next;
32         }
33     }
34 }
35
36 foreach $mod (sort keys %directories)
37 {
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>)
42     {
43         if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_]+)\.dll/)
44         {
45             my $imp = $2;
46             push @{$imports{$mod}}, $imp;
47             next;
48         }
49         if (/^\#?import\s+(-delay\s+)?([a-zA-Z0-9_.]+)/)
50         {
51             my $imp = $2;
52             push @{$imports{$mod}}, $imp;
53             next;
54         }
55     }
56 }
57
58 open OLDMAKE,"Makefile.in" or die "cannot open Makefile.in";
59 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
60
61 while (<OLDMAKE>)
62 {
63     last if (/^EXTRADLLNAMES/);
64     print NEWMAKE $_;
65 }
66 close OLDMAKE;
67
68 printf NEWMAKE "EXTRADLLNAMES =";
69 foreach $extra (values %altnames) { push @extra, @$extra; }
70 foreach $extra (sort @extra)
71 {
72     printf NEWMAKE " \\\n\t%s", $extra;
73 }
74
75 printf NEWMAKE "\n\nSUBDIRS =";
76 foreach $dir (sort values %directories)
77 {
78     printf NEWMAKE " \\\n\t%s", $dir;
79 }
80 printf NEWMAKE "\n";
81
82 print NEWMAKE <<EOF;
83
84 \@MAKE_RULES\@
85
86 all: \$(DLLS:%=lib%.\@LIBEXT\@) \$(EXTRADLLNAMES:%=lib%.\@LIBEXT\@)
87
88 # Map library name to directory
89
90 EOF
91
92 foreach $mod (sort keys %directories)
93 {
94     my $count = 0;
95     printf NEWMAKE "lib%s.\@LIBEXT\@", $mod;
96     foreach $i (sort @{$altnames{$mod}})
97     {
98         if ($count++ >= 3)
99         {
100             $count = 0;
101             printf NEWMAKE " \\\n ";
102         }
103         printf NEWMAKE " lib%s.\@LIBEXT\@", $i;
104     }
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;
107 }
108
109 print NEWMAKE "# Inter-dll dependencies (only necessary for dynamic libs)\n\n";
110
111 my @depends = ();
112 foreach $mod (sort keys %imports)
113 {
114     next unless $#{$imports{$mod}} >= 0;
115     my $dep = sprintf("%s/lib%s.\@LIBEXT\@:", $directories{$mod}, $mod);
116     foreach $i (@{$imports{$mod}})
117     {
118         $dep .= sprintf(" lib%s.\@LIBEXT\@", $i);
119     }
120     push @depends, $dep . "\n";
121 }
122 print NEWMAKE sort @depends;
123
124 print NEWMAKE <<EOF;
125
126 \$(DLLFILES): dummy
127         \@cd `dirname \$\@` && \$(MAKE)
128
129 \$(DLLFILES:%=%_install_): dummy
130         \@cd `dirname \$\@` && \$(MAKE) install
131
132 \$(DLLFILES:%=%_uninstall_): dummy
133         \@cd `dirname \$\@` && \$(MAKE) uninstall
134
135 \$(DLLFILES:%=%_checklink_): dummy
136         \@cd `dirname \$\@` && \$(MAKE) checklink
137
138 install:: \$(DLLFILES:%=%_install_)
139
140 uninstall:: \$(DLLFILES:%=%_uninstall_)
141
142 checklink:: \$(DLLFILES:%=%_checklink_)
143 EOF
144
145 close NEWMAKE;
146 rename "Makefile.in.new", "Makefile.in";
147 printf "Successfully updated Makefile.in\n";