docs.kde.org
Build Systems
Prev
Next

Build Systems

Except in very simple cases a programming project will consist of a lot of building blocks of source code each put into a separate file for easier maintenance. To make this running one has to effectively translate all this stuff into a few machine language units in a suiting format which allows the operating system to load and execute the program.

To accomplish this, the basic tools needed are

When you have a large project consisting of possibly hundreds of source code files, the process of compiling may become quite laborsome. You do not want to recompile all files each time you have changed only some of them. Instead, you only want to compile those files which are affected by the changes. In general, it is not always easily obvious which of the files have to be recompiled.

When you e.g. change a function prototype in a header file, you need to compile every file which includes this header file. If your project contains many such files you may easily miss one or two of them if you have to do the job manually. Thus some means of automization is necessary.

The Make Process

A tool which takes care of recompilations is make. It keeps track of all work using a set of rules which describe what to do in case some piece of information (usually a source or object code file) was changed. All rules belonging to a certain project are stored in a so-called Makefile which is processed by make any time you want to update your work.

Each rule consists of several building blocks, namely

  • a target, i.e. the file to be built

  • a set of dependencies, basically the names of those files the target depends on (e.g. the name of a source file, where then the target will be the name of the object file to be built) and

  • the commands which are to be executed to “make” the target (i.e. to compile it or to link other object files together to build an executable progam file).

Basically the make command will read the rules one after another, check each file in the dependency list of a given target and make this target anew if any one of these files has changed, using the commands listed in that rule.

There are several additional possibilities to control such a make process, and a Makefile can thus grow very complex. We cannot go into the details here. However, we recommend that you make yourself accustomed to the syntax of make. Even if you do not normally use it directly, an understanding of the fundamentals of the build system can be useful. See the GNU Make Manual for more information.

For more KDevelop specific detail see the Building and Project Management chapter of this manual.

There are several tutorials available, see the references in the Building and project management chapter.

Prev
Next
Home


docs.kde.org