loulou
loulou

Reputation: 331

Makefile for a basic kernel module

The following Makefile aims to create a basic Module in the kernel 2.6. And so, I really would like if somebody explain to me the command lines in this Makefile:

obj−m += hello−1.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

One further question : Being in a 2.6 kernel, should I replace hello-1.o by hello-1.ko?

Upvotes: 0

Views: 313

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799490

The first line tells the kernel makefile that hello-1.o should be used to build a module. The kernel makefile will handle the extension itself; you should not change it.

The third and fifth lines invoke the kernel makefile to build/clean a module, passing it the directory it should look for source files in.

The rest is all standard makefile boilerplate.

See Documentation/kbuild/modules.txt in the kernel documentation for more details.

Upvotes: 1

Related Questions