summaryrefslogtreecommitdiff
path: root/v4l/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'v4l/scripts')
-rwxr-xr-xv4l/scripts/gentree.pl93
-rwxr-xr-xv4l/scripts/make_kconfig.pl178
-rwxr-xr-xv4l/scripts/make_makefile.pl163
-rwxr-xr-xv4l/scripts/make_noconfig.pl57
-rwxr-xr-xv4l/scripts/makelinks.sh2
5 files changed, 457 insertions, 36 deletions
diff --git a/v4l/scripts/gentree.pl b/v4l/scripts/gentree.pl
index 0ae296b93..e58d410c2 100755
--- a/v4l/scripts/gentree.pl
+++ b/v4l/scripts/gentree.pl
@@ -2,12 +2,10 @@
use strict;
use File::Find;
use Fcntl ':mode';
-use Cwd;
my $VER = shift;
my $SRC = shift;
my $DESTDIR = shift;
-my $cwd;
my $extra;
@@ -70,9 +68,9 @@ sub filter_source ($$) {
if ($line =~ m/^#include \"compat.h\"/) {
next;
}
- if ($line =~ m/[\$]Id:/) {
- next;
- }
+# if ($line =~ m/[\$]Id:/) {
+# next;
+# }
if ($line =~ /^#ifdef MM_KERNEL/) {
chomp($line);
$state{$level} = "if";
@@ -81,8 +79,20 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ /^\s*#if 0\s.*[Kk][Ee][Ee][Pp].*/) {
- print OUT "#if 0\n";
+ if ($line =~ /^#ifdef _COMPAT_H/) {
+ chomp($line);
+ $state{$level} = "if";
+ $if{$level} = 0;
+ print STDERR "/* BP #if MM_KERNEL state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
+ if ($line =~ m|^\s*\#if\s+0\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) {
+ if ($1 eq ";") {
+ print OUT "#if 0\n";
+ } else {
+ print OUT "#if 0$1\n";
+ }
chomp($line);
$state{$level} = "ifother";
$if{$level} = 0;
@@ -90,6 +100,30 @@ sub filter_source ($$) {
$level++;
next;
}
+ if ($line =~ /^#ifdef\sSTV0297_CS2/) {
+ chomp($line);
+ $state{$level} = "if";
+ $if{$level} = 0;
+ print STDERR "/* BP #if 0 state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
+ if ($line =~ /^#ifndef\sBROKEN_XAWTV/) {
+ chomp($line);
+ $state{$level} = "if";
+ $if{$level} = 1;
+ print STDERR "/* BP #if 0 state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
+ if ($line =~ /^#ifndef\sSTV0297_CS2/) {
+ chomp($line);
+ $state{$level} = "if";
+ $if{$level} = 1;
+ print STDERR "/* BP #if 1 state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
if ($line =~ /^#if 0/) {
chomp($line);
$state{$level} = "if";
@@ -98,8 +132,8 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ /^#if 1\s.*[Kk][Ee][Ee][Pp].*/) {
- print OUT "#if 1\n";
+ if ($line =~ m|^\s*\#if\s+1\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) {
+ print OUT "#if 1$1\n";
$state{$level} = "ifother";
$if{$level} = 1;
print STDERR "/* BP #if 1 (keep) state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
@@ -122,6 +156,14 @@ sub filter_source ($$) {
$level++;
next;
}
+ if ($line =~ /^#if.*CONFIG_XC3028/) {
+ chomp($line);
+ $state{$level} = "if";
+ $if{$level} = 0;
+ print STDERR "/* BP #if 1 state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
if ($line =~ /^#if.*I2C_CLASS_TV_ANALOG/) {
chomp($line);
$state{$level} = "if";
@@ -138,7 +180,15 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ /^#if.*I2C_CLASS_TV_DIGITAL/) {
+ if ($line =~ /^#ifndef.\s*I2C_PEC/) {
+ chomp($line);
+ $state{$level} = "if";
+ $if{$level} = 0;
+ print STDERR "/* BP #if 1 state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
+ if ($line =~ /^#ifdef.\s*I2C_PEC/) {
chomp($line);
$state{$level} = "if";
$if{$level} = 1;
@@ -146,14 +196,14 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ /^#if.*CONFIG_XC3028/) {
+ if ($line =~ /^#if.*I2C_CLASS_TV_DIGITAL/) {
chomp($line);
$state{$level} = "if";
- $if{$level} = 0;
- print STDERR "/* BP #if 1 state=$state{$level} if=$if{$level} level=$level$
+ $if{$level} = 1;
+ print STDERR "/* BP #if 1 state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
$level++;
next;
- }
+ }
if ($line =~ /^#if.*BTTV_VERSION_CODE/) {
chomp($line);
$line =~ s@^#if\s*@@;
@@ -280,9 +330,7 @@ sub parse_dir {
return;
}
- my $mode = (lstat("$cwd/$file"))[2];
-
-# printf "Permissions of %s/%s are %04o (dir=%s\n", $cwd,$file, $mode, cwd;
+ my $mode = (lstat("$file"))[2];
if ($mode & S_IFDIR) {
return;
@@ -291,14 +339,14 @@ sub parse_dir {
$srcdir =~ s/(.)/\[$1\]/g;
my $f2 = $file;
- $f2 =~ s,^$srcdir,$cwd/$DESTDIR/,;
+ $f2 =~ s,^$srcdir,$DESTDIR/,;
print "from $file to $f2\n";
my $tmp = "/tmp/src.$$";
if ($file =~ m/.*\.[ch]$/) {
- filter_source("$cwd/$file","$tmp");
+ filter_source("$file","$tmp");
} else {
- system("cp $cwd/$file $tmp");
+ system("cp $file $tmp");
}
my $dir = $f2;
@@ -315,12 +363,11 @@ sub parse_dir {
my $patchtmploc = "/tmp/temp.patch";
-printf STDERR <<EOF,$VER,$CODE;
+printf <<EOF,$VER,$CODE;
kernel is %s (0x%x)
EOF
-print STDERR "finding files at $SRC\n";
+print "finding files at $SRC\n";
-$cwd=cwd;
find(\&parse_dir, $SRC);
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl
index f612e83db..04430ccf2 100755
--- a/v4l/scripts/make_kconfig.pl
+++ b/v4l/scripts/make_kconfig.pl
@@ -1,37 +1,189 @@
#!/usr/bin/perl
use FileHandle;
-my $KDIR=shift;
-my $ARCH=shift;
+my %depend = ();
+my %minver = ();
+my %config = ();
+my %tristate = ();
+my $version, $level, $sublevel;
+
+my $force_kconfig=shift;
+
+sub add_bool($)
+{
+ my $arg=shift;
+
+ $tristate{$arg}="bool";
+# printf "Boolean:%s\n",$arg;
+}
+
+sub add_tristate($)
+{
+ my $arg=shift;
+
+ $tristate{$arg}="tristate";
+# printf "Tristate:%s\n",$arg;
+}
+
+sub add_config($)
+{
+ my $arg=shift;
+
+ if ($arg =~ m/^([A-Z0-9_]+)/) {
+ $config{$1} = 1;
+ }
+}
+
+sub check_deps($)
+{
+ my $arg=shift;
+ $arg=$arg." ";
+
+ while ($arg ne "") {
+ if ($arg =~ m/^([A-Z0-9_]+) /) {
+ my $val=$1;
+ my $prev=$depend{$val};
+ $depend { $val } = 1+$prev;
+ }
+ $arg =~ s/^[^ ]+ //;
+ }
+}
sub open_kconfig($$) {
my ($dir,$file)=@_;
my $in = new FileHandle;
+ my $skip=0;
+ my $key;
-print "opening $file\n";
+#print "opening $file\n";
open $in,"$file";
while (<$in>) {
- if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) {
- next;
- }
+# if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) {
+# next;
+# }
if (m|^\s*source[\s\"]+([^\n\s\"]+)[\n\s\"]|) {
open_kconfig($dir,"$dir/$1");
next;
}
+ if (m|^\s+depends on (.*)\n|) {
+ check_deps ($1);
+ }
+ if (m|^\s+select (.*)\n|) {
+ check_deps ($1);
+ }
+ if (m|^\s*bool\s+|) {
+ add_bool($key);
+ }
+ if (m|^\s*tristate\s+|) {
+ add_tristate($key);
+ }
+ if (m|^\s*config (.*)\n|) {
+ $key=$1;
+ add_config ($1);
+
+ my $min=$minver { $key };
+ my $minversion, $minlevel, $minsublevel;
+ if ($min =~ m/(\d+)\.(\d+)\.(\d+)/) {
+ $minversion=$1;
+ $minlevel=$2;
+ $minsublevel=$3;
+ } else {
+ die "Minimum version for $key not found at versions.txt";
+ }
+ if ( ($version < $minversion) |
+ ($level < $minlevel) |
+ ($sublevel < $minsublevel) ) {
+ $skip=1;
+ printf "$key requires version $minversion.$minlevel.$minsublevel\n";
+
+ print OUT "# $key disabled due to incorrect version\nconfig $key\n\ttristate\n\tdefault n\n\n";
+ next;
+ } else {
+# printf "OK: $key requires version $minversion.$minlevel.$minsublevel\n";
+ $skip=0;
+ }
+ }
+
s/^main(menu\s\"[^\"]+)/\1 - DON'T CHANGE IT!/;
- print OUT $_;
+ if (m/^[\w]/) {
+ $skip=0;
+ }
+ if (!$skip) {
+ print OUT $_;
+ }
}
close $in;
}
-open OUT,">Kconfig.kern";
-open_kconfig($KDIR,"$KDIR/arch/$ARCH/Kconfig");
-print OUT "endmenu\n";
-close OUT;
+sub parse_versions ()
+{
+ my $in = new FileHandle;
+ my $ver;
+
+ open $in,"versions.txt";
+ while (<$in>) {
+ if (m/\[([\d.]*)\]/) {
+ $ver=$1;
+ next;
+ }
+ s/\n//;
+ if (m/^\s*([\w\d_]+)/) {
+ $minver { $1 } = $ver;
+# printf ("%s=%s\n",$1,$ver);
+ }
+ }
+ close $in;
+}
+
+parse_versions;
+
+open IN,".version";
+while (<IN>) {
+ if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) {
+ $version=$1;
+ $level=$2;
+ $sublevel=$3;
+ }
+}
+close IN;
+
+printf "Preparing to compile for kernel version %d.%d.%d\n",$version,$level,$sublevel;
open OUT,">Kconfig";
print OUT "mainmenu \"V4L/DVB menu\"\n";
-open_kconfig ("../linux","../linux/drivers/media/video/Kconfig");
-open_kconfig ("../linux","../linux/drivers/media/dvb/Kconfig");
+
print OUT "source Kconfig.kern\n";
+open_kconfig ("../linux","../linux/drivers/media/Kconfig");
+close OUT;
+
+while ( my ($key, $value) = each(%config) ) {
+ delete $depend{$key};
+}
+
+open OUT,">Kconfig.kern";
+
+print OUT "config MODULES\n\tboolean\n\tdefault y\n\n";
+$tristate{"MODULES"}="bool";
+
+while ( my ($key, $value) = each(%depend) ) {
+ print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n";
+}
close OUT;
+
+if (($force_kconfig eq 1) || !open IN,".config") {
+ open OUT,">.config";
+ while ( my ($key,$value) = each(%tristate) ) {
+
+ if ( ($key eq "DVB_AV7110_FIRMWARE") ||
+ ($key eq "DVB_CINERGYT2_TUNING") ) {
+ printf OUT "CONFIG_%s=n\n",$key;
+ } else {
+ if ($value eq "tristate") {
+ printf OUT "CONFIG_%s=m\n",$key;
+ } else {
+ printf OUT "CONFIG_%s=y\n",$key;
+ }
+ }
+ }
+ close OUT;
+}
diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl
new file mode 100755
index 000000000..238c5082f
--- /dev/null
+++ b/v4l/scripts/make_makefile.pl
@@ -0,0 +1,163 @@
+#!/usr/bin/perl
+use FileHandle;
+
+my $instdir = ();
+
+sub check_line($$$)
+{
+ my $dir=shift;
+ my $obj=shift;
+ my $arg=shift;
+ my $arg2="";
+
+ my $idir = $dir;
+
+ $idir =~ s|^../linux/drivers/media/||;
+
+ $arg=$arg." ";
+
+ while ($arg ne "") {
+ if ($arg =~ m|^([^ /]+)/ |) {
+ my $newdir=$1;
+# print "include $dir/$newdir/Makefile\n";
+ open_makefile("$dir/$newdir/Makefile");
+ $arg =~ s/^[^ ]+ //;
+ } else {
+ $arg =~ s/^([^ ]+ )//;
+ my $cur=$1;
+ $arg2 = $arg2.$cur;
+
+ $cur =~ s/\s+$//;
+ $cur =~ s/\\$//;
+ $cur =~ s/\s+$//;
+ $cur =~ s/\.o$/.ko/;
+
+ if ( ($cur ne "") && (! ($instdir { $idir } =~ m/($cur) /))) {
+ $instdir { $idir } = $instdir { $idir }.$cur." ";
+ }
+ }
+ }
+ $arg2 =~ s/\s+$//;
+ if ($arg2 ne "") {
+# print "arg=$arg2\n";
+ print OUT "$obj$arg2\n";
+ }
+}
+
+sub remove_includes($$)
+{
+ my $obj=shift;
+ my $arg=shift;
+ my $arg2="";
+
+ $arg=$arg." ";
+
+ while ($arg ne "") {
+ if (!$arg =~ m|^(-I\s*[^ ]+) |) {
+ $arg2 = $arg2.$1;
+ $arg =~ s|^[^ ] ||;
+ } else {
+ $arg =~ s|^(-I\s*[^ ]+) ||;
+ }
+ }
+ if ($arg2 ne "") {
+ print OUT "$obj$arg2\n";
+ }
+}
+
+sub open_makefile($) {
+ my $file= shift;
+ my $in = new FileHandle;
+ my $dir= "";
+ my $count=0;
+
+ $file=~ m|^(.*)/[^/]*$|;
+ $dir=$1;
+
+#print "opening $file (dir=$dir)\n";
+ open $in,"$file";
+
+ while (<$in>) {
+ if (m|\s*#|) {
+ print OUT $_;
+ next;
+ }
+ if (m|^\s*include|) {
+ next;
+ }
+ if (count==1 || m|(^\s*EXTRA_CFLAGS.*=\s*)(.*/.*)\n|) {
+ remove_includes($1,$2);
+ if (m|[\\]\n|) {
+ $count=1;
+ } else {
+ $count=0;
+ }
+ next;
+ }
+# if (m|(^\s*obj.*=\s*)(.*/.*)\n|) {
+ if (count==2 || m|(^\s*obj.*=\s*)(.*)\n|) {
+ check_line($dir,$1,$2);
+ if (m|\\\n|) {
+ $count=1;
+ } else {
+ $count=0;
+ }
+ next;
+ }
+ print OUT $_;
+ }
+ close $in;
+}
+
+open OUT,">Makefile.media";
+open_makefile ("../linux/drivers/media/Makefile");
+
+# Creating Install rule
+printf OUT "media-install::\n";
+printf OUT "\t\@echo \"Stripping debug info from files:\"\n";
+printf OUT "\t\@strip --strip-debug \$(inst-m)\n\n";
+
+while ( my ($key, $value) = each(%instdir) ) {
+ printf OUT "\t\@echo -e \"\\nInstalling \$(KDIR26)/$key files:\"\n";
+ printf OUT "\t\@install -d \$(KDIR26)/$key\n";
+
+ printf OUT "\t\@files='$value'; ";
+ printf OUT "for i in \$\$files;do if [ -e \$\$i ]; then echo -n \"\$\$i \";";
+ printf OUT " install -m 644 -c \$\$i \$(KDIR26)/$key; fi; done; echo;\n\n";
+}
+printf OUT "\t/sbin/depmod -a \${KERNELRELEASE}\n\n";
+
+# Creating Remove rule
+printf OUT "media-rminstall::\n";
+printf OUT "\t\@echo -e \"\\nRemoving old \$(DEST) files\\n\"\n";
+
+while ( my ($key, $value) = each(%instdir) ) {
+ printf OUT "\t\@echo -e \"\\nRemoving old \$(KDIR26)/$key files:\"\n";
+ printf OUT "\t\@files='$value'; ";
+
+ printf OUT "for i in \$\$files;do if [ -e \$(KDIR26)/$key/\$\$i ]; then ";
+ printf OUT "echo -n \"\$\$i \";";
+ printf OUT " rm \$(KDIR26)/$key/\$\$i; fi; done; ";
+
+ printf OUT "for i in \$\$files;do if [ -e \$(KDIR26)/$key/\$\$i.gz ]; then ";
+ printf OUT "echo -n \"\$\$i.gz \";";
+ printf OUT " rm \$(KDIR26)/$key/\$\$i.gz; fi; done; echo;\n\n";
+}
+
+close OUT;
+
+while ( my ($key, $value) = each(%config) ) {
+ delete $depend{$key};
+}
+
+open OUT,">Kconfig.kern";
+while ( my ($key, $value) = each(%depend) ) {
+ print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n";
+}
+close OUT;
+
+if (open OUT,".myconfig") {
+ close IN;
+} else {
+ system "make allmodconfig";
+}
diff --git a/v4l/scripts/make_noconfig.pl b/v4l/scripts/make_noconfig.pl
new file mode 100755
index 000000000..a81e157e2
--- /dev/null
+++ b/v4l/scripts/make_noconfig.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+my $config = ();
+
+open IN,".config";
+while (<IN>) {
+ if (m/\s*([\d\w_]+)[=](.*)\n/) {
+#printf "%s=%s\n",$1,$2;
+ $config { $1 } = $2;
+ }
+}
+close IN;
+
+open IN,".version";
+while (<IN>) {
+ if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) {
+ $version=$1;
+ $level=$2;
+ $sublevel=$3;
+ }
+}
+close IN;
+
+open IN,"versions.txt";
+while (<IN>) {
+ if (m/\[(\d+)\.(\d+)\.(\d+)\]/) {
+ $minversion=$1;
+ $minlevel=$2;
+ $minsublevel=$3;
+ next;
+ }
+ s/\n//;
+
+ if (m/DVB_AV7110_FIRMWARE_FILE/) {
+ next;
+ }
+ if (m/^\s*([\w\d_]+)/) {
+ if ( ($version < $minversion) |
+ ($level < $minlevel) |
+ ($sublevel < $minsublevel) ) {
+ $config { "CONFIG_$1" } = 'n';
+#print "CONFIG_$1 version is not supported\n";
+ next;
+ }
+ if (!($config { "CONFIG_$1" } ) ) {
+print "CONFIG_$1 is unset\n";
+ $config { "CONFIG_$1" } = 'n';
+ }
+ }
+}
+close IN;
+
+open OUT,">.myconfig";
+while ( my ($key, $value) = each(%config) ) {
+ printf OUT "%-44s := %s\n",$key,$value;
+}
+close OUT;
diff --git a/v4l/scripts/makelinks.sh b/v4l/scripts/makelinks.sh
index a66989771..03fd48849 100755
--- a/v4l/scripts/makelinks.sh
+++ b/v4l/scripts/makelinks.sh
@@ -39,10 +39,12 @@ done
for x in `find include -type d | grep -v CVS` ; do
ln -f -s $PWD/../v4l/compat.h $1/$x/compat.h
+ touch $1/$x/config-compat.h
done
for x in `find drivers/media -type d | grep -v CVS` ; do
ln -f -s $PWD/../v4l/compat.h $1/$x/compat.h
+ touch $1/$x/config-compat.h
done
cd ..