【发布时间】:2014-05-05 22:34:19
【问题描述】:
我刚开始学习linux设备驱动程序。我刚刚编写了一个简单的设备驱动程序代码并尝试编译它,但是当我执行 make 时,我得到以下错误
make: Nothing to be done for `default'
这是我的设备驱动程序代码。
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Manoj");
MODULE_DESCRIPTION("My First Driver");
static int __init ofd_init ( void ) {
printk (KERN_INFO "ofd registered");
return 0;
}
static int __exit ofd_exit ( void ) {
printk (KERN_INFO "ofd unregistered");
return 0;
}
module_init ( ofd_init );
module _exit ( ofd_exit );
而我的Makefile是这样的
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
并且在路径 /lib/modules/3.2.0-58-generic-pae/build 中也存在。 谁能告诉为什么这个特定的make文件不起作用?
【问题讨论】:
-
你的makefile看起来不太好开始,试着简化它,看看例子2-2这里tldp.org/LDP/lkmpg/2.6/html/lkmpg.html
标签: c linux-kernel linux-device-driver kernel-module