File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ # If KERNELRELEASE is defined, we've been invoked from the
2
+ # kernel build system and can use its language
3
+ ifneq ($(KERNELRELEASE ) ,)
4
+ obj-m := hello.o
5
+
6
+ # Otherwise we were called directly from the command
7
+ # line; invoke the kernel build system
8
+ else
9
+ KERNELDIR ?= /lib/modules/$(shell uname -r)/build
10
+ PWD := $(shell pwd)
11
+
12
+ all :
13
+ $(MAKE ) -C $(KERNELDIR ) M=$(PWD ) modules
14
+
15
+ endif
16
+
17
+ .PHONY : clean.
18
+ clean :
19
+ rm -rf * .o * .~ * .ko * .mod.c * .order * .symvers
Original file line number Diff line number Diff line change
1
+ #include <linux/init.h>
2
+ #include <linux/module.h>
3
+ MODULE_LICENSE ("BSD" );
4
+
5
+ static int hello_init (void )
6
+ {
7
+ printk (KERN_ALERT "Hello world!\n" );
8
+ return 0 ;
9
+ }
10
+
11
+ static void hello_exit (void )
12
+ {
13
+ printk (KERN_ALERT "Goodbye, cruel world!\n" );
14
+ }
15
+
16
+ module_init (hello_init );
17
+ module_exit (hello_exit );
18
+
You can’t perform that action at this time.
0 commit comments