If you want to compile the hello module follow these steps:
Create the Makefile in your directory with the hello.c
If you get something like this
Another reason for the above error can be, that your browser converted the TAB before $(MAKE) to spaces. Make sure there is a TAB before $(MAKE).
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
Install it with install.sh:
Now make a
Or if you don't want to install the module, do this:
..and if your system doesn't freeze you've done it right ;-)
For kernel 2.4, the Makefile would look like this:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
printk(KERN_ALERT "hello, world ");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "goodbye,cruel world ");
}

module_init(hello_init);
module_exit(hello_exit);
Create the Makefile in your directory with the hello.c
obj-m := hello.oNow do a
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
make... and the hello.ko is built.
If you get something like this
# makeyou need to install the kernel source and compile the kernel first (run "make" at least to the point until all "HOSTCC scripts/" stuff is done - this will configure your kernel and allows external module compilation). Make sure /lib/modules/$(shell uname -r)/build points to your build directory (most likely /usr/src/linux...).
make: Nothing to be done for `default'.
Another reason for the above error can be, that your browser converted the TAB before $(MAKE) to spaces. Make sure there is a TAB before $(MAKE).
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
Install it with install.sh:
#!/bin/sh(adjust the /lib/modules path according to your needs)
install -m 644 hello.ko /lib/modules/`uname -r`/kernel/drivers/hello.ko
/sbin/depmod -a
Now make a
# modprobe hello
Or if you don't want to install the module, do this:
# insmod ./hello.ko
..and if your system doesn't freeze you've done it right ;-)
For kernel 2.4, the Makefile would look like this:
TARGET := modulenamehello.c
INCLUDE := -I/lib/modules/`uname -r`/build/include
CFLAGS := -O2 -Wall -DMODULE -D__KERNEL__ -DLINUX
CC := gcc
${TARGET}.o: ${TARGET}.c
$(CC) $(CFLAGS) ${INCLUDE} -c ${TARGET}.c


















