Change Makefile variable value

Posted by paulgray on Stack Overflow See other posts from Stack Overflow or by paulgray
Published on 2010-04-26T08:21:26Z Indexed on 2010/04/26 8:23 UTC
Read the original article Hit count: 271

Filed under:
|

Is there a way to reassign Makefile variable value inside of the target body?

What I am trying to do is to add some extra flags for debug compilation:

%.erl: %.beam
    $(ERLC) $(ERLFLAGS) -o ebin $<

test: clean debug_compile_flag compile compile_test

debug_compile:
    $(ERLCFLAGS) += -DTEST

So if I invoke test target I would like to clean up my environment, add some new flags (like -DTEST to the existing ones), compile the whole code once again (first sources, then test modules).

I do not want to copy/paste the code for compiling with some new flags set since there is a lot of logic put here and there.

Is there some easy way to redefine the variable value so I can reuse the existing code?

© Stack Overflow or respective owner

Related posts about makefile

Related posts about target