A solid reference for writing and debugging Makefiles in C/C++ projects. Covers the essentials: pattern rules, automatic variables like $@ and $<, and automatic dependency generation with -MMD so header changes actually trigger rebuilds. The examples are practical, starting from a minimal correct Makefile and building up to multi-directory projects without recursive make. Includes a debugging table for common errors like "missing separator" and "nothing to be done." Useful if you're converting shell scripts to proper build systems or fixing incremental builds that keep recompiling everything. The flat Makefile approach for medium projects is good advice that people often learn the hard way.
- skills.sh installs
- 697
- GitHub stars
- 279
- last updated
- Aug 21, 2026
Install
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill make --agent claude-codeInstalls into .claude/skills of the current project.
Files
GNU Make
Purpose
Guide agents through idiomatic Makefile patterns for C/C++ projects: phony targets, pattern rules, automatic dependency generation, and common build idioms.
Triggers
- "How do I write a Makefile for my C project?"
- "My Makefile rebuilds everything every time"
- "How do I add dependency tracking to Make?"
- "What does
$@,$<,$^mean?" - "I'm getting 'make: Nothing to be done for all'"
- "How do I convert my shell compile script to a Makefile?"
Workflow
1. Minimal correct Makefile for C
CC := gcc
CFLAGS := -std=c11 -Wall -Wextra -g -O2
LDFLAGS :=
LDLIBS :=
SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:src/%.c=build/%.o)
TARGET := build/prog
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
build/%.o: src/%.c | build
$(CC) $(CFLAGS) -c -o $@ $<
build:
mkdir -p build
clean:
rm -rf build
Automatic variables:
$@— target name$<— first prerequisite$^— all prerequisites (deduplicated)$*— stem (the%part in a pattern rule)$(@D)— directory part of$@
2. Automatic dependency generation
Sponsors
Details
- Repository
- github.com/mohitmishra786/low-level-dev-skills
- Categories
- DevOps & CI/CD, Documentation, Debugging
- First seen
- Jun 3, 2026
More from mohitmishra786/low-level-dev-skills
All 54- Memory Model693
- Freertos691
- Linux Kernel Modules689
- Ninja681
- Heaptrack676
- Rust Profiling673
- Ebpf672
- Msvc Cl671
- Fuzzing670
- Binutils665
- Linkers Lto663
- Conan Vcpkg659
- Dynamic Linking650
- Rust Security624
- Rust Ffi613
- Rust Unsafe611
- Pgo610
- Interpreters609
- Cargo Workflows608
- Rust Sanitizers Miri604
- Meson603
- Cpp Modules597
- Rust Debugging597
- Hardware Counters590
