大家好,初学Linux 驱动,有个问题不是很明白。
看过陈皓写过的 “跟我一起学 Makefile" 其中说: makefile 的文件可以命名为 “Makefile” 和“makefile”
再练习写hello world 驱动的时候,我将makefile 命名为两种不同的形式, 但发现大写的Makefile 可以编译通过,但是小写的makefile 编译时确出现 以下错误:
make -C /lib/modules/4.10.0-28-generic/build M=/home/seven/Templates/dirver/helloword modules
make[1]: Entering directory '/usr/src/linux-headers-4.10.0-28-generic'
scripts/Makefile.build:44: /home/seven/Templates/dirver/helloword/Makefile: No such file or directory
make[2]: *** No rule to make target '/home/seven/Templates/dirver/helloword/Makefile'. Stop.
Makefile:1524: recipe for target '_module_/home/seven/Templates/dirver/helloword' failed
make[1]: *** [_module_/home/seven/Templates/dirver/helloword] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-28-generic'
makefile:5: recipe for target 'modules' failed
make: *** [modules] Error 2
说没有找到Makefile 。
makefile 内如如下:
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions Module* modules*
.PHONY: modules modules_install clean
else
obj-m := helloworld.o
endif |