How to encode a Makefile that can distinguish between Intel OS X and Linux?

How to write a conditional expression in the GNU makefile, which in this case recognizes the architecture (Intel OS X vs Linux) so that I can set the flags correctly without requiring the end user to specify the Makefile when make -f run?

EDIT

I must indicate that I get a makefile from an ifeq statement that contains a shell command if this condition is placed outside the target:

'commands commence before first target. Stop.'

+6
source share
2 answers

You can check the output of one of the uname options, and then choose different actions with the makefile depending on this.

Run man uname for details.

In terms of your use of GNU make, you can get the information in a variable from the shell function, and then use ifeq for that variable:

 platform=$(shell uname -o) ifeq ($(platform),Cygwin) defrule: echo I am running in Cygwin. else defrule: echo I am running elsewhere. endif 
+10
source

uname is your friend.

 $ uname -o GNU/Linux 
+1
source

Source: https://habr.com/ru/post/891783/


All Articles