diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2007-10-10 21:12:01 -0700 |
---|---|---|
committer | Trent Piepho <xyzzy@speakeasy.org> | 2007-10-10 21:12:01 -0700 |
commit | f5d374cc9de6fb9662b36c3e9af48c6abb6be743 (patch) | |
tree | 7e5591ee90489b1cc0f7f0f966d878bcfc99e3b3 /v4l/Makefile | |
parent | 30237df1702f85366f07cef0b1041255e296fd28 (diff) | |
download | mediapointer-dvb-s2-f5d374cc9de6fb9662b36c3e9af48c6abb6be743.tar.gz mediapointer-dvb-s2-f5d374cc9de6fb9662b36c3e9af48c6abb6be743.tar.bz2 |
build: Handle kernel output directories correctly
From: Trent Piepho <xyzzy@speakeasy.org>
Recent patches to try to handle kernel object file directories haven't been
doing it correctly. This patch reworks the way the kernel location(s) are
handled.
KDIR et al are removed and replaced with two variables, SRCDIR and OUTDIR.
SRCDIR is the location of:
The main kernel Makefile
The kernel headers
The kernel source (if present)
OUTDIR is the location of:
The kernel .config file
The kernel [qxm]conf binaries (if present)
The following kernel situations should be handled correctly:
1. A kernel installed from source. One can specify the version via "make
release VER=version". If VER is not specified, uname -r is used. This the
default if make is run on a clean tree. OUTDIR is /lib/modules/$(VER)/build
and SRCDIR is /lib/modules/$(VER)/source, which are both symlinks pointing to
the same location.
2. A kernel installed from source which was was built with the
"O=/output/directory" option to the kernel Makefile. The version is specified
the same was as above. OUTDIR and SRCDIR are the same as above, except in
this case they are symlinks to different directories. OUTDIR will be a link
the the directory used in the "O=" option and SRCDIR will be the source
location.
3. An installed binary kernel with only a kernel-headers package. The
version can be specified the same way as above. OUTDIR will be
/lib/modules/$(VER)/build and SRCDIR will be the same as OUTDIR, as no
'source' directory exists. The kernel source and Kconfig program are most
likely not present.
4. An un-installed kernel source tree, for a kernel that was built without
using the "O=/outdir/directory" option. The kernel does not need to be fully
built, only the "modules_prepare" target needs to be built. The location of
the tree is specified with "make release DIR=directory". Both SRCDIR and
OUTDIR will be $(DIR).
5. An un-installed kernel source tree, for a kernel that was built using the
"O=/output/directory" option. The location of the tree is specified using
"make release DIR=/output/directory". Note that DIR is not the directory with
the kernel source! It is set to the directory that was used with the O option
when the kernel was built. The Makefile in this directory has a link back to
the kernel source directory and the v4l-dvb build system will find this.
OUTDIR will be the '/output/directory' and SRCDIR will be the location of the
source that built it.
All all these situation the v4l-dvb tree should build correctly and all the
various scripts will work. In addition, if the binaries for the [qxm]conf
programs are present, "make menuconfig", etc. will work as well. If the
binaries are not present, but the source is, the Makefile will automatically
build the binaries when "make menuconfig", etc. is used. The source should
be present in all situation except (3), a kernel-headers only install.
Note that if the kernel output directory (usually the same as the kernel
source directory, except for (2) and (5)) is not writable, then building the
Kconfig programs automatically will not be possible.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Diffstat (limited to 'v4l/Makefile')
-rw-r--r-- | v4l/Makefile | 104 |
1 files changed, 51 insertions, 53 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 |