Author Topic: Custom Makefile + Global Variable = FAIL  (Read 4811 times)

Offline nfm

  • Single posting newcomer
  • *
  • Posts: 2
Custom Makefile + Global Variable = FAIL
« on: July 11, 2011, 04:36:35 pm »
Hey everybody,

I have a problem with the debugger in codeblocks, I'm using latest svn snapshot and I'm on Windows / MinGW. I'm using a custom Makefile with custom CFLAGS. I want codeblocks to run my Makefile this way:
$ DEBUG=1 make -f Makefile

But I can't get the codeblocks to set a variable "DEBUG" to a "1" in any way, why is it so hard? So codeblocks does not respect my DEBUG flag therefore it compiles without -g which makes debugger not work at all. So I compile by hand from minsys shell. Everything goes well, but then when debugging with codeblocks, how can I view the contents of variables? Do I really have to type "$(varname)" in the memory window all time, why is it so hard and tedious, is there any way to double click? There just should be a separate window for showing stuff like that.

Thanks.



[attachment deleted by admin]
« Last Edit: July 11, 2011, 05:46:56 pm by nfm »

Offline ouch

  • Almost regular
  • **
  • Posts: 223
Re: Custom Makefile + Global Variable = FAIL
« Reply #1 on: July 11, 2011, 08:31:52 pm »
Shouldn't the debug flag be set after calling make and not before?

also you can set a watch to view variable contents. (right click on the variable and select watch)

Offline nfm

  • Single posting newcomer
  • *
  • Posts: 2
Re: Custom Makefile + Global Variable = FAIL
« Reply #2 on: July 11, 2011, 10:39:55 pm »
DEBUG=1 should be set before make executes Makefile, so it sets debugging flags before compiling, take a look at the screenshot, or better:
Code
DBGFLAGS = -g -O0
ifdef DEBUG
    CFLAGS = $(DBGFLAGS) -Wall -std=c99
else
    CFLAGS = -Wall -std=c99 -O2 -march=native -mtune=native
endif

My point is that either setting up environment/global/temporary variables is broken in codeblocks or it is very hard to do.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Custom Makefile + Global Variable = FAIL
« Reply #3 on: July 11, 2011, 11:03:22 pm »
I just tested it here on linux with a wxWidgets sample makefile, and no matter whether I set it before or after the make-command it works as expected.

But as I see, you have a "real" Debug-target in your makefile, why do you not set the flags here ?