01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CH04.fm Page 103 Monday, October 7, 2002 8:54 PM<br />

Introduction to GNU make 103<br />

Since this is one of the most widely used software packages in the development community,<br />

there is a wealth of information available about it on the Internet. This chapter is intended<br />

to provide sufficient information to use make in all types of software projects.<br />

Simply put, make reads a text input file that contains information about how to compile,<br />

link <strong>and</strong> build target files. Make uses comm<strong>and</strong>s <strong>and</strong> rules specified in this file to carry out its<br />

operation. We shall discuss in detail the contents of these files, commonly known as makefiles.<br />

4.1.1 Basic Terminology<br />

Before we move ahead with more information about make <strong>and</strong> how to use it, let us get<br />

familiar with some basic terminology about the software build process <strong>and</strong> the make utility. <strong>The</strong><br />

terms defined below will be used throughout this chapter as well as in the chapters that follow.<br />

Input Files<br />

<strong>The</strong> make utility uses input files to build software projects. <strong>The</strong>se input files, also known<br />

as makefiles, contain information about when <strong>and</strong> how to compile, assemble or link files. <strong>The</strong>se<br />

input files also contain comm<strong>and</strong>s <strong>and</strong> rules to carry out these tasks.<br />

Rules<br />

A rule in an input file provides information about how to build an individual target<br />

(defined next). A rule has three parts:<br />

1. <strong>The</strong> target<br />

2. Dependencies<br />

3. Comm<strong>and</strong>s<br />

A target is rebuilt whenever a dependency file has a timestamp that is newer than the target.<br />

A target may have no dependency, in which case it is always rebuilt. <strong>The</strong> comm<strong>and</strong>s in the rule are<br />

executed to build the target from dependencies. <strong>The</strong> general format of a rule is as follows:<br />

Target: Dependencies<br />

Comm<strong>and</strong>s<br />

<strong>The</strong> comm<strong>and</strong>s part always starts with a TAB character. <strong>The</strong>re are two types of rules that<br />

will be explained later in this chapter. <strong>The</strong>se are types are:<br />

1. <strong>The</strong> explicit rules<br />

2. <strong>The</strong> implicit rules<br />

<strong>The</strong> rules defined above fall into explicit rules category. Implicit rules are predefined rules<br />

that make uses when it does not find an implicit rule to build a target.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!