Author Topic: Setting a variable to be used in Makefile  (Read 7445 times)

willkn

  • Guest
Setting a variable to be used in Makefile
« on: December 16, 2005, 07:58:08 am »
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?

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Setting a variable to be used in Makefile
« Reply #1 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...
Life would be so much easier if we could just look at the source code.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Setting a variable to be used in Makefile
« Reply #2 on: December 16, 2005, 10:37:33 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...
when i was young, this was done by commandline-parameters to make

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Setting a variable to be used in Makefile
« Reply #3 on: December 16, 2005, 01:13:32 pm »
when i was young, this was done by commandline-parameters to make
Using cb? You mean by changing the build commands (Compilers->Advanced Options etc.)? I don't get it  :oops:
Life would be so much easier if we could just look at the source code.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Setting a variable to be used in Makefile
« Reply #4 on: December 16, 2005, 01:43:52 pm »
...Using cb? You mean by changing the build commands (Compilers->Advanced Options etc.)? I don't get it  :oops:

(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?

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Setting a variable to be used in Makefile
« Reply #5 on: December 16, 2005, 01:58:26 pm »
Yes thanks. I also use the SVN head version, but apparently I didn't notice this functionality
Life would be so much easier if we could just look at the source code.

willkn

  • Guest
Re: Setting a variable to be used in Makefile
« Reply #6 on: December 16, 2005, 03:01:15 pm »
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

I'm using RC2 and don't see this feature. I'll be checking out svn head soon.  When I do, 'Project->Build-options, I get the dialog with 'compiler options', 'linker options', 'directories', 'commands', 'custom variables', but I don't see any place to put a command-line variable definition in front of the 'make' command.