Re: [RFC:PATCH] Build system improvement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, here it is the second version of the build patch, fixing some small
stuff on the previous one. Please test. I should apply it tomorrow
nobody complains :)

Em Ter, 2006-06-20 às 12:23 -0300, Mauro Carvalho Chehab escreveu:
> Guys,
> 
> Since the old CVS days, the building system for V4L/DVB assumed that all
> required kernel dependencies were compiled. This is bad, since some
> obsoleted stuff might be required, without need (like, for example, OSS
> support for saa7134_oss, cx88_oss that were replaced by saa7134_alsa and
> cx88_alsa).
> 
> With the inclusion of radio devices, some very unusual modules were also
> required, to compile miropcm20 (the miro-pcm OSS mixer driver). 
> 
> The proposed patch adds the capability to the building system for it to
> check kernel's config.h and autoconf.h at kernel building tree,
> identifying all options used during kernel compilation time. Those
> options will now be reflected on Kconfig.kern and at make all building.
> 
> Please test and give us some feedback.
> 
> Cheers, 
> Mauro.
> --
> video4linux-list mailing list
> Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list
Cheers, 
Mauro.
diff -r be51c8e846b5 v4l/Makefile
--- a/v4l/Makefile	Tue Jun 20 15:07:47 2006 -0300
+++ b/v4l/Makefile	Tue Jun 20 15:21:28 2006 -0300
@@ -251,27 +251,27 @@ LXDIALOG := $(KDIR)/scripts/$(LXDIALOG_D
 LXDIALOG := $(KDIR)/scripts/$(LXDIALOG_DIR)lxdialog/lxdialog
 
 xconfig:: links .version $(QCONF)
-	./scripts/make_kconfig.pl
+	./scripts/make_kconfig.pl $(KDIR)
 	$(QCONF) Kconfig
 	./scripts/make_noconfig.pl
 
 gconfig:: links .version $(GCONF)
-	./scripts/make_kconfig.pl
+	./scripts/make_kconfig.pl $(KDIR)
 	$(QCONF) Kconfig
 	./scripts/make_noconfig.pl
 
 config:: links .version $(CONF)
-	./scripts/make_kconfig.pl
+	./scripts/make_kconfig.pl $(KDIR)
 	$(CONF) Kconfig
 	./scripts/make_noconfig.pl
 
 menuconfig:: links .version $(MCONF) lxdialog
-	./scripts/make_kconfig.pl
+	./scripts/make_kconfig.pl $(KDIR)
 	$(MCONF) Kconfig
 	./scripts/make_noconfig.pl
 
 allyesconfig allmodconfig:: links .version
-	./scripts/make_kconfig.pl 1
+	./scripts/make_kconfig.pl $(KDIR) 1
 	./scripts/make_noconfig.pl
 
 # rule to build kernel conf programs
diff -r be51c8e846b5 v4l/scripts/make_kconfig.pl
--- a/v4l/scripts/make_kconfig.pl	Tue Jun 20 15:07:47 2006 -0300
+++ b/v4l/scripts/make_kconfig.pl	Tue Jun 20 15:21:28 2006 -0300
@@ -7,9 +7,68 @@ my %intopt = ();
 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";
+	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($)
 {
@@ -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($)
-{
-	my $arg=shift;
+#################################################################
+# 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($$) {
@@ -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
@@ -225,6 +330,8 @@ sub parse_versions ()
 	}
 	close $in;
 }
+
+process_config("linux/config.h");
 
 parse_versions;
 
@@ -280,7 +387,12 @@ add_bool('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;
 
@@ -293,7 +405,21 @@ if (($force_kconfig eq 1) || !open IN,".
 	open OUT,">.config";
 	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 -r be51c8e846b5 v4l/versions.txt
--- a/v4l/versions.txt	Tue Jun 20 15:07:47 2006 -0300
+++ b/v4l/versions.txt	Tue Jun 20 15:21:28 2006 -0300
@@ -5,10 +5,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
@@ -22,6 +18,10 @@ USB_ZC0301
 USB_ZC0301
 VIDEO_ZORAN_AVS6EYES
 VIDEO_TLV320AIC23B
+
+# Those are architecture-dependent
+VIDEO_VINO
+VIDEO_M32R_AR_M64278
 
 [2.6.14]
 VIDEO_ZORAN
_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux