GNU Make - Richard M. Stallman , Roland McGrath - Librairie Eyrolles

Déjà client ? Identifiez-vous

Mot de passe oublié ?

Nouveau client ?

CRÉER VOTRE COMPTE
GNU Make
Ajouter à une liste

Librairie Eyrolles - Paris 5e
Indisponible

GNU Make

GNU Make

Richard M. Stallman, Roland McGrath

174 pages, parution le 01/04/2001

Résumé

The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them. This manual describes GNU make, which was implemented by Richard Stallman and Roland McGrath. Development since Version 3.76 has been handled by Paul D. Smith.

GNU make conforms to section 6.2 of IEEE Standard 1003.2-1992 (POSIX.2).

Our examples show C programs, since they are most common, but you can use make with any programming language whose compiler can be run with a shell command. Indeed, make is not limited to programs. You can use it to describe any task where some files must be updated automatically from others whenever the others change.

To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program and provides commands for updating each file. In a program, typically, the executable file is updated from object files, which are in turn made by compiling source files.

Once a suitable makefile exists, each time you change some source files, this simple shell command: make

suffices to perform all necessary recompilations. The make program uses the makefile data base and the last-modification times of the files to decide which of the files need to be updated. For each of those files, it issues the commands recorded in the data base.

You can provide command line arguments to make to control which files should be recompiled, or how. See section How to Run make.

How to Read This Manual

If you are new to make, or are looking for a general introduction, read the first few sections of each chapter, skipping the later sections. In each chapter, the first few sections contain introductory or general information and the later sections contain specialized or technical information. The exception is section An Introduction to Makefiles, all of which is introductory.

If you are familiar with other make programs, see section Features of GNU make, which lists the enhancements GNU make has, and section Incompatibilities and Missing Features, which explains the few things GNU make lacks that others have.

For a quick summary, see section Summary of Options, section Quick Reference, and section Special Built-in Target Names.

Problems and Bugs

If you have problems with GNU make or think you've found a bug, please report it to the developers; we cannot promise to do anything but we might well want to fix it.

Before reporting a bug, make sure you've actually found a real bug. Carefully reread the documentation and see if it really says you can do what you're trying to do. If it's not clear whether you should be able to do something or not, report that too; it's a bug in the documentation!

Before reporting a bug or trying to fix it yourself, try to isolate it to the smallest possible makefile that reproduces the problem. Then send us the makefile and the exact results make gave you. Also say what you expected to occur; this will help us decide whether the problem was really in the documentation.

Once you've got a precise problem, please send electronic mail to: bug-make@gnu.org

Please include the version number of make you are using. You can get this information with the command 'make --version'. Be sure also to include the type of machine and operating system you are using. If possible, include the contents of the file 'config.h' that is generated by the configuration process.

An Introduction to Makefiles

You need a file called a makefile to tell make what to do. Most often, the makefile tells make how to compile and link a program.

In this chapter, we will discuss a simple makefile that describes how to compile and link a text editor which consists of eight C source files and three header files. The makefile can also tell make how to run miscellaneous commands when explicitly asked (for example, to remove certain files as a clean-up operation). To see a more complex example of a makefile, see section Complex Makefile Example.

When make recompiles the editor, each changed C source file must be recompiled. If a header file has changed, each C source file that includes the header file must be recompiled to be safe. Each compilation produces an object file corresponding to the source file. Finally, if any source file has been recompiled, all the object files, whether newly made or saved from previous compilations, must be linked together to produce the new executable editor.

What a Rule Looks Like

A simple makefile consists of "rules" with the following shape:

A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as 'clean' (see section Phony Targets).

A prerequisite is a file that is used as input to create the target. A target often depends on several files.

A command is an action that make carries out. A rule may have more than one command, each on its own line. Please note: you need to put a tab character at the beginning of every command line! This is an obscurity that catches the unwary.

Usually a command is in a rule with prerequisites and serves to create a target file if any of the prerequisites change. However, the rule that specifies commands for the target need not have prerequisites. For example, the rule containing the delete command associated with the target 'clean' does not have prerequisites.

A rule, then, explains how and when to remake certain files which are the targets of the particular rule. make carries out the commands on the prerequisites to create or update the target. A rule can also explain how and when to carry out an action. See section Writing Rules.

A makefile may contain other text besides rules, but a simple makefile need only contain rules. Rules may look somewhat more complicated than shown in this template, but all fit the pattern more or less.

A Simple Makefile

Here is a straightforward makefile that describes the way an executable file called edit depends on eight object files which, in turn, depend on eight C source and three header files.

In this example, all the C files include 'defs.h', but only those defining editing commands include 'command.h', and only low level files that change the editor buffer include 'buffer.h'.

edit : main.o kbd.o command.o display.o \ main.o : main.c defs.h kbd.o : kbd.c defs.h command.h command.o : command.c defs.h command.h display.o : display.c defs.h buffer.h insert.o : insert.c defs.h buffer.h search.o : search.c defs.h buffer.h files.o : files.c defs.h buffer.h command.h utils.o : utils.c defs.h clean : We split each long line into two lines using backslash-newline; this is like using one long line, but is easier to read....

Contents

  • An Introduction to Makefiles
  • Writing Makefiles
  • Writing Rules
  • Writing the Commands in Rules
  • How to Use Variables
  • Conditional Parts of Makefiles
  • Functions for Transforming Text
  • How to Run make
  • Using Implicit Rules
  • Features of GNU make
  • Incompatibilities and Missing Features
  • Makefile Conventions
  • Quick Reference
  • Errors Generated by Make
  • Complex Makefile Example
  • Index of Concepts
  • Index of Functions, Variables, & Directives

L'auteur - Richard M. Stallman

Mathématicien et informaticien de génie, Richard Matthew Stallman est le fondateur charismatique du mouvement GNU à l'origine du logiciel libre dans les années 1980. Après des études de physique et de mathématiques à l'université de Harvard et au MIT, le célèbre hacker annonce en 1983 le développement du système libre GNU avant de fonder la Free Software Foundation (FSF). Il crée en 1989, avec Eben Moglen, la première version de la licence GNU GPL et est récompensé par la fondation MacArthur en 1990.

Autres livres de Richard M. Stallman

Caractéristiques techniques

  PAPIER
Éditeur(s) Free Software Foundation
Auteur(s) Richard M. Stallman, Roland McGrath
Parution 01/04/2001
Nb. de pages 174
Format 17,8 x 22,8
Couverture Broché
Poids 299g
Intérieur Noir et Blanc
EAN13 9781882114818

Avantages Eyrolles.com

Livraison à partir de 0,01 en France métropolitaine
Paiement en ligne SÉCURISÉ
Livraison dans le monde
Retour sous 15 jours
+ d'un million et demi de livres disponibles
satisfait ou remboursé
Satisfait ou remboursé
Paiement sécurisé
modes de paiement
Paiement à l'expédition
partout dans le monde
Livraison partout dans le monde
Service clients sav@commande.eyrolles.com
librairie française
Librairie française depuis 1925
Recevez nos newsletters
Vous serez régulièrement informé(e) de toutes nos actualités.
Inscription