Search code examples
buildmakefilegnugnu-make

Disable make builtin rules and variables from inside the make file


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.


Solution

  • You could start the Makefile with a #! and call it something different so people don't try to use make directly:

    #!/usr/bin/make -rRf
    # ...
    

    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.