0

Works:

make -f Makefile.custom CFLAGS="-DFLAG_ONE -DFLAG_TWO" clean target

What does not work is

FLAGS="-DFLAG_ONE -DFLAG_TWO"
make -f Makefile.custom CFLAGS=$FLAGS clean target

Error: It starts to think that -D is an argument to make and fails.

Tried: Using escape characters

FLAGS="\"-DFLAG_ONE -DFLAG_TWO\""

Any help would be appreciated.

--UPDATE--

This is a workaround but the question still remains open.

CFLAGS="-DFLAG_ONE -DFLAG_TWO"
export CFLAGS
make -f Makefile.custom clean target

2 Answers 2

1

Quoting is necessary:

FLAGS="-DFLAG_ONE -DFLAG_TWO"
make -f Makefile.custom CFLAGS="$FLAGS" clean target
Sign up to request clarification or add additional context in comments.

Comments

1
CFLAGS="-DFLAG_ONE -DFLAG_TWO" make -f Makefile.custom clean target

And simple Makefile:

all:
        echo ${CFLAGS}

...will print:

-DFLAG_ONE -DFLAG_TWO

...thus it does work.

3 Comments

it says -DFLAG_TWO not found
@PravinCG If this does not work for you, most likely you are using csh or tcsh. In that case, you must either stop using csh (recommended) or use env: env CFLAGS=... make ...
@PravinCG Or you are omitting the double quotes on the value you are attempting to assign to CFLAGS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.