内核 kecho 命令问题的 Makefile

Makefile for kernel kecho command issue

这是编译内核模块的 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 的值为空,因此 make 通常只考虑 @$(kecho) 'Kernel: $@ is ready'

你是不是忘了在文件的开头将 kecho 分配给某些东西?喜欢

kecho='echo'