

The make command uses the makefile to determine the order in which the targets have to be made and the correct sequence of rules to invoke. Often, other intermediate targets have to be created before the final target can be made. The makefile is read by the make command, which determines the target file or files that are to be made and then compares the dates and times of the source files to decide which rules need to be invoked to construct the target.

Typically, the target is a single executable file.
#Write makefile for c program how to#
The rules describe how to create the target from the dependent files.

A dependency has a target (a file to be created) and a set of source files upon which it is dependent.
#Write makefile for c program install#
It’s often used not only to control the compilation of source code, but also to prepare manual pages and to install the application into a target directory.Ī makefile consists of a set of dependencies and rules. The combination of the make command and a makefile provides a very powerful tool for managing projects. Indeed, if you have a large project, you may choose to manage it using separate makefiles for different parts of the project. You can have many different makefiles on your machine at any one time. The makefile most often resides in the same directory as the other source files for the project. You must provide a file that tells make how your application is constructed.This file is called the makefile. Although, as you will see, the make command has a lot of built-in knowledge, it can’t know how to build your application all by itself.
