我的 makefile 结果:没有规则可以制作目标`arch/x86/tools/relocs.c',需要

Avi*_*shK 9 makefile

我正在使用 Ubuntu 12.04。我写了一个简单的 hello world 内核模块 ( hello.c)。我为它编写了以下makefile:

obj-m+=hello.o
KDIR:= /usr/src/linux-headers-3.2.0-24-generic-pae
all:
     $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
     rm -rf *.o *.ko *.mod.* *.symvers *.order 
Run Code Online (Sandbox Code Playgroud)

但是当我从内核制作时出现了这个错误:

make[1]: Entering directory `/usr/src/linux-headers-3.2.0-24-generic-pae'
make[2]: *** No rule to make target `arch/x86/tools/relocs.c', needed
by `arch/x86/tools/relocs'.  Stop.
Run Code Online (Sandbox Code Playgroud)

hello.c并且makefile/Documents/module_prog. 我make从那个目录跑了。

是什么导致了这个错误,我该如何解决?

小智 11

在make文件中,只需更改SUBDIRS=$(PWD)M=$(shell pwd)...

像魅力一样工作