summaryrefslogtreecommitdiff
path: root/v4l
diff options
context:
space:
mode:
Diffstat (limited to 'v4l')
-rw-r--r--v4l/Makefile43
1 files changed, 22 insertions, 21 deletions
diff --git a/v4l/Makefile b/v4l/Makefile
index d1d8056c2..f97274db1 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -26,12 +26,20 @@ ifeq ($(wildcard $(SRCDIR)/Makefile),)
SRCDIR := $(OUTDIR)
endif
+ifneq ($(origin KDIR), undefined)
+ifneq ($(KDIR),$(SRCDIR))
+KERNELRELEASE :=
+override DIR := $(KDIR)
+.PHONY: $(obj)/.version
+endif
+endif
+
endif # TOPDIR
#################################################
# default compilation rule
-default:: config-compat.h Makefile.media links $(obj)/.version oss
+default:: config-compat.h Makefile.media links oss
@echo Kernel build directory is $(OUTDIR)
$(MAKE) -C $(OUTDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules
./scripts/rmmod.pl check
@@ -39,7 +47,7 @@ default:: config-compat.h Makefile.media links $(obj)/.version oss
# Object specific rules
# Targets which don't need Makefile.media's rules
-no-makefile-media-targets := %config clean distclean release snapshot snap \
+no-makefile-media-targets := %config clean distclean snapshot snap \
tarball release %links start insmod load stop rmmod unload reload \
card% update push %commit help debug cx88-ivtv lxdialog
@@ -196,27 +204,16 @@ remove rminstall:: media-rminstall
#################################################
# Compiling preparation rules
-$(obj)/.version:
-ifneq ($(KERNELRELEASE),)
- @echo -e VERSION=$(VERSION)\\nPATCHLEVEL:=$(PATCHLEVEL)\\nSUBLEVEL:=$(SUBLEVEL)\\nKERNELRELEASE:=$(KERNELRELEASE) > $(obj)/.version
-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
+.PHONY: release
+ifneq ($(filter release,$(MAKECMDGOALS)),)
+.PHONY: $(obj)/.version
endif
+release:
+ @true
-release::
-ifneq ($(VER),)
- @echo "Forcing compiling to version $(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
+$(obj)/.version:
ifneq ($(DIR),)
- @echo "Searching $(DIR)/Makefile for kernel version."
+ @echo "Searching in $(DIR)/Makefile for kernel version."
@perl \
-e '$$d="$(DIR)"; ' \
-e 'S: open IN,"$$d/Makefile"; ' \
@@ -237,7 +234,11 @@ ifneq ($(DIR),)
echo "*** Warning: You should configure and build kernel before compiling V4L"; \
fi
else
- @echo "No version specified. Using `uname -r`."
+ifneq ($(VER),)
+ @echo "Forcing kernel version to $(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
+ @echo No version yet, using `uname -r`
@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
endif
endif