summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--v4l/Makefile104
-rw-r--r--v4l/Makefile.kernel3
-rwxr-xr-xv4l/scripts/make_kconfig.pl5
3 files changed, 56 insertions, 56 deletions
diff --git a/v4l/Makefile b/v4l/Makefile
index bb22f7e5d..d1d8056c2 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -3,46 +3,37 @@ obj = .
endif
#################################################
-# Version Check
-
-ifneq ($(KERNELRELEASE),)
-
+# This Makefile is used from two contexts. It is used directly when one runs
+# 'make' from the v4l-dvb tree. It used used again when the kernel build
+# process includes this file into the kernel Makefile.
+ifneq ($(TOPDIR),)
+# We are being include from the Kernel
-include $(TOPDIR)/Rules.make
-
else
+# We are running directly, not from the Kernel
# take version info from last module build if available
+# if .version doesn't exist, make will create it for us and restart
-include $(obj)/.version
ifneq ($(SRCDIR),)
-KDIR := $(SRCDIR)
-KDIR_OBJ := $(SRCDIR)
-
-else
-ifneq ($(KERNELRELEASE),)
-KDIR_BASE := /lib/modules/$(KERNELRELEASE)
-else
-KDIR_BASE := /lib/modules/$(shell uname -r|perl -ne 'if (/^([0-9]*)\.([0-9])*\.([0-9]*)(.*)$$/) { printf ("%s.%s.%s%s\n",$$1,$$2,$$3,$$4); };')
+ OUTDIR ?= $(SRCDIR)
endif
-
-ifneq ($(wildcard $(KDIR_BASE)/source),)
-KDIR := $(KDIR_BASE)/source
-else
-KDIR := $(KDIR_BASE)/build
-endif
-
-KDIR_OBJ := $(KDIR_BASE)/build
+OUTDIR ?= /lib/modules/$(KERNELRELEASE)/build
+SRCDIR ?= /lib/modules/$(KERNELRELEASE)/source
+ifeq ($(wildcard $(SRCDIR)/Makefile),)
+ # No kernel source, but headers should be in OUTDIR
+ SRCDIR := $(OUTDIR)
endif
-
-endif
+endif # TOPDIR
#################################################
# default compilation rule
default:: config-compat.h Makefile.media links $(obj)/.version oss
- @if [ "x$(SRCDIR)" != x ]; then echo SRCDIR is $(SRCDIR) ; fi
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) $(MYCFLAGS) O=$(KDIR_OBJ) modules
+ @echo Kernel build directory is $(OUTDIR)
+ $(MAKE) -C $(OUTDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules
./scripts/rmmod.pl check
#################################################
# Object specific rules
@@ -69,6 +60,12 @@ ifneq ($(filter $(no-makefile-media-targets), $(MAKECMDGOALS)),)
endif
endif
+# If version not yet detected, we can't create/have these files yet
+ifeq ($(KERNELRELEASE),)
+ makefile-media := 0
+ dot-config := 0
+endif
+
ifeq ($(dot-config),1)
-include $(obj)/.myconfig
endif
@@ -205,6 +202,9 @@ ifneq ($(KERNELRELEASE),)
ifneq ($(SRCDIR),)
@echo -e SRCDIR=$(SRCDIR)\\n >> $(obj)/.version
endif
+ifneq ($(OUTDIR),)
+ @echo -e OUTDIR=$(OUTDIR)\\n >> $(obj)/.version
+endif
else
@echo "No version yet."
@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
@@ -216,18 +216,21 @@ ifneq ($(VER),)
@echo $(VER)|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
else
ifneq ($(DIR),)
- @echo "Seeking for a version at $(DIR)/Makefile."
+ @echo "Searching $(DIR)/Makefile for kernel version."
@perl \
- -e 'open IN,"$(DIR)/Makefile"; ' \
+ -e '$$d="$(DIR)"; ' \
+ -e 'S: open IN,"$$d/Makefile"; ' \
-e 'while (<IN>) {' \
- -e ' if (/^VERSION\s*=\s*([0-9]+)/){ $$version=$$1; }' \
- -e ' elsif (/^PATCHLEVEL\s*=\s*([0-9]+)/){ $$level=$$1; }' \
- -e ' elsif (/^SUBLEVEL\s*=\s*([0-9]+)/){ $$sublevel=$$1; }' \
- -e ' elsif (/^EXTRAVERSION\s*=\s*([^\s]+)\n/){ $$extra=$$1; }' \
+ -e ' if (/^VERSION\s*=\s*(\d+)/){ $$version=$$1; }' \
+ -e ' elsif (/^PATCHLEVEL\s*=\s*(\d+)/){ $$level=$$1; }' \
+ -e ' elsif (/^SUBLEVEL\s*=\s*(\d+)/){ $$sublevel=$$1; }' \
+ -e ' elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \
+ -e ' elsif (/^KERNELSRC\s*:=\s*(\S.*)\n/){ $$o=$$d; $$d=$$1; goto S; }' \
-e '};' \
-e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \
-e ' $$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \
- -e 'printf ("SRCDIR:=$(DIR)\n");' > $(obj)/.version
+ -e 'print "OUTDIR:=$$o\n" if($$o);' \
+ -e 'print "SRCDIR:=$$d\n";' > $(obj)/.version
@cat .version|grep KERNELRELEASE:|sed s,'KERNELRELEASE:=','Forcing compiling to version ',
@if [ ! -f $(DIR)/scripts/kallsyms ]; then \
@@ -249,10 +252,10 @@ oss:
ln -sf . oss
config-compat.h:: $(obj)/.version .myconfig
- perl scripts/make_config_compat.pl $(KDIR) $(obj)/.myconfig $(obj)/config-compat.h
+ perl scripts/make_config_compat.pl $(SRCDIR) $(obj)/.myconfig $(obj)/config-compat.h
kernel-links makelinks::
- cd ..; v4l/scripts/makelinks.sh $(KDIR)
+ cd ..; v4l/scripts/makelinks.sh $(SRCDIR)
#################################################
# Cardlist updating rule
@@ -297,19 +300,19 @@ debug::
# Configuration rules
# Kernel config programs
-QCONF := $(KDIR_OBJ)/scripts/kconfig/qconf
-GCONF := $(KDIR_OBJ)/scripts/kconfig/gconf
-MCONF := $(KDIR_OBJ)/scripts/kconfig/mconf
-CONF := $(KDIR_OBJ)/scripts/kconfig/conf
+QCONF := $(OUTDIR)/scripts/kconfig/qconf
+GCONF := $(OUTDIR)/scripts/kconfig/gconf
+MCONF := $(OUTDIR)/scripts/kconfig/mconf
+CONF := $(OUTDIR)/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_DIR := $(shell if [ -d $(OUTDIR)/scripts/kconfig/lxdialog ]; then echo kconfig/ ; fi)
# lxdialog might not be a separate program that needs to be built, check
# for lxdialog/Makefile to find out.
-ifneq ($(wildcard $(KDIR)/scripts/$(LXDIALOG_DIR)lxdialog/Makefile),)
+ifneq ($(wildcard $(SRCDIR)/scripts/$(LXDIALOG_DIR)lxdialog/Makefile),)
# lxdialog must be built
LXDIALOG_LNK := $(if $(LXDIALOG_DIR),scripts/kconfig,scripts/lxdialog)
- LXDIALOG := $(KDIR)/scripts/$(LXDIALOG_DIR)lxdialog/lxdialog
+ LXDIALOG := $(OUTDIR)/scripts/$(LXDIALOG_DIR)lxdialog/lxdialog
endif
# Ideally, some kind of oldconfig process would be used to update .config
@@ -319,10 +322,10 @@ endif
$(obj)/.config: $(obj)/.version
@echo Updating/Creating .config
@if [ -e $(obj)/.config ]; then touch $(obj)/.config ; else \
- ./scripts/make_kconfig.pl $(KDIR_OBJ) ; fi
+ ./scripts/make_kconfig.pl $(OUTDIR) $(SRCDIR); fi
$(obj)/Kconfig: $(obj)/.version
- ./scripts/make_kconfig.pl $(KDIR_OBJ)
+ ./scripts/make_kconfig.pl $(OUTDIR) $(SRCDIR)
# With make -j, it's possible that both the .config and Kconfig rules
# will run at the same time, running make_kconfig.pl twice. There
@@ -342,12 +345,12 @@ menuconfig:: $(MCONF) lxdialog $(obj)/Kconfig
$(MCONF) $(obj)/Kconfig
allyesconfig allmodconfig:: $(obj)/.version
- ./scripts/make_kconfig.pl $(KDIR_OBJ) 1
+ ./scripts/make_kconfig.pl $(OUTDIR) $(SRCDIR) 1
# rule to build kernel conf programs
-KMAKEVARS := config-targets=1 mixed-targets=0 dot-config=0
+KMAKEVARS := config-targets=1 mixed-targets=0 dot-config=0 SRCDIR=$(SRCDIR)
$(QCONF) $(GCONF) $(MCONF) $(CONF):
- $(MAKE) -C $(KDIR_OBJ) -f $(PWD)/Makefile.kernel $(KMAKEVARS) v4l-$(notdir $@)
+ $(MAKE) -C $(OUTDIR) -f $(PWD)/Makefile.kernel $(KMAKEVARS) v4l-$(notdir $@)
# lxdialog has two parts, a symlink and the actual binary
.PHONY: lxdialog
@@ -355,10 +358,10 @@ lxdialog: $(LXDIALOG) $(LXDIALOG_LNK)
ifdef LXDIALOG
$(LXDIALOG_LNK):
- ln -snf $(KDIR)/$(LXDIALOG_LNK) $(LXDIALOG_LNK)
+ ln -snf $(OUTDIR)/$(LXDIALOG_LNK) $(LXDIALOG_LNK)
$(LXDIALOG):
- $(MAKE) -C $(KDIR) -f $(PWD)/Makefile.kernel $(KMAKEVARS) v4l-$(LXDIALOG)
+ $(MAKE) -C $(SRCDIR) -f $(PWD)/Makefile.kernel $(KMAKEVARS) v4l-$(LXDIALOG)
endif
cx88-ivtv::
@@ -414,8 +417,3 @@ snapshot snap tarball:: update distclean
(cd ..; tar czf $(snapdir)/$(snap)-$(date).tar.gz .)
hg history --style scripts/map-changelog > /$(snapdir)/$(snap)-ChangeLog-$(date)
$(MAKE) -C $(snapdir)
-
-init:
- make -C $(KDIR) init
-
-$(KDIR)/include/linux/autoconf.h: init
diff --git a/v4l/Makefile.kernel b/v4l/Makefile.kernel
index 7229c6e91..275652609 100644
--- a/v4l/Makefile.kernel
+++ b/v4l/Makefile.kernel
@@ -19,7 +19,8 @@
# mixed-targets := 0
# dot-config := 0
-include Makefile
+KBUILD_SRC := $(SRCDIR)
+include $(SRCDIR)/Makefile
# Used by the config target
v4l-conf: scripts_basic
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl
index 7cb258d86..e228d38b4 100755
--- a/v4l/scripts/make_kconfig.pl
+++ b/v4l/scripts/make_kconfig.pl
@@ -14,6 +14,7 @@ my %depmods = ();
my ($version, $level, $sublevel, $kernver);
my $kernel = shift;
+my $kernsrc = shift;
my $force_kconfig = shift;
my $debug=0;
@@ -542,7 +543,7 @@ disable_config('DVB_FE_CUSTOMISE');
disable_config('VIDEO_HELPER_CHIPS_AUTO');
# ACI needs some kernel includes that might not be there
-disable_config('SOUND_ACI_MIXER') if (! -e "$kernel/sound/oss/sound_config.h");
+disable_config('SOUND_ACI_MIXER') if (! -e "$kernsrc/sound/oss/sound_config.h");
# Check dependencies
my %newconfig = checkdeps();
@@ -595,7 +596,7 @@ if ($force_kconfig==1 || !-e '.config') {
# Check for full kernel sources and print a warning
sub kernelcheck()
{
- my $fullkernel="$kernel/fs/fcntl.c";
+ my $fullkernel="$kernsrc/fs/fcntl.c";
if (! -e $fullkernel) {
print <<"EOF2";