Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimalist version of external kernel module Makefile
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
- Loading branch information
1 parent
07de3c9
commit 0c5142f
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Minimal Makefile for compiling external kernel modules | ||
kbuilddir ?= /lib/modules/$(shell uname -r)/build/ | ||
obj-m += example01.o | ||
obj-m += example02.o | ||
modules: | ||
$(MAKE) -C $(kbuilddir) M=$$PWD modules | ||
install: | ||
$(MAKE) -C $(kbuilddir) M=$$PWD modules_install | ||
clean: | ||
$(MAKE) -C $(kbuilddir) M=$$PWD clean | ||
@rm -f *~ | ||
.PHONY: default install clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
|
||
#include <linux/init.h> | ||
#include <linux/module.h> | ||
#include <linux/printk.h> | ||
|
||
static int __init my_module_init(void) | ||
{ | ||
pr_warn("Module loaded\n"); | ||
return 0; | ||
} | ||
module_init(my_module_init); | ||
|
||
static void __exit my_module_exit(void) | ||
{ | ||
pr_warn("Module unloaded\n"); | ||
} | ||
module_exit(my_module_exit); | ||
|
||
MODULE_AUTHOR("Your Name <name@domain.com>"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
|
||
#include <linux/init.h> | ||
#include <linux/module.h> | ||
#include <linux/printk.h> | ||
|
||
static int __init my_module_init(void) | ||
{ | ||
pr_warn("Module loaded\n"); | ||
return 0; | ||
} | ||
module_init(my_module_init); | ||
|
||
static void __exit my_module_exit(void) | ||
{ | ||
pr_warn("Module unloaded\n"); | ||
} | ||
module_exit(my_module_exit); | ||
|
||
MODULE_AUTHOR("Your Name <name@domain.com>"); | ||
MODULE_LICENSE("GPL"); |