From: Anton Baskanov <baskanov@gmail.com> --- tools/make_makefiles | 21 ++++++++++++++++++++- tools/makedep.c | 16 +++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/make_makefiles b/tools/make_makefiles index a6d0d6b210c..045c2190765 100755 --- a/tools/make_makefiles +++ b/tools/make_makefiles @@ -146,7 +146,7 @@ sub parse_makefile($) $make{$var} = $2; next; } - if (/^\s*(SOURCES|INSTALL_LIB)\s*=\s*(.*)/) + if (/^\s*(SOURCES|[_A-Za-z][_A-Za-z0-9]*_SOURCES|INSTALL_LIB)\s*=\s*(.*)/) { my $var = $1; my @list = split(/\s+/, $2); @@ -213,6 +213,22 @@ sub get_parent_makefile($) return "$path$reldir/Makefile.in"; } +# exclude arch-specific source files that are listed in the existing makefile +sub exclude_arch_source_files($) +{ + my $make = shift; + + foreach my $var (keys %{$make}) + { + next unless $var =~ /^[_A-Za-z][_A-Za-z0-9]*_SOURCES$/; + + my %srcs; + foreach my $file (@{${$make}{$var}}) { $srcs{$file} = 1; } + + @{${$make}{"=SOURCES"}} = map { defined $srcs{$_} ? () : ($_) } @{${$make}{"=SOURCES"}} + } +} + # preserve shared source files that are listed in the existing makefile sub preserve_shared_source_files($$) { @@ -306,6 +322,9 @@ sub assign_sources_to_makefiles(@) push @{${$make}{"=SOURCES"}}, $name; } + # exclude arch-specific source files + foreach my $file (@makefiles) { exclude_arch_source_files( $makefiles{$file} ); } + # preserve shared source files from the parent makefile foreach my $file (@makefiles) { diff --git a/tools/makedep.c b/tools/makedep.c index 90a522640fe..2594f65a8ba 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -1723,12 +1723,13 @@ static void parse_file( struct makefile *make, struct incl_file *source, bool sr * * Add a source file to the list. */ -static struct incl_file *add_src_file( struct makefile *make, const char *name ) +static struct incl_file *add_src_file( struct makefile *make, const char *name, int arch ) { struct incl_file *file = xmalloc( sizeof(*file) ); memset( file, 0, sizeof(*file) ); file->name = xstrdup(name); + file->arch = arch; file->use_msvcrt = is_using_msvcrt( make ); list_add_tail( &make->sources, &file->entry ); if (make == include_makefile) @@ -3564,7 +3565,8 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou if (strendswith( source->name, ".S" ) && is_subdir_other_arch( source->name, arch )) return; - obj_name = strmake( "%s%s.o", source->arch ? "" : arch_dirs[arch], obj ); + obj_name = strmake( "%s%s.o", + (source->file->flags & FLAG_GENERATED) && source->arch ? "" : arch_dirs[arch], obj ); strarray_add( targets, obj_name ); if (source->file->flags & FLAG_C_UNIX) @@ -3654,7 +3656,8 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou if (sarif_converter && make->module && !make->external) { - const char *sast_name = strmake( "%s%s.sarif", source->arch ? "" : arch_dirs[arch], obj ); + const char *sast_name = strmake( "%s%s.sarif", + (source->file->flags & FLAG_GENERATED) && source->arch ? "" : arch_dirs[arch], obj ); output( "%s: %s\n", obj_dir_path( make, sast_name ), source->filename ); output( "\t%s%s -o $@ %s", cmd_prefix( "SAST" ), var_cc, source->filename ); output_filenames( defines ); @@ -4854,8 +4857,11 @@ static void load_sources( struct makefile *make ) list_init( &make->sources ); list_init( &make->includes ); - value = get_expanded_make_var_array( make, "SOURCES" ); - STRARRAY_FOR_EACH( file, &value ) add_src_file( make, file ); + for (arch = 0; arch < archs.count; arch++) + { + value = get_expanded_arch_var_array( make, "SOURCES", arch ); + STRARRAY_FOR_EACH( file, &value ) add_src_file( make, file, arch ); + } add_generated_sources( make ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10716