>_ IzzyLab

Hands-on task

This task is step 1 of the course “Make: builds and automation”

First Makefile: the build target

easy~3 min

The /root/proj directory contains the source file main.c. Write a Makefile (in that same directory) with a build target that builds the program — in practice, it just copies main.c into a file named app. After make build, a file named app must appear in the directory, with contents identical to main.c. The Makefile is handy to write in the Editor tab above the terminal: in a Makefile it puts a real TAB at the start of a recipe line.

What you'll practise:
  • make
  • makefile
  • targets and recipes
  • tab syntax
  • build

Topic breakdown

A Makefile describes a build with a set of rules: the line target: names a target, and the recipe lines below it are the commands make runs when that target is requested. The one hard rule of the syntax: every recipe line must begin with a tab character, not spaces, or make fails with missing separator. A specific target is run with make <name>.

What's checked

  1. make build creates app
  2. app matches main.c

What it looks like