Messages in this thread | | | From | Gerd Knorr <> | Subject | Re: External compilation | Date | 10 Jun 2002 11:15:49 GMT |
| |
John Levon wrote: > > Is there any good example code for compiling a kernel module > externally, that works for modversions etc. on 2.2, 2.4, and 2.5, > and does the right thing (including Rules.make) ? > > I'm having an awful time working out the exact incantations.
Here is a stripped down version of what I use for bttv currently.
Gerd
==============================[ Makefile ]============================== # where the kernel sources are located KDIR := /lib/modules/$(shell uname -r)/build #KDIR := /work/bk/2.5/build
# kernel version KVER := $(shell ./uts-release $(KDIR)) MDIR := /lib/modules/$(KVER)/kernel/drivers/media/video
export-objs := bttv-if.o video-buf.o list-multi := bttv.o bttv-objs := bttv-driver.o bttv-cards.o bttv-risc.o bttv-if.o bttv-vbi.o
obj-m := video-buf.o bttv.o
multi-m := $(filter $(list-multi), $(obj-m)) int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
EXTRA_CFLAGS=-g -Wmissing-prototypes -Wstrict-prototypes
here: DIR=`pwd`; (cd $(KDIR); make SUBDIRS=$$DIR modules)
include $(KDIR)/Rules.make
bttv.o: $(bttv-objs) $(LD) -r -o $@ $(bttv-objs)
==============================[ uts-release ]============================== #! /bin/sh cat <<-EOF | cpp -P -I$1/include | grep '"' | cut -d'"' -f2 #include <linux/version.h> UTS_RELEASE EOF - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |