workshops/slides/makefiles/makefiles.md

1.0 KiB

title author theme colortheme
Making Makefiles
Malin
Warsaw
orchid

Intro

  • input, process, output.
  • automatic idempotence
  • Gotcha: directories
  • This, that, and these

Variables

  • From your shell.
  • New variables.
  • Filenames as variables.
  • Gotcha: no shell variables, only make!

Equality

  • Variables with '=', never ':='.
  • Gotcha: one shell per line.
  • Variables as shell output.

Phonies, and the Problems with Lies

  • clean (common)
  • check (excellent)

Non-Compiling Checks

  • make -n
  • Gotcha: shell output variables.

The Fourth Sigil: %

  • Standard rules, e.g. ImageMagick, copying, et c.
  • Gotcha: intermediaries are deleted.

Bling: make2graph

  • Gotcha: completely outdated.

Inclusivity

  • include dir/Makefile
  • Gotcha: directory has not changed
  • $(MAKEFILE_LIST)

Special Commands

  • dirname
  • DIR = test -d $(dirname $@) || mkdir $(dirname $@)
  • patsubst
  • Wildcards (or not?)

Maintanance

  • backups
  • saving files