这是一个编译内核模块的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

在这里,我根据kernel makefile documantation使用了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

我正在使用gnumakeversion4.1和gccversion4.4.7,哪里出错了。谢谢。。。。。

最佳答案

变量分配给什么?行中kecho@$(kecho) 'Kernel: $@ is ready'的值为空,因此make只将kecho视为规则。
你忘了在文件开头给凯乔分配任务了吗?就像
@$(kecho) 'Kernel: $@ is ready'

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

10-11 16:40