简体   繁体   English

如何在内核 Makefile 中正确 make clean

[英]How to properly make clean in kernel Makefile

I'm porting a driver to the 3.4 kernel, and when I do a make clean, it is not cleaning some .o files, so now I'm wondering what the proper way of doing this is.我正在将驱动程序移植到 3.4 内核,当我执行 make clean 时,它不会清理一些 .o 文件,所以现在我想知道这样做的正确方法是什么。

I have the following Makefile (note: in a separate directory from the kernel):我有以下 Makefile(注意:在与内核不同的目录中):

obj-y += foo.o
foo-objs += foo1.o foo2.o
clean-files := foo3.o

When I run the make clean, it wipes out foo3.o, but leaves foo.o, foo1.o, and foo2.o.当我运行 make clean 时,它会清除 foo3.o,但留下 foo.o、foo1.o 和 foo2.o。 I could put all of these into clean-files, but this seems redundant, and I would think that there would be some way to make the Makefile automatically wipe out all objects in obj-y directory.我可以将所有这些都放入干净的文件中,但这似乎是多余的,我认为有某种方法可以使 Makefile 自动清除 obj-y 目录中的所有对象。

Thanks,谢谢,

John约翰

This is the way I used to make clean my driver code:这是我用来make clean驱动程序代码的方式:

clean:
    $(MAKE) -C $(KDIR) M=$$PWD clean

You can use regular expressions in makefiles, and write *.o instead of foo1.o, foo2.o, etc.可以在makefile中使用正则表达式,用*.o代替foo1.o、foo2.o等。

Common way is to have a 'clean' target, which looks like this:常见的方法是拥有一个“干净”的目标,如下所示:

clean:
    $(RM) .*.cmd *.o *.ko -r .tmp* 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM