3 ms·
To expand on this, the de facto comprehensive standard for Makefile variables is the GNU standard, if only because there is no other widely used, consistent con
by wahern 3y ago
To expand on this, the de facto comprehensive standard for Makefile variables is the GNU standard, if only because there is no other widely used, consistent convention beyond the very small number of POSIX-defined built-in variables. The GNU project blazed the trail for portable, generic build conventions. The GNU Makefile Conventions are documented at https://www.gnu.org/prep/standards/standards.html#Makefile-Conventions https://www.gnu.org/prep/standards/standards.html#Makefile-C... In practice there's a wider set of variable conventions based on or baked into GNU Make and Autotools. See, e.g. https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html https://www.gnu.org/software/make/manual/html_node/Implicit-...
A long time ago I put together my own little summary of applied GNU'ish conventions. See https://25thandClement.com/~william/cuda/Makefile.md.html https://25thandClement.com/~william/cuda/Makefile.md.html Notably I specified LIBS instead of LDLIBS. These days I use LDLIBS. I forget why I listed LIBS, but there is some ambiguity and consistency across GNU tools. For example, pkg-config sort of ignored or simplified some older conventions (e.g. dropping CPPFLAGS and making CFLAGS do double duty) which IME wasn't for the better, at least if applied outside the domain of what pkg-config is used for.
Why use these conventions? Because such variables and their semantics will be useful for package maintainers, who won't need to spend as much time learning some bespoke convention and who often have templates for working with GNU-like builds, even when autotools aren't being used. Because they reflect decades of experience in how to write builds that in 80% of odd circumstances (including development, non-production environments) can be controlled without modifying the build rules directly. Relatedly, they're often the minimum necessary abstraction for cross-compiling (though alone not always sufficient).