summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-06-21 12:23:13 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-21 12:23:13 -0300
commit6cfc8eeff6261fb1153a67e5bc3c71616f332044 (patch)
treec707071b09c935d5a5761bb8ba5b470fdd1bb67d
parent8ed7b8223378e40620c98d03d8ab2102dfab33a0 (diff)
downloadmediapointer-dvb-s2-6cfc8eeff6261fb1153a67e5bc3c71616f332044.tar.gz
mediapointer-dvb-s2-6cfc8eeff6261fb1153a67e5bc3c71616f332044.tar.bz2
Some improvements at the building system
From: Mauro Carvalho Chehab <mchehab@infradead.org> Building system now looks kernel config.h and autoconf.h files, seeking for the compiled options at kernel. If something is missing, it will disable compilation for that driver, printing a warning message. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--v4l/Makefile33
-rwxr-xr-xv4l/scripts/make_kconfig.pl152
-rwxr-xr-xv4l/scripts/make_makefile.pl3
-rw-r--r--v4l/versions.txt8
4 files changed, 162 insertions, 34 deletions
diff --git a/v4l/Makefile b/v4l/Makefile
index 58354a035..881329d7d 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -17,7 +17,12 @@ else
ifneq ($(SRCDIR),)
KDIR := $(SRCDIR)
else
+ifneq ($(KERNELRELEASE),)
KDIR := /lib/modules/$(KERNELRELEASE)/build
+else
+KDIR := /lib/modules/$(shell uname -r|perl -ne 'if (/^([0-9]*)\.([0-9])*\.([0-9]*)(.*)$$/) { printf ("%s.%s.%s%s\n",$$1,$$2,$$3,$$4); };')/build
+
+endif
endif
endif
@@ -133,9 +138,6 @@ remove rminstall:: media-rminstall ivtv-rminstall
#################################################
# Compiling preparation rules
-Makefile.media:: .version
- scripts/make_makefile.pl
-
.version::
ifneq ($(KERNELRELEASE),)
@echo -e VERSION=$(VERSION)\\nPATCHLEVEL:=$(PATCHLEVEL)\\nSUBLEVEL:=$(SUBLEVEL)\\nKERNELRELEASE:=$(KERNELRELEASE) > $(obj)/.version
@@ -147,6 +149,9 @@ else
@uname -r|perl -ne 'if (/^([0-9]*)\.([0-9])*\.([0-9]*)(.*)$$/) { printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",$$1,$$2,$$3,$$1,$$2,$$3,$$4); };' > $(obj)/.version
endif
+Makefile.media:: .version
+ scripts/make_makefile.pl $(KDIR)
+
release::
ifneq ($(VER),)
@echo "Forcing compiling to version $(VER)."
@@ -180,9 +185,7 @@ links::
@find ../linux/drivers/media -name '*.[ch]' -type f -exec ln -sf '{}' . \;
@find ../linux/sound -name '*.[ch]' -type f -exec ln -sf '{}' . \;
-config-compat.h::
- scripts/make_myconfig.pl
-
+config-compat.h:: .myconfig
@echo \#ifndef __CONFIG_COMPAT_H__ > config-compat.h
@echo \#define __CONFIG_COMPAT_H__ >> config-compat.h
@echo >> config-compat.h
@@ -253,29 +256,27 @@ LXDIALOG_DIR := $(shell if [ -d $(KDIR)/scripts/kconfig/lxdialog ]; then echo kc
LXDIALOG_LNK := $(if $(LXDIALOG_DIR),scripts/kconfig,scripts/lxdialog)
LXDIALOG := $(KDIR)/scripts/$(LXDIALOG_DIR)lxdialog/lxdialog
+.myconfig : .config
+ ./scripts/make_myconfig.pl
+
xconfig:: links .version $(QCONF)
- ./scripts/make_kconfig.pl
+ ./scripts/make_kconfig.pl $(KDIR)
$(QCONF) Kconfig
- ./scripts/make_myconfig.pl
gconfig:: links .version $(GCONF)
- ./scripts/make_kconfig.pl
+ ./scripts/make_kconfig.pl $(KDIR)
$(QCONF) Kconfig
- ./scripts/make_myconfig.pl
config:: links .version $(CONF)
- ./scripts/make_kconfig.pl
+ ./scripts/make_kconfig.pl $(KDIR)
$(CONF) Kconfig
- ./scripts/make_myconfig.pl
menuconfig:: links .version $(MCONF) lxdialog
- ./scripts/make_kconfig.pl
+ ./scripts/make_kconfig.pl $(KDIR)
$(MCONF) Kconfig
- ./scripts/make_myconfig.pl
allyesconfig allmodconfig:: links .version
- ./scripts/make_kconfig.pl 1
- ./scripts/make_myconfig.pl
+ ./scripts/make_kconfig.pl $(KDIR) 1
# rule to build kernel conf programs
KMAKEVARS := config-targets=1 mixed-targets=0 dot-config=0
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl
index b499fefa1..33a53d772 100755
--- a/v4l/scripts/make_kconfig.pl
+++ b/v4l/scripts/make_kconfig.pl
@@ -7,10 +7,69 @@ my %config = ();
my %intopt = ();
my %hexopt = ();
my %tristate = ();
+my %kernopts = ();
+my %depmods = ();
my $version, $level, $sublevel;
+my $kernel=shift;
my $force_kconfig=shift;
+#!/usr/bin/perl
+use FileHandle;
+
+###########################################################
+# Checks config.h and autoconf.h for current kernel defines
+sub process_config ($)
+{
+ my $filename = shift;
+ my $in = new FileHandle;
+
+ open $in,"$kernel/include/$filename" or die;
+ while (<$in>) {
+ if (m|\#include\s+\<(.*)\>|) {
+ process_config ($1);
+ next;
+ }
+ if (m/\#define\s+CONFIG_([^ ]*)_ON_SMP\s+(.*)\n/) {
+ my $key=$1;
+ my $value=$2;
+# printf "defined $key as $value\n";
+ if ( $value == 1 ) {
+ $value='y';
+ }
+ $kernopts{$key}=$value;
+ next;
+ }
+ if (m/\#define\s+CONFIG_([^ ]*)_MODULE\s+(.*)\n/) {
+ my $key=$1;
+ my $value=$2;
+# printf "defined $key as $value\n";
+ if ( $value == 1 ) {
+ $value='m';
+ }
+ $kernopts{$key}=$value;
+ next;
+ }
+ if (m/\#define\s+CONFIG_([^ ]*)\s+(.*)\n/) {
+ my $key=$1;
+ my $value=$2;
+# printf "defined $key as $value\n";
+ if ( $value == 1 ) {
+ $value='y';
+ }
+ $kernopts{$key}=$value;
+ next;
+ }
+ if (m/\#undef\s+CONFIG_([^ ]*)\n/) {
+# printf "undefined $1\n";
+ $kernopts{$1}='n';
+ next;
+ }
+ }
+
+ close $in;
+}
+
sub add_bool($)
{
my $arg=shift;
@@ -18,6 +77,8 @@ sub add_bool($)
exists $config{$arg} or die "Adding unknown boolean '$arg'";
$tristate{$arg}="bool";
# printf "Boolean:%s\n",$arg;
+
+ $kernopts{$arg}='y';
}
sub add_tristate($)
@@ -26,7 +87,8 @@ sub add_tristate($)
exists $config{$arg} or die "Adding unknown tristate '$arg'";
$tristate{$arg}="tristate";
-# printf "Tristate:%s\n",$arg;
+
+ $kernopts{$arg}='m';
}
sub add_int($)
@@ -75,6 +137,7 @@ sub add_config($)
}
}
+########################################
# Turn option off, iff it already exists
sub disable_config($)
{
@@ -83,9 +146,14 @@ sub disable_config($)
$config{$key} = 0 if (exists $config{$key});
}
-sub check_deps($)
+#################################################################
+# Make a list of dependencies and the number of references for it
+sub check_deps($$)
{
+ my $key=shift;
my $arg=shift;
+
+ $depmods{$key}=$arg;
$arg=$arg." ";
while ($arg ne "") {
@@ -96,6 +164,44 @@ sub check_deps($)
}
$arg =~ s/^[^ ]+ //;
}
+
+ return $ok;
+}
+
+######################################################
+# Checks if all dependencies for the key are satisfied
+sub deps_ok($)
+{
+ my $key=shift;
+ my $arg=$depmods{$key};
+ my $ok=1;
+
+ if ($arg eq "") {
+ return $ok;
+ }
+
+ $arg=$arg." ";
+
+
+# printf "$key: deps are '$arg'\n";
+
+ while ($arg ne "") {
+ if ($arg =~ m/^([A-Z0-9_]+) /) {
+ if ((! exists $kernopts {$1}) || ($kernopts {$1} eq 'n')) {
+ printf "$key: Required kernel opt '$1' is not present\n";
+ $ok=0;
+ }
+ }
+ if ($arg =~ m/^\!([A-Z0-9_]+) /) {
+ if ($kernopts {$1} eq 'y') {
+ printf "$key: Driver is incompatible with '$1'\n";
+ $ok=0;
+ }
+ }
+ $arg =~ s/^[^ ]+ //;
+ }
+
+ return $ok;
}
sub open_kconfig($$) {
@@ -105,7 +211,7 @@ sub open_kconfig($$) {
my $key;
#print "opening $file\n";
- open $in,"$file";
+ open $in,"$file" or die;
while (<$in>) {
# if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) {
# next;
@@ -124,10 +230,10 @@ sub open_kconfig($$) {
next;
}
if (m|^\s+depends on\s+(.*)\n|) {
- check_deps ($1);
+ check_deps ($key,$1);
}
if (m|^\s+select\s+(.*)\n|) {
- check_deps ($1);
+ check_deps ($key,$1);
}
if (m|^\s+bool(ean)?\s|) {
add_bool($key);
@@ -155,7 +261,6 @@ sub open_kconfig($$) {
$default_seen = 1;
$_ = "\tdefault n\n";
}
-
# check for end of config definition for disabled drivers
# we need to make sure we've disabled it, and add a bit
# to the help text
@@ -211,7 +316,7 @@ sub parse_versions ()
my $in = new FileHandle;
my $ver;
- open $in,"versions.txt";
+ open $in,"versions.txt" or die;
while (<$in>) {
if (m/\[([\d.]*)\]/) {
$ver=$1;
@@ -226,9 +331,11 @@ sub parse_versions ()
close $in;
}
+process_config("linux/config.h");
+
parse_versions;
-open IN,".version";
+open IN,".version" or die;
while (<IN>) {
if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) {
$version=$1;
@@ -240,7 +347,7 @@ close IN;
printf "Preparing to compile for kernel version %d.%d.%d\n",$version,$level,$sublevel;
-open OUT,">Kconfig";
+open OUT,">Kconfig" or die;
print OUT <<"EOF";
mainmenu "V4L/DVB menu"
@@ -273,14 +380,19 @@ while ( my ($key, $value) = each(%config) ) {
delete $depend{$key};
}
-open OUT,">Kconfig.kern";
+open OUT,">Kconfig.kern" or die;
print OUT "config MODULES\n\tboolean\n\tdefault y\n\n";
add_config('MODULES');
add_bool('MODULES');
while ( my ($key, $value) = each(%depend) ) {
- print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n";
+ if ($kernopts{$key}) {
+ print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault ".
+ $kernopts{$key}."\n\n";
+ } else {
+ print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault n #not found\n\n";
+ }
}
close OUT;
@@ -290,10 +402,24 @@ disable_config('DVB_CINERGYT2_TUNING');
# Produce a .config file if it's forced or one doesn't already exist
if (($force_kconfig eq 1) || !open IN,".config") {
- open OUT,">.config";
+ open OUT,">.config" or die;
while ( my ($key,$value) = each(%tristate) ) {
if (!$config{$key}) {
- print OUT "CONFIG_$key=n\n";
+ print OUT "# CONFIG_$key is not set\n";
+ } elsif ($kernopts{$key}) {
+ my $ok=deps_ok($key);
+
+ # If deps are not ok, mark default as n
+ if (!$ok) {
+# print "$key disabled due to missing kernel required prereq\n";
+ $kernopts{$key}='n';
+ }
+
+ if ($kernopts{$key} eq 'n') {
+ print OUT "# CONFIG_$key is not set\n";
+ } else {
+ print OUT "CONFIG_$key=".$kernopts{$key}."\n";
+ }
} elsif ($value eq 'tristate') {
print OUT "CONFIG_$key=m\n";
} else { # must be 'bool'
diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl
index f0d9aef7f..e0a099e9b 100755
--- a/v4l/scripts/make_makefile.pl
+++ b/v4l/scripts/make_makefile.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl
use FileHandle;
+my $kernel=shift;
my $instdir = ();
sub check_line($$$)
@@ -181,5 +182,5 @@ if (open IN,"Makefile.media") {
if (open IN,".myconfig") {
close IN;
} else {
- system "./scripts/make_kconfig.pl 1";
+ system "./scripts/make_kconfig.pl $kernel 1";
}
diff --git a/v4l/versions.txt b/v4l/versions.txt
index 35cb44fc6..6da410612 100644
--- a/v4l/versions.txt
+++ b/v4l/versions.txt
@@ -6,10 +6,6 @@ VIDEO_ZR36120
# This is also marked as broken
VIDEO_PLANB
-# Those are architecture-dependent
-VIDEO_VINO
-VIDEO_M32R_AR_M64278
-
[2.6.16]
VIDEO_USBVIDEO
USB_VICAM
@@ -23,6 +19,10 @@ USB_ZC0301
VIDEO_ZORAN_AVS6EYES
VIDEO_TLV320AIC23B
+# Those are architecture-dependent
+VIDEO_VINO
+VIDEO_M32R_AR_M64278
+
[2.6.14]
VIDEO_ZORAN
VIDEO_ZORAN_BUZ