打印

今天编写一个hello的驱动模块,但对于makefile很郁闷

[复制链接]
1760|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wang12zhe|  楼主 | 2012-9-9 21:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
源码:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>

#define DEVICE_NAME "myfrisr_dev_hello"
#define HELLO_MAJOR 45
static int myfrist_dev_open(struct inode *inode,struct file *file)
  {
    printk("come here I am here \n");
    printk("");
    return 0;
  }
static ssize_t myfrist_dev_write(struct file *file,const char __user *buf,size_t count, loff_t *ppos)
{
   printk("i will go ,thank you \n");
  return 0;
}
static struct file_operations myfrist_dev_fops={
.owner = THIS_MODULE,
.open = myfrist_dev_open,
.write = myfrist_dev_write,
};
static int __init myfrist_dev_hello_init(void)
{
   int ret;
   
   ret = register_chrdev(HELLO_MAJOR,DEVICE_NAME,&myfrist_dev_fops );
  if(ret<0)
   {
     printk(DEVICE_NAME "canot register major number");
     return ret;
   }
   printk(DEVICE_NAME"init yes \n");
   return 0;
}
static void __exit myfrist_dev_hello_exit(void)
{
  unregister_chrdev(HELLO_MAJOR,DEVICE_NAME);
}

module_init(myfrist_dev_hello_init);
module_exit(myfrist_dev_hello_exit);
MODULE_LICENSE("GPL");


自己写了一个Makefile
NEL_DIR=/home/a123/lx/linux-2.6.30.4/
all:
make -C $(NEL_DIR) M=$(pwd) modules
      
obj-m   += frist_driver_hello.o

clean:
rm -rf *.bak *.mod* *or* *.sym* *.ko *.o
但make后
出现如下:
[email=root@a123-virtual-machine:/mnt/hgfs/Win/ARMEXP/frist_driver_hello]root@a123-virtual-machine:/mnt/hgfs/Win/ARMEXP/frist_driver_hello[/email]# make
make -C /home/a123/lx/linux-2.6.30.4/ M= modules
make[1]: Entering directory `/home/a123/lx/linux-2.6.30.4'
  CHK     include/linux/version.h
make[2]: `include/asm-arm/mach-types.h' is up to date.
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-arm
  CALL    scripts/checksyscalls.sh
<stdin>:1097:2: warning: #warning syscall fadvise64 not implemented
<stdin>:1265:2: warning: #warning syscall migrate_pages not implemented
<stdin>:1321:2: warning: #warning syscall pselect6 not implemented
<stdin>:1325:2: warning: #warning syscall ppoll not implemented
<stdin>:1365:2: warning: #warning syscall epoll_pwait not implemented
  Building modules, stage 2.
  MODPOST 413 modules
make[1]: Leaving directory `/home/a123/lx/linux-2.6.30.4'
[email=root@a123-virtual-machine:/mnt/hgfs/Win/ARMEXP/frist_driver_hello]root@a123-virtual-machine:/mnt/hgfs/Win/ARMEXP/frist_driver_hello[/email]#
并没有编译出想要的.ko文件,

然后我使用 make -C /home/a123/lx/linux-2.6.30.4/ M=$(pwd) modules却能编译出.ko文件,这是为什么,请大侠指点一下吧 我郁闷一天啦

相关帖子

沙发
wang12zhe|  楼主 | 2012-9-10 16:03 | 只看该作者
太他妈坑爹啦 obj-m :=hello.o 中   :和=之间是一个英文的空格,我写成中文的空格啦,一个空格困扰我两天,啊啊啊啊啊啊啊 ,也不提示个错误

使用特权

评论回复
板凳
aozima| | 2012-9-10 16:57 | 只看该作者
全角空格的典型案例。

使用特权

评论回复
地板
lkjmnf| | 2012-9-12 13:23 | 只看该作者
神了,喝茶也能减肥。本来是想试试看的。还真减下来了。喝的是瑞士维塔 减肥茶,没有反弹,没有副作用,对局部减肥还有特别好的作用。口感不错,人还挺舒服的。我是在乐购时尚网买的QQ:876931865     -http://www.letgogo.com/#r-pcam。你也看看呀 cam

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

101

主题

205

帖子

1

粉丝