A makefile is used with the UNIX make utility to determine which portions of a program to compile. A makefile is basically a script that guides the make utility to choose the appropriate program files that are to be compiled and linked together.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
The make utility keeps track of the last time files were updated so that it only updates the files containing changes. However, all of the files that are dependent on the updated files must be compiled as well, which can be very time-consuming. With the help of makefile, the make utility automates this compilation to ensure that all files that have been updated - and only those - are compiled and that the most recent versions of files are the ones linked to the main program, without requiring the user to perform the tasks separately.
A makefile contains three types of information for the make program: a target (the name of what the user is trying to construct); the rules (commands that tell how to construct the target from the sources) and a dependency (the reason that the target should be constructed, which is usually because it is out of date in respect to its components). To create a makefile, the user makes a file containing shell commands and names it "makefile." The commands are executed according to the rules in the makefile when the user types "make" while in the directory containing the file.