Hello, world!

This is my first post on DaniWeb, though I have frequented it quite often.

I'm using gcc and make (on Ubuntu 10.10) with GVim for creating a foundation library in C. Within my code I've built in rudimentary profiling and assertion policies that are enabled through a symbolic constant evd_comvar_debug. The appropriate entries in my makefile are as follows:

# compile-time symbolic constants; 'evd' is a namespace
# evd_comvar_ndebug is supposed to switch off debugging
# evd_comvar_debug is supposed to switch on debugging
#
evd_comvar_ndebug = 0
evd_comvar_debug =1

# makefile variable to toggle the debugging option
# in this case, we have chosen to switch on debugging
#
ppd_dbg = evd_comvar_debug

# conditional selection of output directory for the compiled archive
# if debugging is enabled, the compiled archive should be saved in ./lib/dbg
# if debugging is disabled, the compiled archive should be saved in ./lib/rls
#
ifeq ( ${ppd_dbg}, evd_comvar_debug )
   pth_lib = ./lib/dbg
else[ICODE][/ICODE]
   pth_lib = ./lib/rls
endif

# object archive generation
# flg_ar are flags to be passed to 'ar'
# bin_obj specifies the list of objects that have been compiled
#
flg_ar = rvu ${pth_lib}/$@ ${bin_obj}

Now, I have seen that debugging is switched on/off as expected during the compilation process by setting ppd_dbg to evd_comvar_debug or evd_comvar_ndebug. This is OK, as it is the expected behaviour.

My problem is, that no matter what the value of ppd_dbg, the generated archive file is being saved in ./lib/rls. It should be saving in ./lib/dbg if ppd_dbg is set to evd_comvar_debug, but this is not happening.

Any advice would be most welcome.

Thanks in advance.

Why are you mentioning the value ${ppd_dbg} for one variable and not for the other {evd_comvar_debug}. Possibly that is making the ifeq statement false.
Check it out ?

I seem to have figured out the problem. The ifeq block should be as follows:

ifeq (${ppd_dbg},evd_comvar_debug)
   pth_lib = ./lib/dbg
else
   pth_lib = ./lib/rls
endif

The problem was occurring because because of the additional space between the parentheses and the enclosed condition.

It seems that in a makefile, a space should be kept after the ifeq and the left parenthesis, but no space subsequently. Interestingly enough, make does not report an error in case the extra space is encountered.

@kings_mitra: thank you for your reply. The condition ifeq (${ppd_dbg},evd_comvar_debug}) was required as I wanted to ensure that ppd_dbg is set to evd_comvar_debug, and not just its value (which could have been specified through another variable).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.