linux kernel 测试文件编译失败 学习《Linux设备驱动程序第三版.pdf》,第2章的给的测试程序,无法再虚拟机上编译成功。主要原因是makefile不正确,请帮忙修改一下。 错误提示信息: make[1]: Entering directory `/usr/src/kernels/2.6.29.4-167.fc11.i686.PAE' make[2]: *** No rule to make target `/mnt/hgfs/share/kernel_code/kernel_hello.c', needed by `/mnt/hgfs/share/kernel_code/kernel_hello.o'. Stop. make[1]: *** [_module_/mnt/hgfs/share/kernel_code] Error 2 make[1]: Leaving directory `/usr/src/kernels/2.6.29.4-167.fc11.i686.PAE' make: *** [default] Error 2
书中的makefile脚本(没有指定编译器,我不清楚应该指定那个编译器)
Python code
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := kernel_hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
#ehco $(KERNELDIR)
PWD := $(shell pwd)
#echo $(PWD)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules