Gnu make - GNU Makefile detect architecture

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I want to autodetect system architecture, when i compile my program under freebsd and i want 2 includes for x64 and x32 but don t work, i tried like this :

ifeq ($(uname -a),i386)
INCDIR += -I../../x32
else
INCDIR += -I../../x64
endif

What is wrong here? When i compile on amd64 work with code below. When i compile on i388 don t work.

When i compile on amd64 with code below the makefile see x64 dir. When i compile on i386 with code below the makefile see x64 dir. Soo bassicaly that else don t have any effect  ?

Answers

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)

https://www.gnu.org/software/make/manual/make.html#Computed-Names https://www.gnu.org/software/make/manual/make.html#Computed-Names

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

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/36628165/gnu-makefile-detect-architecture

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils