>_ IzzyLab

Hands-on task

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

Makefile with targets

easy~5 min

Write a /root/Makefile with three targets: build (prints building), test (prints testing), clean (prints cleaning). Verify that make build works. The Makefile is easiest to write in the Editor tab above the terminal: in a Makefile it puts a TAB at the start of a recipe line by itself.

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

Topic breakdown

A Makefile is a set of rules of the form target: dependencies, and the following lines are the recipe made of commands. The main classic trap: every recipe line must start with a TAB character, not spaces, otherwise make fails with missing separator (cat -A helps check for a real tab — it shows ^I). Targets that have no files with matching names are considered unbuilt by make and run on every invocation — for action targets that's normal, and strictly this is later locked in via .PHONY.

What's checked

  1. make build works
  2. make test works
  3. make clean works

What it looks like