tags:

views:

37

answers:

1

Hi,

I am starting to learn about Makefiles. Looking at the output I see a lot of occurrences of:

g++ -DHAVE_CONFIG_H -I .....

what is "-DHAVE_CONFIG_H" exactly? What is the function of this compilation option?

Thanks

+1  A: 

All that -DHAVE_CONFIG_H does is to define the pre-processor token HAVE_CONFIG_H exactly as if you had #define HAVE_CONFIG_H right at the start of each of your source files.

As to what it's used for, that depends entirely upon the rest of your source file (and everything that it includes as well). That's where you should be looking for to work out its effect.

It looks like it may mean that a header file config.h is available and should be included, in which case you'll probably find the following sequence somewhere in you source files:

#ifdef HAVE_CONFIG_H
    #include "config.h"
#endif

which will include the header file when you say it's available. However that's supposition on my part and by no means the exact effect, just what I would use such a preprocessor symbol for.

paxdiablo
i understand it know, thanks !
Werner
but the way, what does "DEFS" mean in a Makefile? thanks
Werner
@Werner, depends on the context. If it's "DEFS=-c -O2", that's just defining a substitution that can be used later on so that, for example, "gcc $(DEFS) blah blah" becomes "gcc -c -O2 blah blah".
paxdiablo