How similar/different are gnu make, microsoft nmake and posix standard make?

时光毁灭记忆、已成空白 提交于 2019-11-29 11:31:38

问题


How similar/different are gnu make, microsoft nmake and posix standard make?

Obviously there's things like "which OS?", "which compiler?" and "which linker?", but I'm referring specifically to the syntax, semantics and command-line options of the makefiles themselves.

If I write makefiles based on manuals for gnu make, what are the most important portability issues that I need to be aware of?


回答1:


GNU Make and POSIX Make share a common core so that GNU Make understands makefiles intended for POSIX Make and interprets them the same way - with very few exceptions. However, many GNU Makefiles use features that are only available in GNU Make. Sometimes this is deliberate and conscious; sometimes it isn't (and "sometimes isn't" is a problem). I'm less familiar with Microsoft nmake; I believe it is likely to hew close to the POSIX Make semantics at its core, but it will have its own divergent set of extensions.

Generally speaking, what the programs like autoconf produce are close to portable Makefiles.

The main things to be beware of using GNU Make are all the extended function notations for mapping file names (macros) into useful values. While they are undoubtedly useful, they are also a trap for portability.

The '%.x' notations for suffix rules are not defined by POSIX - they are recognized as a common extension:

The interpretation of targets containing the characters '%' and '"' is implementation-defined.



来源:https://stackoverflow.com/questions/2278151/how-similar-different-are-gnu-make-microsoft-nmake-and-posix-standard-make

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!