Linux 内核模块 makefile 问题

标签 linux compilation makefile kernel

我正在尝试学习一些有关 Linux 内核编程的知识,但在尝试了一个教程之后,我完全被困住了。 我的 makefile 提示某种“未找到命令”错误(错误 127),因此它不会编译它。 我尝试寻找解决方案,但没有任何结果。所以我想我会试着在这里问。抱歉,如果这是重复的。

这是 shell 的错误输出:

malt@ubuntu:~/Documents/C$ make
C /usr/src/linux SUBDIRS=/home/malt/Documents/C; modules
/bin/sh: 1: C: not found
/bin/sh: 1: modules: not found
make: [default] Error 127 (ignored)

这是我的生成文件:

# Makefile of My First Driver

# if KERNELRELEASE is defined, we've been invoked from the kernel build system
# and can use it's language
ifneq (${KERNELRELEASE},)
    obj-m := mfd.o

# otherwise we've been called directly from the commandline.
# invoke the kernel build system.
else
    KERNEL_SOURCE := /usr/src/linux
    PWD := ${shell pwd};

default:
    ${make} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules

clean:
    ${make} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean

endif

有没有人知道哪里出了问题?

提前致谢!

最佳答案

添加到 Santosh A 的更改

  1. PWD := ${shell pwd}; 中不应有;。删除它将解决 /bin/sh: 1: modules: not found 错误。

关于Linux 内核模块 makefile 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25198483/

相关文章:

运行uberjar时Clojure FileNotFound异常,尽管文件在项目源中

c - #ifdef 和使用 Makefile 的条件编译

linux - 从命令行计算多个子目录中的文件数量

java - 使用 Gradle 的 Eclipse 多个项目中的访问限制

c++ - Visual Studio 2010 不重建/重新编译

c++ - 错误为 : unrecognized option '-mcpu=arm1176jzf-s'

c++ - 如何使用 clang 和 llvm-link 链接库

linux - 使用 scons.py 添加配方的 Yocto do_package() 语法

mysql - MySQL CentOS 6 无法设置根密码

c++ - 在 Linux 中检测从管道/fifo 的另一端读取的尝试