Re: External compilation

From: Gerd Knorr (kraxel@bytesex.org)
Date: Mon Jun 10 2002 - 06:15:49 EST


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/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:16 EST