3 # Build the auto-generated parts of the Wine makefiles.
5 # Copyright 2006 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 # update a file if changed
26 my $ret = system "cmp $file $file.new >/dev/null";
30 print "$file is unchanged\n";
34 rename "$file.new", "$file";
35 print "$file updated\n";
40 # replace some lines in a file between two markers
41 sub replace_in_file($$$@)
47 open OLD_FILE, "$file" or die "cannot open $file";
48 open NEW_FILE, ">$file.new" or die "cannot create $file.new";
63 print NEW_FILE $_ unless $skip;
70 return update_file($file);
73 my (@makefiles, @makerules);
77 @makefiles = map { s/\.in$//; $_; } split /\s/, `git ls-files -c Makefile.in \\*/Makefile.in`;
78 @makerules = map { s/\.in$//; $_; } split /\s/, `git ls-files -c Make\\*rules.in \\*/Make\\*rules.in`;
82 @makefiles = map { s/^\.\/(.*)\.in/$1/; $_; } split(/\s/,`find . -name Makefile.in -print`);
83 @makerules = map { s/^\.\/(.*)\.in/$1/; $_; } split(/\s/,`find . -name Make\\*.rules.in -print`);
87 ################################################################
88 # update the makefile list in configure.ac
90 replace_in_file( "configure.ac", '^AC_CONFIG_FILES\(', '\]\)$',
91 "AC_CONFIG_FILES([\n",
92 join ("\n", (sort @makerules), (sort @makefiles) ), "])\n" );
95 ################################################################
96 # update the tests list in programs/winetest/Makefile.in
98 my %modules = ( "kernel" => "kernel32", "gdi" => "gdi32", "user" => "user32" );
100 my @lines = ( "TESTBINS =" );
102 foreach my $file (sort grep /^dlls\/.*\/tests\/Makefile/, @makefiles)
104 if ($file =~ /^dlls\/(.*)\/tests\/Makefile/)
107 my $mod = $modules{$dir} || $dir;
109 push @lines, " \\\n\t${mod}_test.exe\$(DLLEXT)";
114 foreach my $test (sort keys %tests)
116 my $dir = $tests{$test};
117 push @lines, "${test}_test.exe\$(DLLEXT): \$(DLLDIR)/$dir/tests/${test}_test.exe\$(DLLEXT)\n";
118 push @lines, "\tcp \$(DLLDIR)/$dir/tests/${test}_test.exe\$(DLLEXT) \$\@ && \$(STRIP) \$\@\n";
120 push @lines, "\n# Special rules\n";
122 replace_in_file( "programs/winetest/Makefile.in", '^TESTBINS\s*=', '^# Special rules', @lines );
125 ################################################################
126 # update dlls/Makefile.in
128 my @dll_makefiles = grep /^dlls\//, @makefiles;
129 system "dlls/make_dlls", @dll_makefiles;
132 ################################################################
133 # update programs/Makefile.in
135 my @prog_makefiles = grep /^programs\//, @makefiles;
136 system "programs/make_progs", @prog_makefiles;