1

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
CFLAGS=-I$(IDIR)

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.

CC='/buildtools/toolchain/wr-x86/3.0FCScg/bin/i586-wrs-linux-gnu-gcc --sysroot=/buildtools/toolchain/wr-x86/3.0FCScg/sysroot'$
IDIR =../../../include$
CFLAGS=-I$(IDIR)$
$
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
Community
  • 1
  • 1
Sonu Mishra
  • 1,659
  • 4
  • 26
  • 45
  • 4
    The `et` option is the culprit. It is short for `expandtab`--just what you _don't_ want. Remove from your `.vimrc`. Then, reenter the `$(CC)` line in your makefile – Craig Estey Aug 03 '16 at 21:25
  • 1
    @CraigEstey: This makes sense for the asker because they are willing to change their vim configuration. For a lot of users, most of the time the vim configuration is the desired default behavior, but they need an exception for the occasional weird file. – jxh Aug 03 '16 at 21:48
  • 1
    Adding the line `filetype plugin indent on` makes Vim load filetype-specific settings and thus override your own generic settings with sensible ones. – romainl Aug 03 '16 at 21:50
  • @jxh Before there was `.vimrc`, there was the environment variable `EXINIT`. That's what I use/prefer. It solves the problem for weird files because it can be set on a per (e.g.) `xterm` basis. For example, for my own code, I prefer a tabstop of 4 (which I set in `EXINIT` from `.login` or `.bash_profile`). However, for cases when I'm doing a lot of edits for "tab8" files, I open a new `xterm` and I have a shell alias/function that modifies `EXINIT` and sets `ts=8` for that window only (e.g. `t8`) – Craig Estey Aug 03 '16 at 22:09

1 Answers1

2

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.

jxh
  • 69,070
  • 8
  • 110
  • 193