最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

Solve: scripts/Makefile.build:41: /usr/crifan/develop/driver/Makefile: No such file or directory

工作和技术 crifan 2102浏览 0评论

the hello_driver.c is copy from LDD3:
———————————————————————————————-
#include <linux/init.h>

#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)

{

    printk(KERN_ALERT "Hello, worldn");

    return 0;

}

static void hello_exit(void)

{

    printk(KERN_ALERT "Goodbye, cruel worldn");

}

module_init(hello_init);

module_exit(hello_exit);
———————————————————————————————-
and the makefile is:

———————————————————————————————-

#INCLUDE_DIRS = /usr/src/

#hello_driver: hello_driver.o
#    cc -o hello_driver hello_river.o

#hello_driver.o:hello_driver.c
#    cc -c -I$(INCLUDE_DIRS) hello_driver.c

#clean:
#    rm hello_driver hello_driver.o

obj-m    += hello_driver.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

———————————————————————————————-

and when type "makefile" into terminal,the result is:
———————————————————————————————-
root@ubuntu810:/usr/crifan/develop/driver# make
make -C /lib/modules/2.6.27-7-generic/build M=/usr/crifan/develop/driver modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.27-7-generic’
scripts/Makefile.build:41: /usr/crifan/develop/driver/Makefile: No such file or directory
make[2]: *** No rule to make target `/usr/crifan/develop/driver/Makefile’. Stop.
make[1]: *** [_module_/usr/crifan/develop/driver] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-7-generic’
make: *** [all] Error 2

———————————————————————————————-
the simplest solution is:
change the file: makefile name to "Makefile"
for the reason described in:

———————————————————————————————-

《Linux驱动程序开发》学习笔记(一)(zz)

"对这段脚本需要说明下面几点:
       (1)、将上面的脚本保存为Makefile,注意必须保存为M为大写的Makefile。这是因为编译的时候首先看环境变量KERNELRELEASE是否定义,如果没定义则调用Linux内核编译build脚本。该脚本会首先编译内核,其间会创建环境变量KERNELRELEASE,接着编译当前工作目录下的hello模块,此时会第二遍读取Makefile,再次判断环境变量KERNELRELEASE是否定义,已经定义的情况下开始编译hello模块。
如果将该脚本保存为小写m开头的makefile,编译时会出现这样的提示:
scripts/Makefile.build:13: /root/zhou/Makeifle: No such file or directory.
"

转载请注明:在路上 » Solve: scripts/Makefile.build:41: /usr/crifan/develop/driver/Makefile: No such file or directory

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.767 seconds, using 22.10MB memory