← Cheat Sheets
Makefile Basics
Targets, variables and automatic variables.
# Makefile Basics
Targets, variables and automatic variables.
```make
CC = gcc
.PHONY: all clean test
all: app
app: main.o util.o
$(CC) -o $@ $^
%.o: %.c
$(CC) -c $< -o $@
test:
./run_tests.sh
clean:
rm -f *.o app
```
Recipes must be indented with a **tab**. `$@` target, `$<` first prerequisite, `$^` all prerequisites, `.PHONY` marks targets that are not files.