Linux Basics Practice Test: Makefile — Flashcards | Linux | FatSkills

Linux Basics Practice Test: Makefile — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

A Makefile is a text file that contains rules that tell Linux's make utility how to build an application. The rules are made up of three parts:
Target: The file or thing that must be made
Prerequisites: The files that must exist before the target can be created
Commands: The shell commands that will create the target from the prerequisites 

The basic syntax for a Makefile is: target, dependencies, and commands. 

The dependency line in a Makefile has two parts:
Target files:
The first part of the dependency line, before the colon
Source files: The second part of the dependency line, after the colon 
Multiple target files must be separated by a space. 

Here's an example of a Makefile that describes how an executable file called edit depends on eight object files: 
edit : main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o cc -o edit main.o 
 
To execute the commands in the makefile, type make in the directory containing the makefile. 
You can create a makefile using nano, vim, vi, gedit, cat, and other tools. The name of the file must either be “Makefile” or “makefile”.

1 of 19 Ready
What is makefile?
makefile describes to the make command that how to compile the program
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password