Release 20040408.
[wine.git] / dlls / make_dlls
blob72769b2f8038bb08885c4092977eef07225d148c
1 #!/usr/bin/perl -w
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
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 use strict;
25 my $makefiles = `find . -name Makefile.in -print`;
27 my %directories = ();
28 my %implib_dirs = ();
29 my %altnames = ();
31 # list of special dlls that can be switched on or off by configure
32 my %special_dlls =
34 "ddraw" => "XFILES",
35 "glu32" => "GLU32FILES",
36 "glut32" => "GLUT32FILES",
37 "opengl32" => "OPENGLFILES",
38 "d3d8" => "OPENGLFILES",
39 "d3d9" => "OPENGLFILES",
40 "d3dx8" => "OPENGLFILES",
41 "wined3d" => "OPENGLFILES",
42 "x11drv" => "XFILES"
45 foreach my $i (split(/\s/,$makefiles))
47 my $module;
49 next if $i =~ /\/tests\/Makefile.in/;
51 open MAKE,$i;
53 $module = undef;
54 while (<MAKE>)
56 chop;
57 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
58 # at the very top of the Makefile.in
59 last if (/^\#\s*MKDLL_SKIP/);
61 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
63 $module = $1;
64 if ($module =~ /^lib.*\.a$/)
66 ($implib_dirs{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
68 else
70 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
72 next;
74 if (/^ALTNAMES\s*=\s*(.*)/)
76 my @list = split(/\s/,$1);
77 $altnames{$module} = \@list;
78 next;
81 close MAKE;
84 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
86 ################################################################
87 # makefile header
89 print NEWMAKE <<EOF;
90 # Automatically generated by make_dlls; DO NOT EDIT!!
92 TOPSRCDIR = \@top_srcdir\@
93 TOPOBJDIR = ..
94 SRCDIR = \@srcdir\@
95 VPATH = \@srcdir\@
97 EOF
99 ################################################################
100 # output special dlls configure definitions
102 printf NEWMAKE "# special configure-dependent targets\n\n";
103 my %specials = ();
104 foreach my $mod (sort keys %special_dlls)
106 $specials{$special_dlls{$mod}} .= " " . $mod;
108 foreach my $i (sort keys %specials)
110 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
112 printf NEWMAKE "EXTRADIRS =";
113 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
114 printf NEWMAKE "\n\n";
117 ################################################################
118 # output the subdirs list
120 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
121 foreach my $dir (sort values %directories)
123 next if defined($special_dlls{$dir}); # skip special dlls
124 printf NEWMAKE " \\\n\t%s", $dir;
127 printf NEWMAKE "\n\nSUBDIRS = \\\n\t\$(BASEDIRS)";
128 foreach my $dir (sort (keys %special_dlls, values %implib_dirs))
130 printf NEWMAKE " \\\n\t%s", $dir;
132 printf NEWMAKE <<EOF;
135 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
137 INSTALLSUBDIRS = \$(BUILDSUBDIRS)
140 ################################################################
141 # output the all: target
143 my %targets = (); # use a hash to get rid of duplicate target names
144 my %targets16 = ();
145 foreach my $mod (sort keys %directories)
147 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
148 $targets{$mod . ".so"} = 1;
149 next unless defined $altnames{$mod};
150 foreach my $i (sort @{$altnames{$mod}})
152 $targets16{sprintf("%s.so",$i)} = 1;
155 foreach my $mod (sort keys %implib_dirs) { $targets{$mod} = 1; }
157 print NEWMAKE <<EOF;
159 \@MAKE_RULES\@
161 # Symbolic links
163 WIN16_FILES = \\
165 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
167 print NEWMAKE <<EOF;
169 SYMLINKS_SO = \\
170 \$(EXTRADIRS:%=%.dll.so) \\
171 \@WIN16_FILES\@ \\
173 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
175 print NEWMAKE <<EOF;
177 # Main target
179 all: symlinks\$(DLLEXT)
181 .PHONY: symlinks symlinks.so implib
183 symlinks.so: \$(SYMLINKS_SO)
185 symlinks: \$(BUILDSUBDIRS)
189 ################################################################
190 # output the lib name -> directory rules
192 print NEWMAKE <<EOF;
194 # Map symlink name to the corresponding library
198 foreach my $mod (sort keys %directories)
200 printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
201 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
203 if (defined $altnames{$mod})
205 my $count = 0;
206 foreach my $i (sort @{$altnames{$mod}})
208 if ($count++ == 3) { printf NEWMAKE "\\\n "; $count = 1; }
209 printf NEWMAKE "%s.so ", $i;
211 printf NEWMAKE ": %s.so\n", $mod;
212 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s.so \$@\n\n", $mod;
215 foreach my $mod (sort keys %implib_dirs)
217 printf NEWMAKE "%s: %s/%s\n", $mod, $implib_dirs{$mod}, $mod;
218 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $implib_dirs{$mod}, $mod;
221 ################################################################
222 # output the import libraries rules
224 my @implibs = grep /\.dll$/, keys %directories;
225 push @implibs, "winspool.drv";
227 print NEWMAKE "\n# Import libraries\n\nIMPORT_LIBS =";
228 foreach my $mod (sort @implibs)
230 my $def = $mod;
231 $def =~ s/\.(dll|drv)$//;
232 printf NEWMAKE " \\\n\tlib%s", $def;
234 print NEWMAKE "\n\nALL_IMPORT_LIBS = \\\n\t\$(IMPORT_LIBS:%=%.\$(IMPLIBEXT))";
235 foreach my $mod (sort keys %implib_dirs)
237 printf NEWMAKE " \\\n\t%s", $mod;
239 print NEWMAKE "\n\n";
240 print NEWMAKE "implib: \$(ALL_IMPORT_LIBS)\n\n";
242 foreach my $mod (sort @implibs)
244 my $dir = $directories{$mod};
245 my $def = $mod;
246 my $spec = $mod;
247 $spec =~ s/\.dll$//;
248 $def =~ s/\.(dll|drv)$//;
249 printf NEWMAKE "lib%s.def: %s/%s.spec.def\n", $def, $dir, $spec;
250 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.spec.def \$@\n", $dir, $spec;
251 printf NEWMAKE "lib%s.a: %s/%s.spec.def\n", $def, $dir, $spec;
252 printf NEWMAKE "\t\$(DLLTOOL) -k -l \$@ -d %s/%s.spec.def\n\n", $dir, $spec;
254 foreach my $mod (sort @implibs)
256 my $dir = $directories{$mod};
257 my $spec = $mod;
258 $spec =~ s/\.dll$//;
259 printf NEWMAKE "%s/%s.spec.def: \$(WINEBUILD)\n", $dir, $spec;
263 print NEWMAKE <<EOF;
265 \$(BUILDSUBDIRS): \$(ALL_IMPORT_LIBS)
266 \$(INSTALLSUBDIRS:%=%/__install__): \$(ALL_IMPORT_LIBS)
270 ################################################################
271 # output the inter-dll dependencies and rules
273 print NEWMAKE "# Map library name to the corresponding directory\n\n";
275 foreach my $mod (sort keys %directories)
277 printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
279 foreach my $mod (sort keys %implib_dirs)
281 printf NEWMAKE "%s/%s: %s\n", $implib_dirs{$mod}, $mod, $implib_dirs{$mod};
284 ################################################################
285 # makefile trailer
287 print NEWMAKE <<EOF;
289 # Rules for auto documentation
291 \$(SUBDIRS:%=%/__man__): dummy
292 cd `dirname \$@` && \$(MAKE) man
294 man: \$(SUBDIRS:%=%/__man__)
296 \$(SUBDIRS:%=%/__doc_html__): dummy
297 cd `dirname \$@` && \$(MAKE) doc-html
299 doc-html: \$(SUBDIRS:%=%/__doc_html__)
301 \$(SUBDIRS:%=%/__doc_sgml__): dummy
302 cd `dirname \$@` && \$(MAKE) doc-sgml
304 doc-sgml: \$(SUBDIRS:%=%/__doc_sgml__)
306 .PHONY: man doc-html doc-sgml \$(SUBDIRS:%=%/__man__) \$(SUBDIRS:%=%/__doc_html__) \$(SUBDIRS:%=%/__doc_sgml__)
308 # Misc rules
310 install install-dev:: \$(ALL_IMPORT_LIBS)
311 \$(MKINSTALLDIRS) \$(dlldir)
312 for f in \$(ALL_IMPORT_LIBS); do \$(INSTALL_DATA) \$\$f \$(dlldir)/\$\$f; done
314 install install-lib:: \$(INSTALLSUBDIRS:%=%/__install__)
316 uninstall::
317 \$(RM) \$(ALL_IMPORT_LIBS:%=\$(dlldir)/%)
318 -rmdir \$(dlldir)
320 clean::
321 \$(RM) \$(ALL_IMPORT_LIBS) \$(SYMLINKS)
323 check test:: \$(BUILDSUBDIRS:%=%/__test__)
325 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
327 checklink:: \$(BUILDSUBDIRS:%=%/__checklink__)
329 ### Dependencies:
332 close NEWMAKE;
333 rename "Makefile.in.new", "Makefile.in";
334 printf "Successfully updated Makefile.in\n";