Commit 80d12c35 authored by Alexandre Julliard's avatar Alexandre Julliard

makefiles: Automatically update the EXTRASUBDIRS variable in make_makefiles.

parent 59ee6d83
......@@ -19,7 +19,10 @@
# xmlpages: compile xml source for the Wine API Guide
# Sub-directories that don't have a makefile
EXTRASUBDIRS = dlls libs programs
EXTRASUBDIRS = \
dlls \
libs \
programs
# Destination directories for make install
INSTALLDIRS = $(DESTDIR)$(bindir)
......
......@@ -554,7 +554,11 @@ SRCDIR_INCLUDES = \
xmldsodid.h \
zmouse.h
EXTRASUBDIRS = ddk msvcrt msvcrt/sys wine
EXTRASUBDIRS = \
ddk \
msvcrt \
msvcrt/sys \
wine
INSTALLDIRS = \
$(DESTDIR)$(includedir)/windows/ddk \
......
......@@ -119,6 +119,8 @@ my @ignore_srcs = (
[ 'IDL_I_SRCS', '\.idl', '_i.c' ],
[ 'IDL_P_SRCS', '\.idl', '_p.c' ],
[ 'IDL_S_SRCS', '\.idl', '_s.c' ],
[ 'PUBLIC_IDL_H_SRCS', '\.idl', '.h' ],
[ 'PRIVATE_IDL_H_SRCS', '\.idl', '.h' ],
);
my %exported_wine_headers = (
......@@ -168,7 +170,7 @@ my %ignored_source_files = (
"programs/winetest/dist.rc" => 1,
);
my (@all_files, @makefiles, %makefiles);
my (@makefiles, %makefiles);
sub dirname($)
{
......@@ -285,7 +287,7 @@ sub replace_makefile_variable($$)
return update_file("$file.in");
}
# parse the specified makefile to identify the rules file
# parse the specified makefile and load the variables
sub parse_makefile($)
{
my $file = shift;
......@@ -328,28 +330,63 @@ sub parse_makefile($)
}
# assign source files to their respective makefile
sub assign_sources_to_makefiles()
sub assign_sources_to_makefiles(@)
{
foreach my $file (@all_files)
my %subdirs;
foreach my $file (@_)
{
next if defined $ignored_source_files{$file};
my $dir = dirname( $file );
my $subdir = $dir;
while ($dir && !defined $makefiles{"$dir/Makefile"}) { $dir = dirname( $dir ); }
$subdir =~ s/^$dir\/?//;
$subdirs{"$dir/ $subdir"} = 1 if $subdir;
next unless $dir;
die "no makefile found for $file\n" unless defined $makefiles{"$dir/Makefile"};
my $make = $makefiles{"$dir/Makefile"};
my $basename = substr( $file, length($dir) + 1 );
if ($basename =~ /\.c$/) { push @{${$make}{"=C_SRCS"}}, $basename; }
elsif ($basename =~ /\.l$/) { push @{${$make}{"=LEX_SRCS"}}, $basename; }
elsif ($basename =~ /\.y$/) { push @{${$make}{"=BISON_SRCS"}}, $basename; }
elsif ($basename =~ /\.rc$/) { push @{${$make}{"=RC_SRCS"}}, $basename; }
elsif ($basename =~ /\.mc$/) { push @{${$make}{"=MC_SRCS"}}, $basename; }
elsif ($basename =~ /\.svg$/) { push @{${$make}{"=SVG_SRCS"}}, $basename; }
my $name = substr( $file, length($dir) + 1 );
if ($dir eq "include")
{
next if ($name =~ /\.in$/);
if ($name =~ /^wine\// && !$exported_wine_headers{$name})
{
if ($private_idl_headers{$name}) { push @{${$make}{"=PRIVATE_IDL_H_SRCS"}}, $name; }
next;
}
if ($name =~ /stdole2\.idl$/) { push @{${$make}{"=IDL_TLB_SRCS"}}, $name; }
elsif ($private_idl_headers{$name}) { push @{${$make}{"=SRCDIR_INCLUDES"}}, $name; }
elsif ($name =~ /\.h$/) { push @{${$make}{"=SRCDIR_INCLUDES"}}, $name; }
elsif ($name =~ /\.rh$/) { push @{${$make}{"=SRCDIR_INCLUDES"}}, $name; }
elsif ($name =~ /\.inl$/) { push @{${$make}{"=SRCDIR_INCLUDES"}}, $name; }
elsif ($name =~ /\.idl$/) { push @{${$make}{"=PUBLIC_IDL_H_SRCS"}}, $name; }
else { die "unknown file $name in include dir"; }
}
else
{
if ($name =~ /\.c$/) { push @{${$make}{"=C_SRCS"}}, $name; }
elsif ($name =~ /\.l$/) { push @{${$make}{"=LEX_SRCS"}}, $name; }
elsif ($name =~ /\.y$/) { push @{${$make}{"=BISON_SRCS"}}, $name; }
elsif ($name =~ /\.rc$/) { push @{${$make}{"=RC_SRCS"}}, $name; }
elsif ($name =~ /\.mc$/) { push @{${$make}{"=MC_SRCS"}}, $name; }
elsif ($name =~ /\.svg$/) { push @{${$make}{"=SVG_SRCS"}}, $name; }
}
}
foreach my $key (keys %subdirs)
{
my ($dir, $subdir) = split " ", $key;
if ($dir eq "/") { $dir = ""; }
push @{${$makefiles{"${dir}Makefile"}}{"=EXTRASUBDIRS"}}, $subdir;
}
# add extra variables to include source list
my $make = $makefiles{"include/Makefile"};
unshift @{${$make}{"=SRCDIR_INCLUDES"}}, "\$(PUBLIC_IDL_H_SRCS)";
unshift @{${$make}{"=SRCDIR_INCLUDES"}}, "\$(IDL_TLB_SRCS)";
}
################################################################
......@@ -439,14 +476,17 @@ sub update_makefiles(@)
foreach my $file (sort @_)
{
my %make = %{$makefiles{$file}};
replace_makefile_variable( $file, "LEX_SRCS" );
replace_makefile_variable( $file, "BISON_SRCS" );
replace_makefile_variable( $file, "MC_SRCS" );
replace_makefile_variable( $file, "SVG_SRCS" );
replace_makefile_variable( $file, "C_SRCS" );
replace_makefile_variable( $file, "RC_SRCS" );
replace_makefile_variable( $file, "PRIVATE_IDL_H_SRCS" );
replace_makefile_variable( $file, "PUBLIC_IDL_H_SRCS" );
replace_makefile_variable( $file, "IDL_TLB_SRCS" );
replace_makefile_variable( $file, "SRCDIR_INCLUDES" );
replace_makefile_variable( $file, "EXTRASUBDIRS" );
}
push @lines, "dnl End of auto-generated output commands\n";
......@@ -494,46 +534,6 @@ sub update_ignores(@)
################################################################
# update include/Makefile.in
sub update_includes()
{
my (@h_srcs, @private_idl_srcs, @public_idl_srcs, @tlb_srcs, %subdirs);
my @includes = map { (my $ret = $_) =~ s/^include\///; $ret; } grep /^include\//, @all_files;
foreach my $incl (@includes)
{
if ($incl =~ /(.*)\//) { $subdirs{$1} = 1; }
next if ($incl =~ /\.in$/);
if ($incl =~ /^wine\// && !$exported_wine_headers{$incl})
{
if ($private_idl_headers{$incl}) { push @private_idl_srcs, $incl; }
next;
}
if ($incl =~ /stdole2\.idl$/) { push @tlb_srcs, $incl; }
elsif ($private_idl_headers{$incl}) { push @h_srcs, $incl; }
elsif ($incl =~ /\.h$/) { push @h_srcs, $incl; }
elsif ($incl =~ /\.rh$/) { push @h_srcs, $incl; }
elsif ($incl =~ /\.inl$/) { push @h_srcs, $incl; }
elsif ($incl =~ /\.idl$/) { push @public_idl_srcs, $incl; }
else { die "unknown file $incl in include dir"; }
}
replace_in_file( "include/Makefile.in", '^PRIVATE_IDL_H_SRCS\s*=', '^INSTALLDIRS',
"PRIVATE_IDL_H_SRCS = \\\n\t",
join( " \\\n\t", sort @private_idl_srcs ),
"\n\nPUBLIC_IDL_H_SRCS = \\\n\t",
join( " \\\n\t", sort @public_idl_srcs ),
"\n\nIDL_TLB_SRCS = \\\n\t",
join( " \\\n\t", sort @tlb_srcs ),
"\n\nSRCDIR_INCLUDES = \\\n\t\$(IDL_TLB_SRCS) \\\n\t\$(PUBLIC_IDL_H_SRCS) \\\n\t",
join( " \\\n\t", sort @h_srcs ),
"\n\nEXTRASUBDIRS = ",
join( " ", sort keys %subdirs ),
"\n\nINSTALLDIRS = \\\n" );
return map { s/(.*)\.idl$/include\/$1.h/; $_; } @public_idl_srcs, @private_idl_srcs;
}
################################################################
# update the main .gitignore
sub update_gitignore(@)
......@@ -565,7 +565,7 @@ sub update_gitignore(@)
die "needs to be run from a git checkout" unless -d ".git";
@all_files = split /\0/, `git ls-files -c -z`;
my @all_files = split /\0/, `git ls-files -c -z`;
@makefiles = map { my $ret = $_; $ret =~ s/\.in$//; $ret; } grep /Makefile.in$/, @all_files;
foreach my $file (sort values %makerules, @makefiles)
......@@ -574,8 +574,7 @@ foreach my $file (sort values %makerules, @makefiles)
$makefiles{$file} = \%make;
}
assign_sources_to_makefiles();
assign_sources_to_makefiles( @all_files );
update_makefiles( @makefiles );
push @ignores, update_includes();
push @ignores, update_ignores( @makefiles );
update_gitignore( @ignores );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment