2006-08-28 11:57:10 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
#
|
|
|
|
# Build the auto-generated parts of the Wine makefiles.
|
|
|
|
#
|
|
|
|
# Copyright 2006 Alexandre Julliard
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
#
|
|
|
|
|
2006-09-24 12:11:39 +02:00
|
|
|
# Make rules files
|
2006-09-22 09:27:29 +02:00
|
|
|
my %makerules =
|
|
|
|
(
|
|
|
|
"MAKE_RULES" => "Make.rules",
|
|
|
|
"MAKE_DLL_RULES" => "dlls/Makedll.rules",
|
|
|
|
"MAKE_IMPLIB_RULES" => "dlls/Makeimplib.rules",
|
|
|
|
"MAKE_TEST_RULES" => "dlls/Maketest.rules",
|
|
|
|
"MAKE_PROG_RULES" => "programs/Makeprog.rules",
|
|
|
|
);
|
|
|
|
|
2006-09-24 12:11:39 +02:00
|
|
|
# Programs that we want to install in the bin directory too
|
|
|
|
my %bin_install =
|
|
|
|
(
|
|
|
|
"msiexec" => 1,
|
|
|
|
"notepad" => 1,
|
|
|
|
"progman" => 1,
|
|
|
|
"regedit" => 1,
|
|
|
|
"regsvr32" => 1,
|
|
|
|
"uninstaller" => 1,
|
|
|
|
"wineboot" => 1,
|
|
|
|
"winebrowser" => 1,
|
|
|
|
"winecfg" => 1,
|
|
|
|
"wineconsole" => 1,
|
|
|
|
"winedbg" => 1,
|
|
|
|
"winefile" => 1,
|
|
|
|
"winemine" => 1,
|
|
|
|
"winepath" => 1,
|
|
|
|
"winhelp" => 1,
|
|
|
|
);
|
|
|
|
|
|
|
|
# Programs that we don't want to install at all
|
|
|
|
my %dont_install =
|
|
|
|
(
|
|
|
|
"cmdlgtst" => 1,
|
|
|
|
"view" => 1,
|
|
|
|
"winetest" => 1,
|
|
|
|
);
|
|
|
|
|
2006-09-22 09:27:29 +02:00
|
|
|
my (@makefiles, %makefiles);
|
|
|
|
|
2006-08-28 11:57:10 +02:00
|
|
|
# update a file if changed
|
|
|
|
sub update_file($)
|
|
|
|
{
|
|
|
|
my $file = shift;
|
|
|
|
my $ret = system "cmp $file $file.new >/dev/null";
|
|
|
|
if (!$ret)
|
|
|
|
{
|
|
|
|
unlink "$file.new";
|
2006-09-22 09:27:29 +02:00
|
|
|
#print "$file is unchanged\n";
|
2006-08-28 11:57:10 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rename "$file.new", "$file";
|
|
|
|
print "$file updated\n";
|
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
# replace some lines in a file between two markers
|
|
|
|
sub replace_in_file($$$@)
|
|
|
|
{
|
|
|
|
my $file = shift;
|
|
|
|
my $start = shift;
|
|
|
|
my $end = shift;
|
|
|
|
|
|
|
|
open NEW_FILE, ">$file.new" or die "cannot create $file.new";
|
|
|
|
|
2006-09-24 12:11:39 +02:00
|
|
|
if (defined($start))
|
2006-08-28 11:57:10 +02:00
|
|
|
{
|
2006-09-24 12:11:39 +02:00
|
|
|
open OLD_FILE, "$file" or die "cannot open $file";
|
|
|
|
while (<OLD_FILE>)
|
|
|
|
{
|
|
|
|
last if /$start/;
|
|
|
|
print NEW_FILE $_;
|
|
|
|
}
|
2006-08-28 11:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print NEW_FILE @_;
|
|
|
|
|
|
|
|
if (defined($end))
|
|
|
|
{
|
|
|
|
my $skip=1;
|
|
|
|
while (<OLD_FILE>)
|
|
|
|
{
|
|
|
|
print NEW_FILE $_ unless $skip;
|
|
|
|
$skip = 0 if /$end/;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-24 12:11:39 +02:00
|
|
|
close OLD_FILE if defined($start);
|
2006-08-28 11:57:10 +02:00
|
|
|
close NEW_FILE;
|
|
|
|
return update_file($file);
|
|
|
|
}
|
|
|
|
|
2006-09-22 09:27:29 +02:00
|
|
|
# parse the specified makefile to identify the rules file
|
|
|
|
sub parse_makefile($)
|
|
|
|
{
|
|
|
|
my $file = shift;
|
2006-09-24 12:11:39 +02:00
|
|
|
my %make;
|
2006-09-22 09:27:29 +02:00
|
|
|
|
|
|
|
open MAKE, "$file.in" or die "cannot open $file.in\n";
|
|
|
|
|
|
|
|
while (<MAKE>)
|
|
|
|
{
|
|
|
|
chomp;
|
|
|
|
while (/\\$/) { chop; $_ .= <MAKE>; chomp; } # merge continued lines
|
|
|
|
|
|
|
|
if (/^\@(MAKE.*RULES)\@/)
|
|
|
|
{
|
|
|
|
my $var = $1;
|
2006-09-24 12:11:39 +02:00
|
|
|
$make{"=rules"} = $makerules{$var};
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
|
|
|
|
{
|
|
|
|
$make{"MODULE"} = $1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^\#\s*MKDLL_SKIP/ || /^\#\s*MKPROG_SKIP/)
|
|
|
|
{
|
|
|
|
$make{"=skip"} = 1;
|
|
|
|
next;
|
2006-09-22 09:27:29 +02:00
|
|
|
}
|
|
|
|
}
|
2006-09-24 12:11:39 +02:00
|
|
|
return %make;
|
2006-09-22 09:27:29 +02:00
|
|
|
}
|
2006-08-28 11:57:10 +02:00
|
|
|
|
|
|
|
if (-d ".git")
|
|
|
|
{
|
|
|
|
@makefiles = map { s/\.in$//; $_; } split /\s/, `git ls-files -c Makefile.in \\*/Makefile.in`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@makefiles = map { s/^\.\/(.*)\.in/$1/; $_; } split(/\s/,`find . -name Makefile.in -print`);
|
|
|
|
}
|
|
|
|
|
2006-09-22 09:27:29 +02:00
|
|
|
foreach my $file (sort values %makerules, @makefiles)
|
|
|
|
{
|
2006-09-24 12:11:39 +02:00
|
|
|
my %make = parse_makefile( $file );
|
|
|
|
$makefiles{$file} = \%make;
|
2006-09-22 09:27:29 +02:00
|
|
|
}
|
2006-08-28 11:57:10 +02:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
# update the makefile list in configure.ac
|
|
|
|
|
2006-09-22 09:27:29 +02:00
|
|
|
my @lines = ();
|
|
|
|
|
|
|
|
foreach my $var (sort { $makerules{$a} cmp $makerules{$b}; } keys %makerules)
|
|
|
|
{
|
|
|
|
push @lines, "$var=$makerules{$var}\n";
|
|
|
|
push @lines, "AC_SUBST_FILE($var)\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
replace_in_file( "configure.ac", '^MAKE_RULES', '\]\)$',
|
|
|
|
@lines,
|
2006-08-28 11:57:10 +02:00
|
|
|
"AC_CONFIG_FILES([\n",
|
2006-09-22 09:27:29 +02:00
|
|
|
join ("\n", (sort values %makerules), (sort @makefiles) ), "])\n" );
|
2006-08-28 11:57:10 +02:00
|
|
|
|
|
|
|
|
2006-08-28 11:58:31 +02:00
|
|
|
################################################################
|
2006-09-11 14:32:00 +02:00
|
|
|
# update the tests list in programs/winetest/Makefile.in and programs/winetest/winetest.rc
|
2006-08-28 11:58:31 +02:00
|
|
|
|
2006-10-20 12:25:29 +02:00
|
|
|
my %modules = ( "user" => "user32" );
|
2006-08-28 11:58:31 +02:00
|
|
|
my %tests;
|
2006-09-22 09:27:29 +02:00
|
|
|
@lines = ( "TESTBINS =" );
|
2006-08-28 11:58:31 +02:00
|
|
|
|
|
|
|
foreach my $file (sort grep /^dlls\/.*\/tests\/Makefile/, @makefiles)
|
|
|
|
{
|
|
|
|
if ($file =~ /^dlls\/(.*)\/tests\/Makefile/)
|
|
|
|
{
|
|
|
|
my $dir = $1;
|
|
|
|
my $mod = $modules{$dir} || $dir;
|
|
|
|
$tests{$mod} = $dir;
|
2006-09-11 14:32:00 +02:00
|
|
|
push @lines, " \\\n\t${mod}_test.exe";
|
2006-08-28 11:58:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
push @lines, "\n\n";
|
|
|
|
|
|
|
|
foreach my $test (sort keys %tests)
|
|
|
|
{
|
|
|
|
my $dir = $tests{$test};
|
2006-09-11 14:32:00 +02:00
|
|
|
push @lines, "${test}_test.exe: \$(DLLDIR)/$dir/tests/${test}_test.exe\$(DLLEXT)\n";
|
2006-08-28 11:58:31 +02:00
|
|
|
push @lines, "\tcp \$(DLLDIR)/$dir/tests/${test}_test.exe\$(DLLEXT) \$\@ && \$(STRIP) \$\@\n";
|
|
|
|
}
|
|
|
|
push @lines, "\n# Special rules\n";
|
|
|
|
|
|
|
|
replace_in_file( "programs/winetest/Makefile.in", '^TESTBINS\s*=', '^# Special rules', @lines );
|
|
|
|
|
2006-09-11 14:32:00 +02:00
|
|
|
@lines = ();
|
|
|
|
foreach my $test (sort keys %tests)
|
|
|
|
{
|
|
|
|
push @lines, "${test}_test.exe TESTRES \"${test}_test.exe\"\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
replace_in_file( "programs/winetest/winetest.rc", ' TESTRES ', undef, @lines );
|
2006-08-28 11:58:31 +02:00
|
|
|
|
2006-09-14 09:41:21 +02:00
|
|
|
################################################################
|
|
|
|
# update the makefile list in Makefile.in
|
|
|
|
|
|
|
|
my @targets;
|
|
|
|
my @depends;
|
|
|
|
|
2006-09-22 09:27:29 +02:00
|
|
|
foreach my $file (sort values %makerules)
|
2006-09-14 09:41:21 +02:00
|
|
|
{
|
|
|
|
push @targets, $file;
|
2006-09-24 12:11:39 +02:00
|
|
|
my %make = %{$makefiles{$file}};
|
|
|
|
if (!defined($make{"=rules"})) { push @depends, "$file: $file.in"; }
|
2006-09-14 09:41:21 +02:00
|
|
|
else { push @depends, "$file: $file.in Make.rules"; }
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $file (sort @makefiles)
|
|
|
|
{
|
|
|
|
push @targets, $file unless $file eq "Makefile";
|
2006-09-24 12:11:39 +02:00
|
|
|
my $dep = ${$makefiles{$file}}{"=rules"};
|
2006-09-14 09:41:21 +02:00
|
|
|
push @depends, "$file: $file.in $dep";
|
|
|
|
}
|
|
|
|
|
|
|
|
@lines = ();
|
|
|
|
push @lines, "ALL_MAKEFILES = \\\n\t";
|
|
|
|
push @lines, join (" \\\n\t", @targets ), "\n\n";
|
|
|
|
push @lines, "Makefile \$(ALL_MAKEFILES): config.status\n";
|
|
|
|
push @lines, "\t\@./config.status \$\@\n\n";
|
|
|
|
push @lines, "\$(RECURSE_TARGETS) \$(MAKEDEP): \$(ALL_MAKEFILES)\n\n";
|
|
|
|
push @lines, "distclean::\n";
|
|
|
|
push @lines, "\t\$(RM) Makefile \$(ALL_MAKEFILES)\n\n";
|
|
|
|
push @lines, join ("\n", @depends ), "\n";
|
|
|
|
|
|
|
|
replace_in_file( "Makefile.in", '^ALL_MAKEFILES\s*=', undef, @lines );
|
|
|
|
|
|
|
|
|
2006-08-28 11:57:10 +02:00
|
|
|
################################################################
|
|
|
|
# update dlls/Makefile.in
|
|
|
|
|
|
|
|
my @dll_makefiles = grep /^dlls\//, @makefiles;
|
|
|
|
system "dlls/make_dlls", @dll_makefiles;
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
2006-09-24 12:11:39 +02:00
|
|
|
# update programs/Makefile.in and programs/.gitignore
|
|
|
|
|
|
|
|
sub update_progs(@)
|
|
|
|
{
|
|
|
|
my (@subdirs, @install_subdirs, @install_progs);
|
|
|
|
|
|
|
|
my @ignores =
|
|
|
|
(
|
|
|
|
"/Makeprog.rules",
|
|
|
|
"/wineapploader",
|
|
|
|
"/winelauncher",
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach my $make (@_)
|
|
|
|
{
|
|
|
|
my %makefile = %{$makefiles{$make}};
|
|
|
|
my $module = $makefile{"MODULE"};
|
|
|
|
(my $dir = $make) =~ s/^programs\/(.*)\/Makefile$/$1/;
|
|
|
|
die "Invalid module $module in $make" unless "$dir.exe" eq $module;
|
|
|
|
next if defined $makefile{"=skip"};
|
|
|
|
push @subdirs, $dir;
|
|
|
|
push @ignores, "$dir/$dir";
|
|
|
|
push @install_subdirs, $dir unless $dont_install{$dir};
|
|
|
|
push @install_progs, $dir if $bin_install{$dir};
|
|
|
|
}
|
|
|
|
|
|
|
|
replace_in_file( "programs/Makefile.in", '^SUBDIRS\s*=', '^INSTALLDIRS',
|
|
|
|
"SUBDIRS = \\\n\t",
|
|
|
|
join( " \\\n\t", @subdirs ),
|
|
|
|
"\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS = \\\n\t",
|
|
|
|
join( " \\\n\t", @install_subdirs ),
|
|
|
|
"\n\n# Programs to install in bin directory\nINSTALLPROGS = \\\n\t",
|
|
|
|
join( " \\\n\t", @install_progs ),
|
|
|
|
"\n\nINSTALLDIRS = \$(DESTDIR)\$(bindir)\n" );
|
|
|
|
|
|
|
|
replace_in_file( "programs/.gitignore", undef, undef,
|
|
|
|
"# Automatically generated by make_makefiles; DO NOT EDIT!!\n",
|
|
|
|
join("\n", sort @ignores), "\n" );
|
|
|
|
}
|
2006-08-28 11:57:10 +02:00
|
|
|
|
2006-09-24 12:11:39 +02:00
|
|
|
update_progs( sort grep /^programs\/.*\/Makefile$/, @makefiles );
|