[PATCH] New system for build kernel's config programs

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

 



The current system for calling a kernel Makefile to build the kernel config
programs doesn't work correctly.  The programs aren't built with the same
commands and options as they are when built by the kernel.  In some case they
will still build and run.  In other cases, like building mconf on 2.6.12, they
simply won't build at all.  They also will not build with a pristine kernel, as
certain kernel helper programs like "fixdep" need to be built first.

This patch impliments a completely different way to build these programs.  A
new makefile is used, Makefile.kernel, which includes the top-level kernel
Makefile.  New "v4l-*" targets are added which just build the kernel conf
programs.  This way the conf programs are built in the same manner as when the
kernel builds them.  In effect, we have patched the kernel's top-level
Makefile to include new targets to just build the config programs without
configuring the kernel.

Trying to build lxdialog needs write access to the kernel source tree, even if
lxdialog is already built and won't be re-built.  To avoid this and
unnecessary sub-makes, the kernel conf programs are added as dependencies to
the v4l Makefile's *config targets.  The rules to build them use the new
Makefile.kernel.  This way Makefile.kernel is never called unless the needed
kernel conf program doesn't already exist.

I have tested this with kernels 2.6.12 and 2.6.16.11 and both work perfectly.
With write access, everything that needs to be built will be built, starting
from either a pristine kernel or from a kernel with some components already
built.  The compilation will take place exactly how the kernel would have done
it.  Without write access, everything will work fine as long as the necessary
kernel programs have already been compiled.
# HG changeset patch
# User Trent Piepho <xyzzy@xxxxxxxxxxxxx>
# Node ID b60d5192e59c4503b4c9346ae6d9cf5e96c4eca6
# Parent  13622c93e20a7756540ae6b2ef2f4ab6e3b05074
New system for building kernel's config programs

From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>

Since we now use the kernel's config system, we need certain kernel binaries
like qconf, mconf, lxdialog to run the config targets.  The kernel's Makefile
is not kind enough to give us a target to just build these programs.  What
this patch does is introduce a new makefile, Makefile.kernel, which includes
the kernel's top-level Makefile.  Then adds some new "v4l-*" targets which
just build the kernel config programs.

The main v4l Makefile is patched to add the necessary kernel conf programs as
dependencies to their respective config targets.  Rules to build the kernel
conf programs are added which invoke a sub-make with the new Makefile.kernel. 
These rules are only invoked when the kernel conf programs needed don't yet
exist.  If they already exist, no write access to the kernel source tree is
needed.

Signed-off-by: Trent Piepho <xyzzy@xxxxxxxxxxxxx>

diff -r 13622c93e20a -r b60d5192e59c v4l/Makefile
--- a/v4l/Makefile	Wed Apr 26 18:08:40 2006 -0300
+++ b/v4l/Makefile	Thu Apr 27 18:04:29 2006 -0700
@@ -182,66 +182,55 @@ reload::
 #################################################
 # Configuration rules
 
-# SHELL used by kbuild
-CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-          else if [ -x /bin/bash ]; then echo /bin/bash; \
-          else echo sh; fi ; fi)
-
-build := srctree=$(KDIR) HOSTCXX="$(CXX)" HOSTCC="$(HOSTCC)" CONFIG_SHELL="$(CONFIG_SHELL)" -f $(KDIR)/scripts/Makefile.build obj
-
-xconfig:: links .version
-	-if [ ! -f $(KDIR)/scripts/kconfig/qconf ]; then \
-		$(MAKE) -C $(KDIR) $(build)=scripts/kconfig qconf-target=1 scripts/kconfig/qconf; \
-	fi
-	./scripts/make_kconfig.pl
-	$(KDIR)/scripts/kconfig/qconf Kconfig
-	./scripts/make_noconfig.pl
-
-gconfig:: links .version
-	-if [ ! -f $(KDIR)/scripts/kconfig/gconf ]; then \
-		$(MAKE) -C $(KDIR) $(build)=scripts/kconfig scripts/kconfig/gconf; \
-	fi
-	./scripts/make_kconfig.pl
-	$(KDIR)/scripts/kconfig/gconf Kconfig
-	./scripts/make_noconfig.pl
-
-config:: links .version
-	-if [ ! -f $(KDIR)/scripts/kconfig/conf ]; then \
-		$(MAKE) -C $(KDIR) $(build)=scripts/kconfig scripts/kconfig/conf; \
-	fi
-	./scripts/make_kconfig.pl
-	$(KDIR)/scripts/kconfig/conf Kconfig
-	./scripts/make_noconfig.pl
-
-menuconfig:: links .version
-	./scripts/make_kconfig.pl
-	-rm scripts/lxdialog scripts/kconfig
-	-if [ -d $(KDIR)/scripts/lxdialog ]; then \
-		if [ ! -f $(KDIR)/scripts/lxdialog/lxdialog ]; then \
-			$(MAKE) -C $(KDIR) $(build)=scripts/lxdialog; \
-		fi; \
-		ln -s $(KDIR)/scripts/lxdialog scripts/lxdialog; \
-	fi
-
-	-if [ -d $(KDIR)/scripts/kconfig ]; then \
-		if [  -d $(KDIR)/scripts/kconfig/lxdialog ]; then \
-			if [ ! -f $(KDIR)/scripts/kconfig/lxdialog ]; then \
-				$(MAKE) -C $(KDIR) $(build)=scripts/kconfig/lxdialog; \
-			fi; \
-		else \
-			if [ ! -f $(KDIR)/scripts/kconfig/mconf ]; then \
-				$(MAKE) -C $(KDIR) $(build)=scripts/kconfig scripts/kconfig/mconf; \
-			fi; \
-		fi; \
-		ln -s $(KDIR)/scripts/kconfig scripts/kconfig; \
-	fi
-
-	$(KDIR)/scripts/kconfig/mconf Kconfig
+# Kernel config programs
+QCONF := $(KDIR)/scripts/kconfig/qconf
+GCONF := $(KDIR)/scripts/kconfig/gconf
+MCONF := $(KDIR)/scripts/kconfig/mconf
+CONF := $(KDIR)/scripts/kconfig/conf
+
+# lxdialog can be in either scripts/lxdialog or scripts/kconfig/lxdialog
+LXDIALOG_DIR := $(shell if [ -d $(KDIR)/scripts/kconfig/lxdialog ]; then echo kconfig/ ; fi)
+LXDIALOG_LNK := $(if $(LXDIALOG_DIR),scripts/kconfig,scripts/lxdialog)
+LXDIALOG := $(KDIR)/scripts/$(LXDIALOG_DIR)lxdialog/lxdialog
+
+xconfig:: links .version $(QCONF)
+	./scripts/make_kconfig.pl
+	$(QCONF) Kconfig
+	./scripts/make_noconfig.pl
+
+gconfig:: links .version $(GCONF)
+	./scripts/make_kconfig.pl
+	$(QCONF) Kconfig
+	./scripts/make_noconfig.pl
+
+config:: links .version $(CONF)
+	./scripts/make_kconfig.pl
+	$(CONF) Kconfig
+	./scripts/make_noconfig.pl
+
+menuconfig:: links .version $(MCONF) lxdialog
+	./scripts/make_kconfig.pl
+	$(MCONF) Kconfig
 	./scripts/make_noconfig.pl
 
 allyesconfig allmodconfig:: links .version
 	./scripts/make_kconfig.pl 1
 	./scripts/make_noconfig.pl
+
+# rule to build kernel conf programs
+KMAKEVARS := config-targets=1 mixed-targets=0 dot-config=0
+$(QCONF) $(GCONF) $(MCONF) $(CONF):
+	$(MAKE) -C $(KDIR) -f $(PWD)/Makefile.kernel $(KMAKEVARS) v4l-$(notdir $@)
+
+# lxdialog has two parts, a symlink and the actual binary
+.PHONY: lxdialog
+lxdialog: $(LXDIALOG) $(LXDIALOG_LNK)
+
+$(LXDIALOG_LNK):
+	ln -snf $(KDIR)/$(LXDIALOG_LNK) $(LXDIALOG_LNK)
+
+$(LXDIALOG):
+	$(MAKE) -C $(KDIR) -f $(PWD)/Makefile.kernel $(KMAKEVARS) v4l-$(LXDIALOG)
 
 #################################################
 # IVTV link rules
diff -r 13622c93e20a -r b60d5192e59c v4l/Makefile.kernel
--- /dev/null	Thu Jan  1 00:00:00 1970 +0000
+++ b/v4l/Makefile.kernel	Thu Apr 27 18:04:29 2006 -0700
@@ -0,0 +1,46 @@
+# This Makefile is used to build sources that are part of the kernel tree. 
+# What we want are the various programs used by the kconfig system.  We can't
+# just directly call the top-level kernel Makefile, as it doesn't provide
+# targets to only build the kconfig system.  It provides targets to build
+# the kconfig system *and then configure the kernel*.  
+
+# What we do is include the top-level kernel Makefile here, to get all the
+# variables and rules it defines, and then add our own targets to just build
+# the kconfig system.  You can think of this file as a modified version of the
+# top-level kernel Makefile that has "kconfig build only" targets added to it.
+# Each of these new targets has the prefix v4l- so it doesn't conflict with
+# any targets in the kernel Makefile.
+
+# Like the kernel Makefile, this Makefile should have the cwd be the root
+# of the kernel source.
+
+# These should be defined on the command line, to override the kernel Makefile
+# config-targets := 1
+# mixed-targets := 0
+# dot-config := 0
+
+include $(KDIR)/Makefile
+
+# Used by the config target
+v4l-conf: scripts_basic
+	$(MAKE) $(build)=scripts/kconfig scripts/kconfig/conf
+
+# Used by the xconfig target
+v4l-qconf: scripts_basic
+	$(MAKE) $(build)=scripts/kconfig qconf-target=1 scripts/kconfig/qconf
+
+# Used by the qconfig target
+v4l-gconf: scripts_basic
+	$(MAKE) $(build)=scripts/kconfig gconf-target=1 scripts/kconfig/gconf
+	
+# Used by the menuconfig target, also needs lxdialog
+v4l-mconf: scripts_basic
+	$(MAKE) $(build)=scripts/kconfig scripts/kconfig/mconf
+
+# Rule used for kernel where lxdialog is in directory scripts/lxdialog
+v4l-%/scripts/lxdialog/lxdialog: scripts_basic
+	$(MAKE) $(build)=scripts/lxdialog
+
+# Rule used for kernel where lxdialog is in directory scripts/kconfig/lxdialog
+v4l-%/scripts/kconfig/lxdialog/lxdialog: scripts_basic
+	$(MAKE) $(build)=scripts/kconfig/lxdialog
_______________________________________________

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