linux - 内核 kecho 命令问题的 Makefile

标签 linux makefile kernel

这是一个用于编译内核模块的 makefile。

# Makefile – makefile of our first driver
#  
# if KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq (${KERNELRELEASE},)

 obj-m = first-driver.o

# Otherwise we were called directly from the command line.
# Invoke the kernel build system.
else
KERNEL_SOURCE := /lib/modules/2.6.32-504.8.1.el6.x86_64/build
PWD := $(shell pwd)
default: 
        ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
        @echo kernel first-driver is ready
        @$(kecho) 'Kernel: $@ is ready' 

clean:
        ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
endif

.PHONY : install remove

install :
        sudo insmod first-driver.ko

remove :
        sudo rmmod first-driver

这里我根据内核 makefile 文档使用了 echo 和 kecho,但它给出了以下错误:

make -C /lib/modules/2.6.32-504.8.1.el6.x86_64/build SUBDIRS=/home/betatest/Device-Driver-Test modules
make[1]: Entering directory '/usr/src/kernels/2.6.32-504.8.1.el6.x86_64'
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory '/usr/src/kernels/2.6.32-504.8.1.el6.x86_64'
kernel first-driver is ready
make: Kernel: default is ready: Command not found
Makefile:16: recipe for target 'default' failed
make: *** [default] Error 127

我正在使用 GNU make 版本 4.1 和 gcc 版本 4.4.7 我哪里出错了。谢谢......

最佳答案

kecho 变量的赋值是什么?在行 @$(kecho) 'Kernel: $@ is ready' kecho's value is null 所以 make 只考虑 @$(kecho) '内核:$@ 准备就绪' 通常。

您是否忘记在文件开头将 kecho 分配给某些内容?喜欢

kecho='echo'

关于linux - 内核 kecho 命令问题的 Makefile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28538683/

相关文章:

mysql - 需要有关连接到数据库 mysql 的支持

html - 使用 Linux -poppler-utils-pdftohtml 从 pdf 生成带有图像的 html

linux - 具有相同时区但不同时间的服务器

python - ssh 到 linux 服务器,不使用 ps 命令从 python 列出 PID

c++ - 如何使用 Makefile 规则将 .o 文件放入单独的目录

c - 插入 USB 设备时如何加载模块(不是驱动程序)

Makefile:依赖于目录的每个文件

c - 具有相同功能的 C 中的 Makefile 错误

linux 在没有系统日志消息的情况下崩溃

windows - _EPROCESS 对象和 _KPROCESS 对象有什么区别