合併多個檔案成一個模組
有時候檔案會分散,如果想合在同一個模組的話可以用以下方式 start.c:
/*
* start.c − Illustration of multi filed modules
*/
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */
int init_module(void)
{
printk(KERN_INFO "Hello, world − this is the kernel speaking\n");
return 0;
}
stop.c:
/*
* stop.c − Illustration of multi filed modules
*/
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */
void cleanup_module()
{
printk(KERN_INFO "Short is the life of a kernel module\n");
}
MakeFile寫法:
obj−m += startstop.o
startstop−objs := start.o stop.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