]> git.pld-linux.org Git - packages/kernel.git/blame - kernel-module-build.pl
mark arm* configs as sources
[packages/kernel.git] / kernel-module-build.pl
CommitLineData
2380c486
JR
1#!/usr/bin/perl
2#
3use strict;
4use warnings;
5use File::Find qw(find);
6
7my $rpmdir = shift @ARGV or die;
8my $fileoutdir = shift @ARGV or die;
2380c486 9
5e3474e7 10# files which match: */include/*/Kbuild
11my @modulebuild_in_include;
12# files which match: */Kbuild */Kconfig except include
13my @modulebuild;
14# parent dirs of Kconfig files which match */include*
15my @dirs_in_include;
16# parent dirs of Kconfig files except include
17my @dirs;
2380c486 18
5e3474e7 19sub push_dirs
20{
21 my $list = shift;
22 my $dir = shift;
23 my $subdir = "";
24 foreach my $sub ( split( '/', $dir )) {
25 $subdir .= "/" . $sub;
26 push @$list, "\%dir $rpmdir$subdir\n";
27 }
28}
29
30sub wanted
31{
2380c486
JR
32 return unless -f;
33 return unless /^Kconfig/ or /^Makefile/ or /^Kbuild/;
34 #return if /\.orig$/;
29564a2e 35 return if $File::Find::name =~ /Documentation/;
2380c486
JR
36 (my $file = $File::Find::name) =~ s#^\./##;
37 $file =~ m#^(.*)/#;
38 my $dir = $1 || "";
5e3474e7 39 if ( $dir =~ m{^(.*/)?include(/.*?)?$} ) {
40 push @modulebuild_in_include, "$rpmdir/$file\n";
41 push_dirs( \@dirs_in_include, $dir );
42 } else {
43 push @modulebuild, "$rpmdir/$file\n";
44 push_dirs( \@dirs, $dir );
45 }
46}
47
48find(\&wanted, ".");
49
50sub uniq
51{
52 my %hash = map { $_, 1 } @_;
53 return sort keys %hash;
54}
55
56sub remove
57{
58 my $from = shift;
59 my $what = shift;
60 my %hash = map { $_, 1 } @$from;
61 foreach ( @$what ) {
62 delete $hash{ $_ };
2380c486 63 }
5e3474e7 64 return sort keys %hash;
2380c486
JR
65}
66
5e3474e7 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
69open F_OUT, "> $fileoutdir/files.mb_include_modulebuild_and_dirs"
70 or die "Can't create files.mb_include_modulebuild_and_dirs: $!\n";
71print F_OUT remove( \@dirs, \@dirs_in_include );
72print F_OUT uniq( @modulebuild_in_include, @modulebuild );
73close F_OUT and print "files.mb_include_modulebuild_and_dirs created\n";
2380c486 74
5e3474e7 75# from source remove all files Kconfig, Makefile and Kbuild files
76# also remove all their parent dirs
77open F_OUT, "> $fileoutdir/files.source_exclude_modulebuild_and_dirs"
78 or die "Can't create files.source_exclude_modulebuild_and_dirs: $!\n";
79print F_OUT map {"\%exclude $_"} uniq( @modulebuild_in_include, @modulebuild,
80 @dirs_in_include, @dirs );
81close F_OUT and print "files.source_exclude_modulebuild_and_dirs created\n";
2380c486 82
5e3474e7 83# from headers remove all Kconfig, Makefile and Kbuild files that are
84# part of include directory
85open F_OUT, "> $fileoutdir/files.headers_exclude_kbuild"
86 or die "Can't create files.headers_exclude_kbuild: $!\n";
87print F_OUT map {"\%exclude $_"} uniq( @modulebuild_in_include );
88close F_OUT and print "files.headers_exclude_kbuild created\n";
This page took 0.40947 seconds and 4 git commands to generate.