Restricting GNU‑Make to POSIX Make behaviour

gnu-makemake

Is there a known way to make Linux's make reject unintended use of GNU‑Make specific extensions in Makefile when editing or using other's Makefile in Linux? I mean, restricting GNU‑Make to behave as the make specified in POSIX and reject any GNU‑Make specific extensions?

The .POSIX special target is not enough, according to “4.9 Special Built-in Target Names (gnu.org)”. The man page does not mention a command line option for this.

Using another make utility may be an option.

— Update 2018-10-19 —

I still have not found a direct answer to my question, but here is at least a document about this issue, a document which did not exist at the time I had this question: A Tutorial on Portable Makefiles (nullprogram.com).

Best Answer

I'm pretty sure that there is no way to disable GNU make extensions. The .POSIX target improves the compatibility but does not disable compatible extensions such as functions, proprietary dot targets, % patterns in targets, etc.

I don't know of any make implementation that sticks to POSIX features. For example MINIX, Solaris, OpenBSD all have their own extensions. You could at least try to build your programs with these four implementations (assuming that your programs do build on all these platforms), which will give you a pretty good portability assurance in practice. Add Windows with the make utility from Visual Studio, plus a port of some Unix shell tools, if you can use a non-free OS (I think there's a free version of VS that would be enough).