lkml.org 
[lkml]   [2002]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: External compilation
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:26    [W:0.308 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site