0

I'm trying to build an out-of-tree module against a downloaded kernel tree.

My Makefile looks like this:

obj-m += userModule.o
ARCH := arm
CC := arm-linux-gnueabihf-
KERN_DIR := /home/user/Downloads/beaglebone-linux-5.10/
CD := /home/user/Downloads/userModule/

all:
       make ARCH=$(ARCH) CROSS_COMPILE=$(CC) -C $(KERN_DIR) M=$(CD) modules
clean:
       make ARCH=$(ARCH) CROSS_COMPILE=$(CC) -C $(KERN_DIR) M=$(CD) clean
help:
       make ARCH=$(ARCH) CROSS_COMPILE=$(CC) -C $(KERN_DIR) M=$(CD) help

When I execute: $make, I get an error:

$make
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /home/user/Downloads/beaglebone-linux-5.10/ M=/home/user/Downloads/userModule/ modules
make: Entering directory '/home/user/Downloads/beaglebone-linux-5.10'
  CC [M]  /home/user/Downloads/userModule//userModule.o
/bin/sh: 1: arm-linux-gnueabihf-: not found
make[1]: *** [scripts/Makefile.build:280: /home/user/Downloads/userModule//userModule.o] Error 127
make: *** [Makefile:1825: /home/user/Downloads/userModule/] Error 2
make: Leaving directory '/home/user/Downloads/beaglebone-linux-5.10'
make: *** [Makefile:9: all] Error 2

But, when I comment out the entire Makefile except for the first line, so it looks like this:

obj-m += userModule.o

and I execute the same command but this time from the command line, everything is built with no error:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /home/user/Downloads/beaglebone-linux-5.10/ M=$PWD modules

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /home/user/Downloads/beaglebone-linux-5.10/ M=$PWD modules
make: Entering directory '/home/user/Downloads/beaglebone-linux-5.10'
CC [M]  /home/user/Downloads/userModule/userModule.o
MODPOST /home/user/Downloads/userModule/Module.symvers
CC [M]  /home/user/Downloads/userModule/userModule.mod.o
LD [M]  /home/user/Downloads/userModule/userModule.ko
make: Leaving directory '/home/user/Downloads/beaglebone-linux-5.10'

everything goes just fine.

I compared the 2 commands as they are shown in the building messages and they look the same. Has anybody experienced such behavior?

Yaniv G
  • 307
  • 4
  • 11

1 Answers1

2

The CC variable is supposed to be the name of your compiler. You have set it to the string arm-linux-gnueabihf- which is not the name of your compiler; in fact it's not the name of any program on your system. So, when it is executed you get an error.

CC := arm-linux-gnueabihf-

Don't set this variable.

MadScientist
  • 92,819
  • 9
  • 109
  • 136