[Ilugc] How to compile module

Santosh ssantosh at fossix.org
Thu Dec 11 13:56:04 IST 2008


Ashish Verma wrote:
> Hi,
> 
> I have a pcnet32.c file. I want to make a module out of it. What should I
> do. The below link requires me to make a make file. I don't know how to do
> that. Please advise.
> 
> http://www.cyberciti.biz/tips/build-linux-kernel-module-against-installed-kernel-source-tree.html
> 
> Regards,
> Ashish
> _______________________________________________
> To unsubscribe, email ilugc-request at ae.iitm.ac.in with 
> "unsubscribe <password> <address>"
> in the subject or body of the message.  
> http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
> 

Hi Ashish,
Do you have a custom compiled kernel? If so then, it is not necessary to 
download headers. If not, you have to download the headers and write a 
makefile. The makefile is very simple.

obj-m += <yourfile.o>

all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean


Then
make modulename

There is no specific directory to place your source, just compeile it 
and later you can insert.

Thanks,
Santosh


More information about the ilugc mailing list