GNU Makefile, detect architecture

江枫思渺然 提交于 2019-12-05 11:40:40

In GNU make syntax $() dereferences a variable. You rather want a shell command:

uname_p := $(shell uname -p) # store the output of the command in a variable

And then:

ifeq ($(uname_p),i386)

Alternative to multi-level ifeq using computed variable names. Here is a working makefile I used on my system:

uname_s := $(shell uname -s)
$(info uname_s=$(uname_s))
uname_m := $(shell uname -m)
$(info uname_m=$(uname_m))

# system specific variables, add more here    
INCDIR.Linux.x86_64 := -I../../x64
INCDIR.Linux.i386 := -I../../x32

INCDIR += $(INCDIR.$(uname_s).$(uname_m))
$(info INCDIR=$(INCDIR))

Which produces the following output:

$ make 
uname_s=Linux
uname_m=x86_64
INCDIR=-I../../x64
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!