Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of -DHAVE_CONFIG_H in makefiles

Tags:

makefile

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?

like image 817
Open the way Avatar asked Mar 13 '10 12:03

Open the way


People also ask

What is meant by in makefile?

A makefile is a file that results from using the "make" processing tool, a tool used in software development to build a program in its final ".exe" file extension form together with its libraries. The make tool performs an interpretation process of make files to determine the final code of the destination .exe file.

What does $@ mean in makefiles?

The file name of the target of the rule. If the target is an archive member, then ' $@ ' is the name of the archive file. In a pattern rule that has multiple targets (see Introduction to Pattern Rules), ' $@ ' is the name of whichever target caused the rule's recipe to be run. $%

What does AT symbol do in makefile?

The @ symbol is commonly seen at the beginning of an action lines and means that the action line itself is not be be echoed on the screen as it is executed. Macros are commonly used in makefiles to decrease the amount of typing required.

What type of files are makefiles?

The makefile is a text file that contains the recipe for building your program. It usually resides in the same directory as the sources, and it is usually called Makefile . Each one of these commands should be a separate rule in a makefile.


1 Answers

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.

like image 68
paxdiablo Avatar answered Sep 20 '22 00:09

paxdiablo