I have a (from my point of view) rather complicated Makefile.
That is mostly because I wanted colors there and other unnecessary things.
Anyway, might I jump right into my question:
Apart from Linux I newly support *BSD, thus I need to check for the platform in use on several places. Is conditional variable assignment possible in a Makefile? Something like:
platform := [ $$(uname) = Linux ] && echo Linux || echo BSD or other
Of course this does not work, but hopefully, you get my point.
I need a solution, that works both with the BSD make
, and the GNU make
.
The
!=
shell assignment operator is apparently supported on both BSD and GNU make:Note that the assignments are really evaluated by the shell: it is the result of this evaluation that gets assigned to the make variables, not the shell commands.
Solution that requires GNU make. It works with GNU make on BSD, but not with BSD make.
One possibility is to use the
if
GNU make function:Another one is to rely only on the shell conditionals:
The GNU make conditionals can also be used: