<Makefile>
CC = gcc
KERNELDIR = /usr/src/linux-2.4.20-8
CFLAGS = -D__KERNEL__ -DMODULE -I$(KERNELDIR)/include -g -Wall
all : hello.o
hello.o : hello.c
$(CC)$(CFLAGS) -c hello.c
clean :
rm -f core hello.o
<hello.c>
#include <linux/kernel.h>
#include <linux/module.h>
#ifdef CONFIG_MODVERSIONS
#define MODVERSIONS
#include <linux/modversions.h>
#endif
MODULE_LICENSE("GPL");
int init_module(void)
{
printk("Hello, World...\n");
return 0;
}
void cleanup_module(void)
{
printk("Goodbye...\n");