Introduction to GNU make103
Since this is one of the most widely used software packages in the development commu-
nity, there is a wealth of information available about it on the Internet. This chapter is intended
to provide sufficient information to use
make
in all types of software projects.
Simply put,
make
reads a text input file that contains information about how to compile,
link and build target files.
Make
uses commands and rules specified in this file to carry out its
operation. We shall discuss in detail the contents of these files, commonly known as
makefiles
.
4.1.1Basic Terminology
Before we move ahead with more information about
make
and how to use it, let us get
familiar with some basic terminology about the software build process and the
make
utility. The
terms defined below will be used throughout this chapter as well as in the chapters that follow.
Input Files
The
make
utility uses input files to build software projects. These input files, also known
as
makefiles
, contain information about when and how to compile, assemble or link files. These
input files also contain commands and rules to carry out these tasks.
Rules
A rule in an input file provides information about how to build an individual target
(defined next). A rule has three parts:
1.
The target
2.
Dependencies
3.
Commands
A target is rebuilt whenever a dependency file has a timestamp that is newer than the target.
A target may have no dependency, in which case it is always rebuilt. The commands in the rule are
executed to build the target from dependencies. The general format of a rule is as follows:
Target: Dependencies
Commands
The commands part always starts with a TAB character. There are two types of rules that
will be explained later in this chapter. These are types are:
1.
The explicit rules
2.
The implicit rules
The rules defined above fall into explicit rules category. Implicit rules are predefined rules
that
make
uses when it does not find an implicit rule to build a target.
Next Page >>
<< Previous Page
Back to the Table of Contents