secur32: Implement ntlmv2 signing.
[wine.git] / dlls / make_dlls
blob7969c52e209c82ea7114c2af62d5929472823843
1 #!/usr/bin/perl -w
3 # Update the dll dependencies in the dlls main Makefile.in.
5 # Copyright 2001 Alexandre Julliard
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 use strict;
24 my %directories = ();
25 my %testdirs = ();
26 my %importlibs = ();
27 my %static_implibs = ();
28 my %staticlib_dirs = ();
29 my %altnames = ();
31 # list of special dlls that can be switched on or off by configure
32 my %special_dlls =
34 "glu32" => "GLU32FILES",
35 "glut32" => "GLUT32FILES",
36 "opengl32" => "OPENGLFILES",
37 "wined3d" => "OPENGLFILES",
38 "winex11.drv" => "XFILES",
39 "winequartz.drv" => "QUARTZFILES"
42 sub needs_symlink($)
44 (my $mod = $_[0]) =~ s/\.dll$//;
45 return $mod ne $directories{$_[0]};
48 sub update_file($)
50 my $file = shift;
51 if (!system "cmp $file $file.new >/dev/null")
53 unlink "$file.new";
54 print "$file is unchanged\n";
56 else
58 rename "$file.new", "$file";
59 print "$file updated\n";
60 if (-x "./config.status" && $file =~ /(.*Makefile)\.in$/)
62 system "./config.status", $1;
67 # if we are inside the dlls dir, go up one level
68 if (! -f "configure.ac" && -f "../configure.ac") { chdir(".."); }
70 my @args = @ARGV;
71 if (!@args) { @args = map { s/^(.*)\.in/$1/; $_; } split(/\s/,`find dlls -name Makefile.in -print`); }
73 foreach my $i (@args)
75 if ($i =~ /dlls\/(.*)\/tests\/Makefile/)
77 $testdirs{$1} = "$1/tests";
78 next;
81 open MAKE, "$i.in" or die "cannot open $i.in\n";
83 my $module = undef;
84 my $dir = $i;
86 while (<MAKE>)
88 chop;
89 # EPP hack to disable this DLL... the MKDLL_SKIP comment must appear
90 # at the very top of the Makefile.in
91 last if (/^\#\s*MKDLL_SKIP/);
93 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
95 $module = $1;
96 if ($module =~ /^lib.*\.a$/)
98 ($staticlib_dirs{$module} = $i) =~ s/^dlls\/(.*)\/[^\/]+$/$1/;
99 die "invalid module $module in dir $staticlib_dirs{$module}\n" if "lib$staticlib_dirs{$module}.a" ne $module;
101 else
103 ($directories{$module} = $i) =~ s/^dlls\/(.*)\/[^\/]+$/$1/;
105 next;
107 if (/^IMPORTLIB\s*=\s*([a-zA-Z0-9_.]+)\.\$\(IMPLIBEXT\)/)
109 $importlibs{$module} = $1;
110 next;
112 if (/^IMPLIB_SRCS\s*=/)
114 $static_implibs{$module} = 1;
115 next;
117 if (/^SPEC_SRCS16\s*=\s*(.*)/)
119 my $specs = $1;
120 while ($specs =~ /\s*(.*)\\$/) { $specs = $1 . <MAKE>; }
121 my @list = split(/\s+/,$specs);
122 @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @list;
123 $altnames{$module} = \@list;
124 next;
127 close MAKE;
130 open NEWMAKE,">dlls/Makefile.in.new" or die "cannot create dlls/Makefile.in.new";
132 ################################################################
133 # makefile header
135 print NEWMAKE <<EOF;
136 # Automatically generated by make_dlls; DO NOT EDIT!!
138 TOPSRCDIR = \@top_srcdir\@
139 TOPOBJDIR = ..
140 SRCDIR = \@srcdir\@
141 VPATH = \@srcdir\@
145 ################################################################
146 # output special dlls configure definitions
148 printf NEWMAKE "# special configure-dependent targets\n\n";
149 my %specials = ();
150 foreach my $mod (sort keys %special_dlls)
152 $specials{$special_dlls{$mod}} .= " " . $mod;
154 foreach my $i (sort keys %specials)
156 printf NEWMAKE "%s =%s\n", $i, $specials{$i};
158 printf NEWMAKE "EXTRADIRS =";
159 foreach my $i (sort keys %specials) { printf NEWMAKE " \@%s\@", $i; }
160 printf NEWMAKE "\n\n";
163 ################################################################
164 # output the subdirs list
166 print NEWMAKE "# Subdir list\n\nBASEDIRS =";
167 foreach my $dir (sort values %directories)
169 next if defined($special_dlls{$dir}); # skip special dlls
170 printf NEWMAKE " \\\n\t%s", $dir;
173 print NEWMAKE "\n\nIMPLIBSUBDIRS = \\\n\t";
174 print NEWMAKE join " \\\n\t", sort values %staticlib_dirs;
176 print NEWMAKE "\n\nTESTSUBDIRS = \\\n\t";
177 print NEWMAKE join " \\\n\t", sort values %testdirs;
179 print NEWMAKE "\n\nSUBDIRS = \\\n\t";
180 print NEWMAKE join " \\\n\t", "\$(BASEDIRS)", "\$(IMPLIBSUBDIRS)", "\$(TESTSUBDIRS)",
181 sort keys %special_dlls;
182 print NEWMAKE <<EOF;
185 BUILDSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(TESTSUBDIRS)
186 INSTALLSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS) \$(IMPLIBSUBDIRS)
187 DOCSUBDIRS = \$(BASEDIRS) \$(EXTRADIRS)
190 ################################################################
191 # output the all: target
193 my %targets = (); # use a hash to get rid of duplicate target names
194 my %targets16 = ();
195 foreach my $mod (sort keys %directories)
197 next if defined($special_dlls{$directories{$mod}}); # skip special dlls
198 $targets{$mod . ".so"} = 1 if needs_symlink($mod);
199 next unless defined $altnames{$mod};
200 foreach my $i (sort @{$altnames{$mod}})
202 $targets16{$i . "16"} = $mod;
206 print NEWMAKE <<EOF;
208 \@MAKE_RULES\@
210 # Symbolic links
212 WIN16_FILES = \\
214 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets16 );
216 print NEWMAKE <<EOF;
218 SYMLINKS_SO = \\
219 \@WIN16_FILES\@ \\
221 printf NEWMAKE "\t%s\n", join( " \\\n\t", sort keys %targets );
223 print NEWMAKE <<EOF;
225 # Main target
227 all: \$(BUILDSUBDIRS) symlinks\$(DLLEXT)
229 .PHONY: symlinks symlinks.so implib
231 symlinks.so: \$(SYMLINKS_SO)
233 symlinks: \$(BUILDSUBDIRS)
237 ################################################################
238 # output the lib name -> directory rules
240 print NEWMAKE "# Map symlink name to the corresponding library\n\n";
241 foreach my $mod (sort keys %directories)
243 next unless needs_symlink($mod);
244 printf NEWMAKE "%s.so: %s/%s.so\n", $mod, $directories{$mod}, $mod;
245 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.so \$@\n\n", $directories{$mod}, $mod;
248 print NEWMAKE "# Placeholders for 16-bit libraries\n\n";
249 foreach my $mod (sort keys %directories)
251 next unless defined $altnames{$mod};
252 printf NEWMAKE "%s:\n", join(" ", map { $_ . "16"; } sort @{$altnames{$mod}});
253 printf NEWMAKE "\techo \"%s\" >\$\@\n\n", $mod;
256 ################################################################
257 # output the import libraries rules
259 print NEWMAKE "# Import libraries\n\n";
260 print NEWMAKE "STATIC_IMPLIBEXT = \$(IMPLIBEXT:def=def.a)\n\n";
262 my @lib_symlinks = ();
263 foreach my $mod (sort keys %importlibs)
265 my $dir = $directories{$mod};
266 my $lib = $importlibs{$mod};
267 if ($lib ne "lib" . $dir) { push @lib_symlinks, $mod; }
269 print NEWMAKE "IMPORT_SYMLINKS =";
270 foreach my $mod (sort @lib_symlinks)
272 printf NEWMAKE " \\\n\t%s.\$(IMPLIBEXT)", $importlibs{$mod};
275 print NEWMAKE "\n\nIMPORT_LIBS = \\\n\t\$(IMPORT_SYMLINKS)";
276 foreach my $mod (sort keys %staticlib_dirs)
278 printf NEWMAKE " \\\n\t%s/%s", $staticlib_dirs{$mod}, $mod;
280 foreach my $mod (sort keys %importlibs)
282 my $dir = $directories{$mod};
283 my $def = $mod;
284 $def =~ s/\.(dll|drv)$//;
285 printf NEWMAKE " \\\n\t%s/lib%s.\$(IMPLIBEXT)", $dir, $def;
286 printf NEWMAKE " \\\n\t%s/lib%s.\$(STATIC_IMPLIBEXT)", $dir, $def if $static_implibs{$mod};
288 print NEWMAKE "\n\n";
289 print NEWMAKE "implib: \$(IMPORT_LIBS)\n\n";
291 foreach my $mod (sort keys %importlibs)
293 my $dir = $directories{$mod};
294 my $lib = $importlibs{$mod};
295 my $spec = $mod;
296 $spec =~ s/\.dll$//;
297 printf NEWMAKE "%s/%s.\$(IMPLIBEXT): %s/%s.spec \$(WINEBUILD)\n", $dir, $lib, $dir, $spec;
298 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(IMPLIBEXT)\n\n", $dir, $lib;
299 next unless $static_implibs{$mod};
300 printf NEWMAKE "%s/%s.\$(STATIC_IMPLIBEXT): dummy\n", $dir, $lib, $dir, $spec;
301 printf NEWMAKE "\t\@cd %s && \$(MAKE) %s.\$(STATIC_IMPLIBEXT)\n\n", $dir, $lib;
303 foreach my $mod (sort @lib_symlinks)
305 my $dir = $directories{$mod};
306 my $lib = $importlibs{$mod} . ".\$(IMPLIBEXT)";
307 printf NEWMAKE "%s: %s/%s\n", $lib, $dir, $lib;
308 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s \$@\n\n", $dir, $lib;
311 print NEWMAKE <<EOF;
312 \$(BUILDSUBDIRS): \$(IMPORT_LIBS)
313 \$(INSTALLSUBDIRS:%=%/__install__) \$(INSTALLSUBDIRS:%=%/__install-lib__): \$(IMPORT_LIBS)
317 ################################################################
318 # output the inter-dll dependencies and rules
320 print NEWMAKE "# Map library name to the corresponding directory\n\n";
322 foreach my $mod (sort keys %directories)
324 next unless needs_symlink($mod);
325 printf NEWMAKE "%s/%s.so: %s\n", $directories{$mod}, $mod, $directories{$mod};
327 foreach my $mod (sort keys %staticlib_dirs)
329 printf NEWMAKE "%s/%s: %s\n", $staticlib_dirs{$mod}, $mod, $staticlib_dirs{$mod};
332 ################################################################
333 # makefile trailer
335 print NEWMAKE <<EOF;
337 # Misc rules
339 install-lib:: \$(INSTALLSUBDIRS:%=%/__install-lib__)
341 install-dev:: \$(INSTALLSUBDIRS:%=%/__install-dev__)
343 uninstall::
344 -rmdir \$(DESTDIR)\$(dlldir)
346 clean::
347 \$(RM) \$(IMPORT_SYMLINKS) \$(WIN16_FILES)
350 close NEWMAKE;
351 update_file("dlls/Makefile.in");
353 ################################################################
354 # .gitignore file
356 open GITIGNORE, ">dlls/.gitignore.new" or die "cannot create dlls/.gitignore.new";
357 print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n";
359 my @ignores =
361 "/Makedll.rules",
362 "/Makeimplib.rules",
363 "/Maketest.rules",
364 "*/tests/testlist.c",
365 "*/tests/*.ok",
368 foreach my $mod (sort @lib_symlinks)
370 push @ignores, "/$importlibs{$mod}.def";
372 foreach my $mod (sort keys %directories)
374 next unless defined $altnames{$mod};
375 push @ignores, map { "/" . $_ . "16"; } @{$altnames{$mod}};
377 foreach my $mod (sort keys %importlibs)
379 my $dir = $directories{$mod};
380 my $def = $mod;
381 $def =~ s/\.(dll|drv)$//;
382 push @ignores, "$dir/lib$def.def";
385 print GITIGNORE join("\n", sort @ignores) . "\n";
387 close GITIGNORE;
388 update_file("dlls/.gitignore");