view raw
Sonu Mishra Sonu Mishra - 9 months ago 77
Linux Question

Unable to debug the makefile. Makefile:9: *** missing separator. Stop

I have written the following Makefile:

CC='/buildtools/toolchain/wr-x86/3.0FCScg/bin/i586-wrs-linux-gnu-gcc --sysroot=/buildtools/toolchain/wr-x86/3.0FCScg/sysroot'
IDIR =../../../include

LDIR =../../../../../../../../.debug/lib.out/public/
LIBS= -lmylib1 -lmylib2 -lmylib3

myexec: my_code.c
$(CC) $(CFLAGS) -o myexec my_code.c

It throws error:

Makefile:9: *** missing separator. Stop

I looked at a related question here. It says there can a problem with a tab. I double checked the code. I am using a tab and not spaces. However when I run

cat -e -t -v Makefile

I get the following, that implies there is no tab before

CC='/buildtools/toolchain/wr-x86/3.0FCScg/bin/i586-wrs-linux-gnu-gcc --sysroot=/buildtools/toolchain/wr-x86/3.0FCScg/sysroot'$
IDIR =../../../include$
LDIR =../../../../../../../../.debug/lib.out/public/$
LIBS= -lmylib1 -lmylib2 -lmylib3$
myexec: my_code.c$
$(CC) $(CFLAGS) -o myexec my_code.c$

I also checked my .vimrc file. I have
set tabstop=4
. I tried removing this, but it rather made the situation worse. It started giving me error:
Makefile:9: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.

This is how it looks:

syntax on
colorscheme desert
set nocompatible
set number
set backspace=indent,eol,start
set autoindent
set ruler
set spell
set title
set et
set mouse=v
set history=100
set tabstop=4

jxh jxh

There is something in your vim initializations that prevents correct editing of the Makefile. It appears to be et, which is the abbreviation for the expandtab setting, which causes each tab character to be expanded to the appropriate number of space characters. (Thanks to Craig Estey for confirming this.)

However, you can tell vim to not use your init file by using -u NONE:

vim -u NONE Makefile

With that, you should be able to edit in the needed tab character.

Alternatively, you can add this to the bottom of your .vimrc:

:autocmd FileType make set noet

which will disable expandtab behavior whenever you edit a Makefile.