8

While trying to install the som_pak-3.1-NAcMoS.tar.gz file, I've used the below commands:

$ tar xvf som_pak-3.1-NAcMoS.tar.gz
$ cd som_pak-3.1
$ cp makefile.unix makefile
$ make
$ cd ..
$ ln -s som_pak-3.1 $NACMOS_HOME/som_pak

But while executing the make command I'm getting the following error:

* missing separator (did you mean TAB instead of 8 spaces?). Stop.

  • Can anybody tell me the reason for the error?
  • Is there any packages need to include with this?
  • 1
    Where did you download that file from? – Gilles Apr 21 '14 at 23:26
12

The error you're encountering:

*** missing separator (did you mean TAB instead of 8 spaces?). Stop.

Means that the makefile contains spaces instead of Tab's. The make utility is notoriously picky about the use of Space instead of Tab. So it's likely that the makefile contains Space at the beginning of rule stanzas within the file.

Example

Let's say I have the following 3 .c files:

hello.c
char *
hello() 
{
  return "Hello";
}
world.c
char *
world() 
{
  return "world";
}
main.c:
#include <stdio.h>

/* Prototypes. */
char *hello();
char *world();

int
main(int argc, char *argv[]) 
{
    printf("%s, %s!\n", hello(), world());
    return 0;
}    

Say I have the following Makefile:

# The executable 'helloworld' depends on all 3 object files
helloworld: main.o hello.o world.o
        cc -o helloworld main.o hello.o world.o # Line starts with TAB!

# Build main.o (only requires main.c to exist)
main.o: main.c
        cc -c main.c # Line starts with TAB!

# Build hello.o (only requires hello.c to exist)
hello.o: hello.c
        cc -c hello.c # Line starts with TAB!

# Build world.o (only requires world.c to exist)
world.o: world.c
        cc -c world.c # Line starts with TAB!

#  Remove object files, executables (UNIX/Windows), Emacs backup files, 
#+ and core files
clean:
        rm -rf  *.o helloworld *~ *.core core # Line starts with TAB!

Now we try to build a target

When I run it against the target helloworld:

$ make helloworld
makefile:3: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.

Look familiar?

Fixing the issue

You can fix this by changing the Spaces to actual Tab characters. I used vim to repair my file. Simply open it:

$ vim makefile

And then run this command within:

:%s/^[ ]\+/^I/

NOTE: ^I is a special character. Typing ^ followed by I will be interpreted differently compared to Ctrl+V-Ctrl+I.

This will substitute all the lines that begin with 1 or more Spaces with an actual Tab.

Now when I rerun my helloworld target:

$ make helloworld
cc -c main.c # Line starts with TAB!
cc -c hello.c # Line starts with TAB!
cc -c world.c # Line starts with TAB!
cc -o helloworld main.o hello.o world.o # Line starts with TAB!

References

  • I get E486 error pattern not found when I try to use that vim command – Daniel Jacobson Jan 31 '16 at 20:09
  • @DanielJacobson - if you have a new Q please ask it, comments aren't meant for asking new questions. – slm Jan 31 '16 at 20:34
  • ^I just created ^I in the file itself instead of tab – Sun Mar 28 '18 at 17:01
1

As the other answer suggested, Makefiles need tab characters, not space characters. I have my .vimrc set to automatically replace all tabs with spaces, so I have to manually set the reverse setting in individual Makefiles. The vim command that I use is as follows:

:%s/^[ ]\+/\t/g
  • I use this modeline (first line in Makefile) # vim: set noet: – Michael D. Sep 25 '18 at 21:34
0

Note: The correct ways to deal with this particular problem is to correct the Makefile so that each action line of each recipe is indented using a single tab character, and then to submit a patch for it to the original developers.

This is an ugly hack, which work with recent versions of GNU make (if the issue is that the Makefile uses spaces instead of tabs, consistently):

make '.RECIPEPREFIX+='

This will set the special GNU make variable .RECIPEPREFIX to a single space. This variable, since GNU make 3.82 or so (2007), controls the character used for prefixing the action lines of the recipes. If the variable is empty (as it is by default), tabs are used.

Example,

$ cat Makefile
all:
  echo hello
$ make '.RECIPEPREFIX+='
echo hello
hello

Example, showing its use with > (setting the variable inside the Makefile in this case):

$ cat Makefile
.RECIPEPREFIX = >
all:
> echo hello
$ make
echo hello
hello

See also:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.