MrMalt
MrMalt

Reputation: 42

Linux kernel module makefile issues

I am trying to learn a little about Linux kernel programming, and after trying a tutorial i am completely stuck. My makefile is complaining about some sort of "Command not found" error (error 127), so it won't compile it. I tried searching for a solution, but nothing came up. So I thought I'd try to ask here. Sorry if this is a duplicate.

Here is the error output from the 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)

And here is my makefile:

# 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

Does anyone have any idea as to what is wrong?

Thanks in advance!

Upvotes: 0

Views: 1528

Answers (2)

Sagar Sakre
Sagar Sakre

Reputation: 2426

Adding to Santosh A's Changes

  1. There shouldn't be ; in PWD := ${shell pwd};. remove it which will solve /bin/sh: 1: modules: not found error.

Upvotes: 1

Santosh A
Santosh A

Reputation: 5361

change keyword make to MAKE as below

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

Upvotes: 1

Related Questions