I'm trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host.
The codesourcery tool chain for ARM is located at: /home/ravi/workspace/hawk/arm-2009q3
The kernel source is located at :/home/ravi/workspace/hawk/linux-omapl1
My Makefile:
ARCH=arm
CROSS_COMPILE=arm-none-linux-gnueabi
obj-m := Hello.o
KDIR := /home/ravi/workspace/hawk/linux-omapl1
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
When i run make, the .ko produced is that of my host machine which means the makefile is invoking the native compiler instead of the cross compiler.What am I doing wrong? The cross compiler's binaries are in my path.
Replace
by
this will also work if you do not want to give these parameter command line each time.
Sidenote:
SUBDIRS=
is deprecated in favor ofM=
.Putting
ARCH
andCROSS_COMPILE
in the Makefile doesn't work. You need to put them on the command line:could you try, you forgot to add ARCH and CROSS_COMPILE into the default and clean
adding
export
at the end of your Makefile variable declarations will make them available to subshells. and add the dash to theCROSS_COMPILE
prefix as JayM pointed out, andM
instead ofSUBDIRS
as user502515 answered.and it's generally a good idea to use
:=
rather than=
in a Makefile, so the variable only gets interpolated once. really doesn't matter in this particular case though.