How do I write a conditional into a GNU make
Makefile, which discerns the architecture (Intel OS X vs Linux, in this case) so that I can set flags appropriately, without requiring the end user to specify the Makefile when running make -f
?
EDIT
I should specify that I get a makefile error from an ifeq
statement that contains a shell command, if this conditional is placed outside a target:
'commands commence before first target. Stop.'
You should be able to check the output of one of the uname
variants, and then choose different actions withing the makefile
depending on that.
Run man uname
for details.
In terms of how you use it from GNU make, you can get the information into a variable from the shell
function and then use ifeq
on that variable:
platform=$(shell uname -o)
ifeq ($(platform),Cygwin)
defrule:
echo I am running in Cygwin.
else
defrule:
echo I am running elsewhere.
endif
uname
is your friend.
$ uname -o
GNU/Linux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With