[linux-dvb] [PATCH] Fix kernel options overriding v4l-dvb Hg options

Trent Piepho xyzzy at speakeasy.org
Fri Jun 23 02:02:48 CEST 2006


The file config-compat.h contains the C #define version of all the config
options in .myconfig.  Except for options set to 'n', which don't appear at
all.  This is a problem if you turn on something like DVB_CINERGYT2_TUNING or
DVB_AV7110_FIRMWARE in the kernel, but turn it off for v4l-dvb.  The kernel's
setting from linux/include/autoconf.h will not get overriden by
config-compat.h, and the option will remain on.

The Makefile is changed to use an in-line perl script (make 3.81 safe!)
instead of a bunch of calls to sed and grep.

The new config-compat.h will be much more like the kernel's autoconf.h file
that it is supposed to be emulating.

Example .config / .myconfig options:
CONFIG_ONE=n
CONFIG_TWO=m
CONFIG_THREE=y

What kernel will output:
#undef CONFIG_ONE
#define CONFIG_TWO_MODULE 1
#define CONFIG_THREE 1

What used to go into config-compat.h:
#undef CONFIG_TWO
#define CONFIG_TWO m
#undef CONFIG_THREE
#undef CONFIG_THREE y

What will appear in config-compat.h now:
#undef CONFIG_ONE
#undef CONFIG_TWO
#define CONFIG_TWO_MODULE 1
#undef CONFIG_THREE
#define CONFIG_THREE 1

The extra undefs are for overriding the kernel.
-------------- next part --------------
# HG changeset patch
# User Trent Piepho <xyzzy at speakeasy.org>
# Node ID eecdd9d58b186242fec28cfde74ba985a50e6a96
# Parent  05618eba3c72de587bfdea9f39cd9ee7a81ab86c
Have config-compat.h, undefine options turned off

From: Trent Piepho <xyzzy at speakeasy.org>

Use a (make 3.81 safe!) in-line perl script to generate config-compat.h
from .myconfig.  The output will be more like the Kernel's output:

Options set to 'm' will define CONFIG_WHATEVER_MODULE to 1, rather than
define CONFIG_WHATEVER to m. 

Options set to 'y' to be defined to 1 instead of y.

Options that are off will be #undef'ed, rather that omitted, so that they
will override the settings from the kernel autoconf.h file. 

The last change will fix a problem where certain options, like CinergyT2
tuning and AV7110 firmware, wouldn't work properly if they were on in the
kernel but off for v4l-dvb Hg.

Signed-off-by: Trent Piepho <xyzzy at speakeasy.org>

diff -r 05618eba3c72 -r eecdd9d58b18 v4l/Makefile
--- a/v4l/Makefile	Thu Jun 22 16:24:02 2006 -0700
+++ b/v4l/Makefile	Thu Jun 22 16:59:16 2006 -0700
@@ -177,20 +177,19 @@ links::
 	@find ../linux/sound -name '*.[ch]' -type f -exec ln -sf '{}' . \;
 
 config-compat.h:: .myconfig
-	@echo \#ifndef __CONFIG_COMPAT_H__ > config-compat.h
-	@echo \#define __CONFIG_COMPAT_H__ >> config-compat.h
-	@echo >> config-compat.h
-	@echo \#include \<linux\/config\.h\> >> config-compat.h
-	@echo >> config-compat.h
-	@grep "CONFIG\_" .myconfig | grep -v "\:\= n" | \
-		sed s/"CONFIG\_"/"\#undef CONFIG\_"/1 | \
-		sed s/"\:\= .*"/""/1 >> config-compat.h >> config-compat.h
-	@echo >> config-compat.h
-	@grep "CONFIG\_" .myconfig | grep -v "\:\= n" | \
-		sed s/"CONFIG\_"/"\#define CONFIG\_"/1 | \
-		sed s/"\:\="/""/1 >> config-compat.h >> config-compat.h
-	@echo >> config-compat.h
-	@echo \#endif >> config-compat.h
+	@perl \
+	-e 'print "#ifndef __CONFIG_COMPAT_H__\n";' \
+	-e 'print "#define __CONFIG_COMPAT_H__\n\n";' \
+	-e 'print "#include <linux/config.h>\n\n";' \
+	-e 'while(<>) {'\
+	-e '    next unless /^(\S+)\s*:= (\S+)$$/;' \
+	-e '    print "#undef $$1\n";' \
+	-e '       if($$2 eq "n") { next; }' \
+	-e '    elsif($$2 eq "m") { print "#define $$1_MODULE 1\n"; }' \
+	-e '    elsif($$2 eq "y") { print "#define $$1 1\n"; }' \
+	-e '    else              { print "#define $$1 $$2\n"; }' \
+	-e '} print "\n#endif\n";' \
+		< .myconfig > config-compat.h
 
 kernel-links makelinks::
 	cd ..;	v4l/scripts/makelinks.sh $(KDIR)


More information about the linux-dvb mailing list