PDA

View Full Version : [Makefile] Costanti


Unrue
17-04-2008, 16:48
Ciao ragazzi,
una domanda bovina sulle costanti nel Makefile. Ho tra le mani un Makefile in cui la costante definita è seguita da un punto interrogativo:

MPICC?=mpicc

E poi è espansa come:

$(MPICC)

quindi, a cosa serve quel punto interrogativo?:confused: Non si poteva definire senza?

andbin
17-04-2008, 17:06
quindi, a cosa serve quel punto interrogativo?:confused: Non si poteva definire senza?Dal manuale (http://www.gnu.org/software/make/manual/make.html) del make:

There is another assignment operator for variables, `?='. This is called a conditional variable assignment operator, because it only has an effect if the variable is not yet defined. This statement:

FOO ?= bar

is exactly equivalent to this (see The origin Function):

ifeq ($(origin FOO), undefined)
FOO = bar
endif