Eddie Monge Jr
Eddie Monge Jr

Reputation: 12730

Variables based on targets in Makefile

when creating a Makefile, im trying to figure out how(if) i can change a variable based on the target.

So something likes this:

VER = $(if target=release then 1.0.0 elseif target=nightly then 20110411)

nightly:
    @@echo ${VER} >> version.txt

release:
    @@echo ${VER} >> version.txt

Upvotes: 1

Views: 1223

Answers (1)

Ise Wisteria
Ise Wisteria

Reputation: 11669

If your make is GNU make, Target-Specific Variable is allowed.
For example, in your question's case, the following definitions will meet the purpose:

nightly: VER = 20110411
release: VER = 1.0.0

nightly:
    @echo ${VER}

release:
    @echo ${VER}

Hope this helps

Upvotes: 6

Related Questions