lkml.org 
[lkml]   [2004]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Inserting a module (2.6 kernel)
On Wed, Jun 09, 2004 at 11:47:58AM +0200, Andi Kleen wrote:
>
> Now since 2.6.5 or so it needs:
>
> /* MODULE is not needed anymore */
> #define __KERNEL__1
> #include <linux/module.h>
>
> int init_module(void)
> {
> printk("Hello world\n");
> return 0;
> }
>
> struct module __this_module
> __attribute__((section(".gnu.linkonce.this_module"))) = {
> .name = "hello",
> .init = init_module,
> };

Most of the glue above can be deleted if you just accept to use kbuild when
building modules.
So to compile your module use a simple Makefile:
obj-m := mymodule.o

Then to compile the module use:
make -C path/to/kernel/src M=`pwd`

And to install it use:
make -C path/to/kernel/src M=`pwd` modules_install

And to clean up in the directory where the module is being compiled:
make -C path/to/kernel/src M=`pwd` clean

Sam
-
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 14:03    [W:0.020 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site