GNU Make 4 · Rules and targets

Create a folder before building

An order-only prerequisite (after |) must exist but doesn't force a rebuild.

build/%.o: src/%.c | build
	$(CC) -c $< -o $@

build:
	mkdir -p build

Official GNU Make 4 documentation

More rules and targets commands

All rules and targets commands · GNU Make 4 cheatsheet

Was this page helpful?