Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.arcetri.astro.it/~lfini/ArtOfmakefile.pdf
Дата изменения: Tue Feb 5 14:29:38 2013
Дата индексирования: Sat Apr 9 23:43:12 2016
Кодировка:

Поисковые слова: п п п п п п п п п п п
The art of Makefile


The use of make is a traditional, simple and effective way to develop programs The make command executes instructions from a Makefile Commands from the file are not necessarily executed sequentially If you use a modern development system (e.g.: Eclipse) you don't need a Makefile
The art of Makefile







Feb. 5, 20013


Program development


You have a main program file: main.c
­

Main.c uses three subprograms


subprog1.c
­ ­

Includes subprog1.h Includes constants.h Includes subprog2.h ... ...



subprog2.c
­ ­



subprog1.c
­



To build the executable you must compile the four source files and link them together
The art of Makefile

Feb. 5, 20013


The Makefile

Feb. 5, 20013

The art of Makefile


Dependency



main.o depends on ...

Feb. 5, 20013

The art of Makefile


Build command

TAB



Command to execute to resolve the dependency

Feb. 5, 20013

The art of Makefile


Processing a Makefile: make


Get the first dependency in Makefile Resolve dependencies recursively:
­



Resolve main.o


Resolve main.c: depends on nothing stop recursion ... If any dependency file is more recent than main.o, rebuild

­ ­

Resolve subprog1.o, etc. .... If any dependency file is more recent than main, rebuild
The art of Makefile

Feb. 5, 20013


Processing a Makefile: make xxx


Any dependency other than the first must be explicitly requested: make clear resolves the following dependency:

Feb. 5, 20013

The art of Makefile


Macros

Feb. 5, 20013

The art of Makefile


Implicit rules, special macros, etc.

Feb. 5, 20013

The art of Makefile


Automatic variables


$< $@ $? ...

The name of the first prerequisite. The file name of the target of the rule.

All the prerequisites newer than the target

Feb. 5, 20013

The art of Makefile


Implicit rules, special macros, etc.

Feb. 5, 20013

The art of Makefile