how to build module outside kernel tree

osama
hi everyone!
I am doing with mini2440 and trying to modify drivers. I know that when
building drivers, we have 2 ways:
   1. Compile INSIDE KERNEL TREE
   2. Compile OUTSIDE Kernel tree
Now, I want to compile my driver outside kernel tree but I don't know how
to write make file,... 
anyone knows that problem?
Please, help me! 
Thanks a lot.Nice day.:)

open-nandra
Hi, you can create simple Makefile in your external module:
obj-m +=  MyDriver.o

export KROOT=/home/linux-2.6-xlnx/
export ARCH=arm

all:
  @$(MAKE) -C $(KROOT) M=$(PWD) modules
clean:
  rm -rf   Module.symvers modules.order *.o *.ko

where KROOT is path to your kernel. 

Good luck,

marek

mayur
obj-m := serial.o
KDIR := /home/ABC/linux-2.6.32.2
PWD := $(shell pwd)
default:
        $(MAKE)  -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
        $(MAKE)  -C $(KDIR) SUBDIRS=$(PWD) clean

i am using this script but not working on x86 host machine

davef
any error messages?