type | slideOptions | ||||||||
---|---|---|---|---|---|---|---|---|---|
slide |
|
- Explain the basic functionality of makefiles (timestamps, dependencies, update rules).
- Read simple makefiles and know where to look for additional material for complex makefiles.
- Write simple makefiles for small projects.
Introduce Hello-World
example
- A build system
- The / a go-to solution for small (research) projects (e.g., latex document, processing data, ...), though also used in big projects (Linux kernel)
- A building block for CMake
- Nice non-expert introduction in py-RSE book, chapter 9
- GNU Make: standard implementation of Make for Linux and macOS
- When you create / change a file, the OS updates timestamp of file.
- Make compares timestamps to see which files are older / newer than others.
- In
Makefile
:- Rules which file(s) depend on which other file(s)
- Rules how to update out-of-date files
- When you run
make
, Make updates out-of-date files including transitive dependencies in correct order.
- Single rule makefile
- Multiple rules
- Phony targets
- There is more:
- Variables
- Rules
- Wildcards
- ... but becomes quickly very hard to read.
- Not covered because CMake does this for us.
- But nicely documented in py-RSE chapter 9.
- Make is an important build system by itself and an important building block for CMake.
- Make works by checking timestamps and updating outdated files if necessary.
- Each file can be a target. A target has dependencies and an update rule.
make target
updates "target", justmake
updates first target.- Phony targets are empty (helper) targets, not files.
- Always define the standard phony targets
all
andclean
.