禁用内置化妆规则和变量从生成文件内 [英] Disable make builtin rules and variables from inside the make file
问题描述
我想禁用内置的规则和变量根据传递 -r
和 -R
选项来了GNU make,从make文件中。其他的解决方案,让我含蓄地做到这一点,透明也欢迎。
I want to disable builtin rules and variables as per passing the -r
and -R
options to GNU make, from inside the make file. Other solutions that allow me to do this implicitly and transparently are also welcome.
我发现<一个href=\"http://blog.electric-cloud.com/2009/08/19/makefile-performance-built-in-rules/#comment-219\">several引用来使用 MAKEFLAGS
,并有类似的问题。
I've found several references to using MAKEFLAGS
, and had similar problems.
推荐答案
禁用内置规则由的写一个空的规则 .SUFFIXES
:
Disabling the built-in rules is done by writing an empty rule for .SUFFIXES
:
.SUFFIXES:
已经抹去了内置的规则,我不知道该擦除内置变量可以帮助你的不仅仅是记住自己设置它们或不使用它们多得多,但是你可以使用类似
Having erased the built-in rules, I'm not sure that erasing the built-in variables helps you much more than just remembering to set them yourself or not use them, but you could use something like
$(foreach V
$(shell make -p -f/dev/null 2>/dev/null | sed -n '/^[^:#= ]* *=/s/ .*//p'),
$(if $(findstring default,$(origin $V)),$(eval $V=)))
...这是不可否认相当疯狂。如果有一种方法,从化妆中得到定义的变量的列表(而不是炮击了另一个化妆),这将是可行的。由于它是,它不是真的不过如此
...which is admittedly fairly crazy. If there is a way to get a list of the defined variables from within make (instead of shelling out to another make), it would be viable. As it is, it's not really much better than
CC=
CXX=
# etc, for each likely built-in variable
这篇关于禁用内置化妆规则和变量从生成文件内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!