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.
I've found several references to using MAKEFLAGS
, and had similar problems.
This works for me:
Put this in a file named disable_implicit_rules.mk and
include
it in every makefile.https://www.gnu.org/software/make/manual/make.html#Canceling-Rules
@hseldon has the right idea because .SUFFIXES doesn't cover the match-everything built-in implicit rules. However, I don't think his syntax is exactly right.
See http://www.gnu.org/software/make/manual/make.html#Match_002dAnything-Rules and http://www.gnu.org/software/make/manual/make.html#index-g_t_002eSUFFIXES-998
You could start the
Makefile
with a#!
and call it something different so people don't try to usemake
directly:This will cause horrific problems if GNU make is not the system
make
. Maybe a wrapper script?You can also read
$(MAKEFLAGS)
and make sure the required flags are present.Disabling the built-in rules is done by writing an empty rule for
.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
...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