Ordered by how often each one turns out to be the answer.
A recipe line is indented with spaces, not a tab
CommonAn editor, a paste from a web page or a formatter replaced the tab with spaces.
Confirm
cat -et Makefile | sed -n 'LINEp'
The reported line starting with spaces instead of ^I
Fix
- Replace the leading spaces with one tab, in an editor that shows whitespace.
- Stop it recurring: in .editorconfig, add a [Makefile] section with indent_style = tab.
A merge-conflict marker was left in the file
OccasionalA line such as <<<<<<< HEAD, ======= or >>>>>>> branch is not valid Makefile syntax.
Confirm
grep -nE '^(<<<<<<<|=======|>>>>>>>)' Makefile
Any line printed: an unresolved conflict
Fix
- Resolve the conflict properly, keep the lines you meant, and delete the markers.
Shell code is written outside a recipe
OccasionalA shell if, for loop or command at the top level of the Makefile is read as Makefile syntax, which it is not.
Confirm
sed -n 'LINEp' Makefile
A shell command at the reported line that is not under a target
Fix
- Move it into a recipe under a target, indented with a tab, or use make's own syntax (ifeq, $(shell …)) for decisions at the top level.
.RECIPEPREFIX is not supported by the make that runs it
RareGNU Make 3.82 and later let you choose another recipe prefix with .RECIPEPREFIX. macOS ships GNU Make 3.81, which ignores it, so every recipe line then fails.
Confirm
make --version | head -1
GNU Make 3.81 with a Makefile that sets .RECIPEPREFIX
Fix
- Use tabs, which every make understands, or install a newer GNU make and call it explicitly (on macOS with Homebrew it is gmake).