ttroy50 / cmake-examples

Useful CMake Examples
http://ttroy50.github.io/cmake-examples
MIT License
12.31k stars 2.48k forks source link

Kernel Module Example #28

Open BlackFrog1 opened 5 years ago

BlackFrog1 commented 5 years ago

Is it possible to create a loadable kernel module example?

I know what the result of the Makefile should be

`obj-m += main.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`

ttroy50 commented 5 years ago

Thanks for the suggestion.

Unfortunately I don't know much about building kernel modules. The only experience I have is building toy examples to test things and using a makefile similar to what you posted.

I'm happy to accept a PR with an example for a kernel module but wouldn't feel comfortable to write one at the moment.

enkeyz commented 3 years ago

You can find a straightforward tutorial here: https://musteresel.github.io/posts/2020/02/cmake-template-linux-kernel-module.html