{"enrichment":{"faq":[{"a":"make is a build automation tool that compiles C/C++ projects by defining rules and dependencies. Start by listing your source files, object files, and the final executable. Use pattern rules like `%.o: %.c` to compile each `.c` file to `.o`, and link them together. Define variables for `CC`, `CFLAGS`, and `LDFLAGS` to keep commands consistent. Always mark non-file targets (like `clean`, `all`) as `.PHONY` to prevent conflicts with actual files. A minimal Makefile includes a main target, object file rules, and a clean rule.","q":"How do I write a Makefile for a C project?"},{"a":"make provides automatic variables to simplify rule writing. `$@` expands to the target filename, `$<` expands to the first prerequisite, and `$^` expands to all prerequisites (space-separated). For example, in `program: main.o util.o`, the rule `$(CC) $^ -o $@` becomes `gcc main.o util.o -o program`. These variables eliminate repetition and make pattern rules work correctly across different targets.","q":"What do the special variables $@, $<, and $^ mean in make?"},{"a":"make supports automatic dependency generation to detect when header files change. Use `gcc -MM` to generate `.d` dependency files listing which headers each `.c` file includes. Add a rule like `%.d: %.c` that runs `$(CC) -MM $< > $@`, then include those files with `-include *.d` at the end of your Makefile. This ensures rebuilds trigger when any included header changes, eliminating the \"header change not detected\" problem.","q":"How can I add automatic dependency tracking to my Makefile?"},{"a":"make rebuilds when prerequisites are missing or newer than targets. Common causes: missing dependency files (use automatic dependency generation), phony targets not marked `.PHONY` (causing false rebuilds), or timestamps corrupted by version control. Verify your pattern rules use `$@`, `$<`, and `$^` correctly. Check that `.PHONY` declarations appear before their rules. If headers aren't tracked, implement automatic dependency generation with `gcc -MM` and `-include *.d`.","q":"Why does my Makefile rebuild everything every time I run it?"},{"a":"make requires recipe lines (commands under rules) to start with a literal tab character, not spaces. The error \"missing separator\" signals you used spaces instead. In your editor, ensure tab insertion is enabled when editing Makefiles. Most editors have a setting to show whitespace or force tabs in Makefile mode. If copying from documentation, re-type the indentation manually. This is a frequent source of frustration but easily fixed by checking your editor's tab/space settings.","q":"What does the 'missing separator' error mean and how do I fix it?"},{"a":"make supports multi-directory projects through recursive make or flat structures. For recursive make, create a Makefile in each subdirectory and call them from a top-level Makefile using `$(MAKE) -C subdir`. For flat structures, use vpath or explicit paths like `src/%.o: src/%.c` to locate sources. Flat Makefiles scale better and avoid re-invocation overhead. Define `VPATH` or use pattern rules with directory prefixes to locate source and object files consistently across your project tree.","q":"How do I organize a multi-directory C project with make?"}],"shadow_tags":["build-automation","c-cpp-compilation","incremental-builds","dependency-tracking","makefile-patterns","build-configuration","project-structure","compiler-flags","parallel-execution"],"summary_rewrite":"This skill guides you through building maintainable Makefiles for C/C++ using phony targets, pattern rules, and automatic dependency tracking. Learn to structure multi-file projects, manage compiler flags, diagnose rebuild issues, and convert ad-hoc compile commands into robust build systems."},"files":[{"bytes":4819,"path":"skills/build-systems/make/SKILL.md","sha256":"ff3b6cf0c164d6e707bced06deae27b2128b42157342c482e5869592f1473daf","url":"https://skillfed.io/files/mohitmishra786/low-level-dev-skills/make/e4b111dc/SKILL.md"}],"id":"mohitmishra786/low-level-dev-skills/make","links":{"html":"https://skillfed.io/mohitmishra786/low-level-dev-skills/make","md":"https://skillfed.io/mohitmishra786/low-level-dev-skills/make.md","repo":"https://github.com/mohitmishra786/low-level-dev-skills"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":19,"language":"JavaScript","last_updated":"2026-06-27","license":"MIT","name":"make","publisher":"mohitmishra786","stars":148},"relations":{"similar":[{"id":"akin-ozer/cc-devops-skills/makefile-generator"},{"id":"itechmeat/llm-code/makefile"},{"id":"LeoKemp223/embed-ai-tool/build-makefile"},{"id":"plinde/claude-plugins/makefile-best-practices"},{"id":"oldwinter/skills/justfile"},{"id":"akin-ozer/cc-devops-skills/makefile-validator"},{"id":"mohitmishra786/low-level-dev-skills/ninja"},{"id":"mohitmishra786/low-level-dev-skills/stm32-baremetal"},{"id":"mohitmishra786/low-level-dev-skills/resource-optimization-lowend"},{"id":"Goldziher/ai-rulez/cgo-bindings"}]},"slug":{"owner":"mohitmishra786","repo":"low-level-dev-skills","skill":"make"},"version":"e4b111dc"}
