User forums > General (but related to Code::Blocks)

Setting a variable to be used in Makefile

(1/2) > >>

willkn:
I'm using an external makefile in my project and I'd like to be able to specify the value of variables that can be used in the Makefile, such as with an 'ifeq "$(BLD)" "dbg"    statement. Under 'Build options', I've tried setting the variable in the 'Compiler', 'Other Options' box, the 'Compiler', '#defines' box, and even the 'Custom variables' box, but it looks like none of these values are ever passed to the make program, it seems that they are only given to the compiler (and even there, I wonder).

Any way to specify a variable setting in the build options so that the Makefile can use it?

yop:
How can this happen with an external makefile? Using an external makefile means that you "disable" the cb building functionality and you  use your own...

tiwag:

--- Quote from: yop on December 16, 2005, 09:11:53 am ---How can this happen with an external makefile? Using an external makefile means that you "disable" the cb building functionality and you  use your own...

--- End quote ---
when i was young, this was done by commandline-parameters to make

yop:

--- Quote from: tiwag on December 16, 2005, 10:37:33 am ---when i was young, this was done by commandline-parameters to make
--- End quote ---
Using cb? You mean by changing the build commands (Compilers->Advanced Options etc.)? I don't get it  :oops:

tiwag:

--- Quote from: yop on December 16, 2005, 01:13:32 pm ---...Using cb? You mean by changing the build commands (Compilers->Advanced Options etc.)? I don't get it  :oops:

--- End quote ---

(i don't know if CodeBlocks RC2 had already this feature, i use a recent SVN version)
When you use a custom makefile, you can specifiy for each target the make-commands, see Project->Build-options->"Make" commands

maybe you have two targets in your project, Release and Debug and you use the same makefile, just give it the necessary variable on the commandline. (as willkn described in his post)

you change the "Build project/target" value from $make -f $makefile $target (which is set as default) to whatever you need for your custom makefile.

for example
target  : "Build project/target"
-----------------------
Release :  make BLD=rel
Debug   :  make BLD=dbg

did you get it now?

Navigation

[0] Message Index

[#] Next page

Go to full version