[SOLVED] Having custom variables in Makefile
-
Sorry, it seems that the code highlighter is not working exactly the same when you are editing the answer and once it's re-loaded.
I've fixed it. Please take a look again, it's already working for environment variables.
-
Sam, I am bit confused.
If I understand correctly,
Having your code,
TESTSTR = '\\"$\\"' DEFINES += TEST=\"$\"
Should I need to add my environment variable here?
Example:TSTR = '\\"$(BOOST_PATH)\\"' DEFINES += TEST=$${TSTR}
Makefile looks like this:
-DTEST=\"$(BOOST_PATH)\"
Or I understood wrongly?
Please clarify. Thank you very much for your kind help..
--Kumara
-
Sorry again about the code formatting…
Trying again here:
TESTSTR = '\\"$$(TEST)\\"'
DEFINES += TEST=\"\$\$\{TESTSTR\}\"
On that last line remove the backslashes before the dollar signs and curly braces...
-
I did try the exact as you said..
STRT = '\\"$(BOOST_PATH)\\"'
DEFINES += BOOST_PATH=\"\$\$\{STRT\}\"
And the output is,
-DBOOST_PATH="$${STRT}"
And I tried removing the back slashes on dollar sign and curly braces
STRT = '\\"$(BOOST_PATH)\\"'
DEFINES += BOOST_PATH=\"$${STRT}\"
And the output is
-DBOOST_PATH="\"$(BOOST_PATH)\""
Still no success..
--Kumara
-
What do you get for the various variable if you show a message with their content:
e.g.
message($$(BOOST_PATH))
message(\$\$\{STRT\})
?Again, remove the backslashes in the second line...
-
While printing a message, it looks good.
message($(BOOST_PATH))
Project MESSAGE: /path/to/boost
message($${STRT})
Project MESSAGE: \"/path/to/boost\"
But why this has not been taken to Makefile? Mysteries..
-
Then you are likely just missing some escaping for the last call...
-
Finally found a way to write it:
BOOST = $ $ ( BOOST_PATH ) BOOST_STR = ' \ \ " $ $ { BOOST } \ \ " ' DEFINES += BOOST_PATH= \ " $ $ { BOOST_STR } \ "
Extra spaces to be removed for the sample code
-
Thanks Sam, for helping me to fix the problem.
I do confirm that, it works.
(I do not want copy the instruction again here, which contains more spaces :P)
With the above code, I can see this in my Makefile
-DBOO_PATH="/path/to/boost"
It has been a great help! Thanks a lot.
--Kumara
-
Later to that,
I have figured out a problem in having:
We need to have \" in the argument:
-DBOO_PATH="/path/to/boost"
Problem is that, the macro turned out to be
#define BOO_PATH /path/to/boost
which is actually useless. We need to have double quotes to cover them up.BOOST = $ $ ( BOOST_PATH ) BOOST_STR = ' \ \ " $ $ { BOOST } \ \ " ' DEFINES += BOOST_PATH=\ " $ $ { BOOST_STR } \"
Again, eliminate the spaces :)