blob: 05dd5a25e63bfec745a0e646b0ad7c7c477f92d4 [file] [log] [blame]
Alexandre Julliard7c3dec92001-06-08 19:09:44 +00001#!/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
15foreach $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
36foreach $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
58open OLDMAKE,"Makefile.in" or die "cannot open Makefile.in";
59open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
60
61while (<OLDMAKE>)
62{
63 last if (/^EXTRADLLNAMES/);
64 print NEWMAKE $_;
65}
66close OLDMAKE;
67
68printf NEWMAKE "EXTRADLLNAMES =";
69foreach $extra (values %altnames) { push @extra, @$extra; }
70foreach $extra (sort @extra)
71{
72 printf NEWMAKE " \\\n\t%s", $extra;
73}
74
75printf NEWMAKE "\n\nSUBDIRS =";
76foreach $dir (sort values %directories)
77{
78 printf NEWMAKE " \\\n\t%s", $dir;
79}
80printf NEWMAKE "\n";
81
82print NEWMAKE <<EOF;
83
84\@MAKE_RULES\@
85
86all: \$(DLLS:%=lib%.\@LIBEXT\@) \$(EXTRADLLNAMES:%=lib%.\@LIBEXT\@)
87
88# Map library name to directory
89
90EOF
91
92foreach $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
109print NEWMAKE "# Inter-dll dependencies (only necessary for dynamic libs)\n\n";
110
111my @depends = ();
112foreach $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}
122print NEWMAKE sort @depends;
123
124print 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
138install:: \$(DLLFILES:%=%_install_)
139
140uninstall:: \$(DLLFILES:%=%_uninstall_)
141
142checklink:: \$(DLLFILES:%=%_checklink_)
143EOF
144
145close NEWMAKE;
146rename "Makefile.in.new", "Makefile.in";
147printf "Successfully updated Makefile.in\n";