345

I am getting the following error running make:

Makefile:168: *** missing separator.  Stop.

What is causing this?

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
Renjith G
  • 6,307
  • 9
  • 27
  • 26
  • 3
    Does this answer your question? [makefile:4: \*\*\* missing separator. Stop](https://stackoverflow.com/questions/16931770/makefile4-missing-separator-stop) – S.S. Anne Apr 07 '20 at 20:45
  • There are lots of comments about "bad error message". But, this message `missing separator` is just make's version of a generic _syntax error_, or "I have no idea what the heck you are trying to do here". It's not really feasible to provide a better error because make can't figure out what this line is supposed to be. Make's parser works with "separators": if it finds a `=` then it's a variable assignment, if it finds a `:` then it's a rule, if it starts with a TAB (or `.RECIPEPREFIX` character) it's a recipe. If none of those things then... it has no idea. – MadScientist Jan 10 '23 at 13:50

14 Answers14

528

As indicated in the online manual, the most common cause for that error is that lines are indented with spaces when make expects tab characters.

Correct

target: 
\tcmd

where \t is TAB (U+0009)

Wrong

target:
....cmd

where each . represents a SPACE (U+0020).

Neuron
  • 5,141
  • 5
  • 38
  • 59
dfa
  • 114,442
  • 31
  • 189
  • 228
  • 9
    You can use .RECIPEPREFIX to change the character make uses. See: https://www.gnu.org/software/make/manual/html_node/Special-Variables.html#Special-Variables – aseq Dec 01 '16 at 09:31
  • To confirm, I just ran into this myself. Most editors/IDEs can help spot this. For example, in IDEA, go to the View menu, choose "Active Editor", "Show Whitespaces". I can't believe that spaces vs. tabs is still a thing in (checks notes) 2022. – cpurdy May 27 '22 at 15:41
  • I had a string variable that contained newlines - not by choice. Snuck in via `execute_process`, fixed with `OUTPUT_STRIP_TRAILING_WHITESPACE` seeing as the output is single-line. Infuriatingly bad error message though – Zoe Nov 20 '22 at 01:16
23

Just for grins, and in case somebody else runs into a similar error:

I got the infamous "missing separator" error because I had invoked a rule defining a function as

($eval $(call function,args))

rather than

$(eval $(call function,args))

i.e. ($ rather than $(.

Wolf
  • 9,679
  • 7
  • 62
  • 108
Krazy Glew
  • 7,210
  • 2
  • 49
  • 62
9

This is a syntax error in your Makefile. It's quite hard to be more specific than that, without seeing the file itself, or relevant portion(s) thereof.

unwind
  • 391,730
  • 64
  • 469
  • 606
7

For me, the problem was that I had some end-of-line # ... comments embedded within a define ... endef multi-line variable definition. Removing the comments made the problem go away.

Hugues
  • 2,865
  • 1
  • 27
  • 39
  • Thank you. I didn't know comments in `define` directive are treated literally. Actually the behavior is **not** explain in [the documentation](https://www.gnu.org/software/make/manual/make.html#Multi_002dLine). (For clarity: Embedding a number sign `#` within the directive isn't itself a syntax error. But it is just not interpreted as a start of a comment, so doing that is admittedly error-prone.) – ynn Nov 05 '19 at 10:48
5

My error was on a variable declaration line with a multi-line extension. I have a trailing space after the "\" which made that an invalid line continuation.

MY_VAR = \
   val1 \ <-- 0x20 there caused the error.
   val2
JHarveyJr
  • 51
  • 1
  • 4
5

In my case, this error was caused by the lack of a mere space. I had this if block in my makefile:

if($(METHOD),opt)
CFLAGS=
endif

which should have been:

if ($(METHOD),opt)
CFLAGS=
endif

with a space after if.

Hashimoto
  • 306
  • 4
  • 8
5

In my case, I was actually missing a tab in between ifeq and the command on the next line. No spaces were there to begin with.

ifeq ($(wildcard $DIR_FILE), )
cd $FOLDER; cp -f $DIR_FILE.tpl $DIR_FILE.xs;
endif

Should have been:

ifeq ($(wildcard $DIR_FILE), )
<tab>cd $FOLDER; cp -f $DIR_FILE.tpl $DIR_FILE.xs;
endif

Note the <tab> is an actual tab character

Nena
  • 681
  • 1
  • 10
  • 27
3

In my case error caused next. I've tried to execute commands globally i.e outside of any target.

UPD. To run command globally one must be properly formed. For example command

ln -sf ../../user/curl/$SRC_NAME ./$SRC_NAME

would become:

$(shell ln -sf ../../user/curl/$(SRC_NAME) ./$(SRC_NAME))
yuliskov
  • 1,379
  • 15
  • 16
2

In my case, the same error was caused because colon: was missing at end as in staging.deploy:. So note that it can be easy syntax mistake.

Pratik
  • 959
  • 1
  • 14
  • 20
1

I had the missing separator file in Makefiles generated by qmake. I was porting Qt code to a different platform. I didn't have QMAKESPEC nor MAKE set. Here's the link I found the answer:

https://forum.qt.io/topic/3783/missing-separator-error-in-makefile/5

JulieC
  • 192
  • 11
1

Just to add yet another reason this can show up:

$(eval VALUE)

is not valid and will produce a "missing separator" error.

$(eval IDENTIFIER=VALUE)

is acceptable. This sort of error showed up for me when I had an macro defined with define and tried to do

define SOME_MACRO
... some expression ...
endef

VAR=$(eval $(call SOME_MACRO,arg))

where the macro did not evaluate to an assignment.

Simon Rose
  • 381
  • 5
  • 11
1

I had this because I had no colon after PHONY

Not this,

.PHONY install
install:
    install -m0755 bin/ytdl-clean /usr/local/bin

But this (notice the colon)

.PHONY: install
...
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
-2

Following Makefile code worked:

obj-m = hello.o

all:
    $(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 

clean:
    $(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
josliber
  • 43,891
  • 12
  • 98
  • 133
-3

So apparently, all I needed was the "build-essential" package, then to run autoconf first, which made the Makefile.pre.in, then the ./configure then the make which works perfectly...

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140