5 use File::Find qw(find);
7 my $rpmdir = shift @ARGV or die;
8 my $fileoutdir = shift @ARGV or die;
10 # files which match: */include/*/Kbuild
11 my @modulebuild_in_include;
12 # files which match: */Kbuild */Kconfig except include
14 # parent dirs of Kconfig files which match */include*
16 # parent dirs of Kconfig files except include
24 foreach my $sub ( split( '/', $dir )) {
25 $subdir .= "/" . $sub;
26 push @$list, "\%dir $rpmdir$subdir\n";
33 return unless /^Kconfig/ or /^Makefile/ or /^Kbuild/;
35 return if $File::Find::name =~ /Documentation/;
36 (my $file = $File::Find::name) =~ s#^\./##;
39 if ( $dir =~ m{^(.*/)?include(/.*?)?$} ) {
40 push @modulebuild_in_include, "$rpmdir/$file\n";
41 push_dirs( \@dirs_in_include, $dir );
43 push @modulebuild, "$rpmdir/$file\n";
44 push_dirs( \@dirs, $dir );
52 my %hash = map { $_, 1 } @_;
53 return sort keys %hash;
60 my %hash = map { $_, 1 } @$from;
64 return sort keys %hash;
67 # to module-build add all Kconfig, Makefile and Kbuild files
68 # also add all their parent dirs if they aren't parents of some include directory
69 open F_OUT, "> $fileoutdir/files.mb_include_modulebuild_and_dirs"
70 or die "Can't create files.mb_include_modulebuild_and_dirs: $!\n";
71 print F_OUT remove( \@dirs, \@dirs_in_include );
72 print F_OUT uniq( @modulebuild_in_include, @modulebuild );
73 close F_OUT and print "files.mb_include_modulebuild_and_dirs created\n";
75 # from source remove all files Kconfig, Makefile and Kbuild files
76 # also remove all their parent dirs
77 open F_OUT, "> $fileoutdir/files.source_exclude_modulebuild_and_dirs"
78 or die "Can't create files.source_exclude_modulebuild_and_dirs: $!\n";
79 print F_OUT map {"\%exclude $_"} uniq( @modulebuild_in_include, @modulebuild,
80 @dirs_in_include, @dirs );
81 close F_OUT and print "files.source_exclude_modulebuild_and_dirs created\n";
83 # from headers remove all Kconfig, Makefile and Kbuild files that are
84 # part of include directory
85 open F_OUT, "> $fileoutdir/files.headers_exclude_kbuild"
86 or die "Can't create files.headers_exclude_kbuild: $!\n";
87 print F_OUT map {"\%exclude $_"} uniq( @modulebuild_in_include );
88 close F_OUT and print "files.headers_exclude_kbuild created\n";