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?