views:

259

answers:

1

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?

+2  A: 

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.

Jonathan Leffler
I have run into aix make program couple times. Yuck. It is strictly POSIX or is it something else standard-wise?
aaa
@unknown: it is fairly close to POSIX Make - somewhere between that and one of the System V make programs. POSIX Make is pretty much a common subset of the various make variants.
Jonathan Leffler