Home:ALL Converter>Makefile for kernel kecho command issue

Makefile for kernel kecho command issue

Ask Time:2015-02-16T17:55:09         Author:Abhijatya Singh

Json Formatter

This a makefile for compiling the kernel module.

# 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

Here I have used echo and kecho as per kernel makefile documantation but it giving the following error:

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

I am using GNU make version 4.1 and gcc version 4.4.7 where am I going wrong. Thanks.....

Author:Abhijatya Singh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28538683/makefile-for-kernel-kecho-command-issue
yy