How do I code a Makefile that can tell the difference between Intel OS X and Linux?
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开发者_如何学Python 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
精彩评论