36

I am facing errors in make file in CentOS 6.02 64 bit. I need to know what should be done to make the makefile workable. Any suggestion will be greatly helpful. My make file is pasted below: -

#



.SUFFIXES: .cc $(.SUFFIXES)



ALL = libpal.a



#all = $(ALL)

all: $(ALL)



.cpp.o:

            $(C++) -o $@ -c $(PROF) $(CFLAGS) $*.cpp

.cc.o:

            $(C++) -o $@ -c $(PROF) $(CFLAGS) $*.cc

.c.o:

            $(CC) -o $@ -c $(PROF) $(CFLAGS) $*.c



top_srcdir = ..

OPENSSL_LIB_DIR = ../../ThirdPartyLibs/openssl-0.9.8e/include
BOOST_DIR = ../../ThirdPartyLibs/boost/stage/lib

BOOST_INCLUDE_DIR = ../../ThirdPartyLibs/boost





CC = gcc

C++ = g++

CCOPT = -Os -Wall -Wno-deprecated

CCOPT_DEBUG = -Wall -g -Wno-deprecated

PROF = 



STATIC = -static





INCLUDE = \
 -I./usr/include/sys

 -I./Headers \

 -I$(top_srcdir)/PAL/Headers \

 -I$(top_srcdir)/BaseMulti/Headers \

 -I$(top_srcdir)/NetworkMulti/Headers \

 -I$(top_srcdir)/RTP/Headers \

 -I$(BOOST_INCLUDE_DIR) \

 -I$(OPENSSL_LIB_DIR) \



LIBDIRS = \

    -L$(BOOST_DIR) \





#XXX NLAYER define / MB_DEBUG

DEFINE =  -D_LINUX -DDEBUGLOG -D_INDENT_DB_PRINT -fsigned-char -fno-inline -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PER_PROCESS_TIMER_SOURCE -D_PTHREADS -DUNICODE #-DDISABLE_LOG



SHLIB_SUFFIX   = .so

SHLIB_LD       = gcc -shared

SHLIB_LD_LIBS  = 

SHLIB_CFLAGS   = -fPIC



BFLAGS = $(DEFINE) $(INCLUDE)

CFLAGS = $(CCOPT) $(BFLAGS)



OBJ_C =



OBJ_CC = \

    ./Sources/PALsystime.o \

    ./Sources/PALdebug.o \

    ./Sources/PALdebuglog.o \

    ./Sources/PALthread.o \

    ./Sources/PALcritsec.o \

    ./Sources/PALprofiler.o \

    ./Sources/PALserializable.o \

    ./Sources/PALinet.o \

    ./Sources/PALnetwork.o \

    ./Sources/PALsocket.o \

    ./Sources/PALlocalhostUdpEvent.o \

    ./Sources/PALpollarray.o \

    ./Sources/PALrandom.o \



OBJS = $(OBJ_C) $(OBJ_CC) 



SRCS = $(OBJ_C:.o=.c) $(OBJ_CC:.o=.cc)



debug: DEFINE += -DDEBUG

debug: BFLAGS = $(DEFINE) $(INCLUDE)

debug: CFLAGS = $(CCOPT_DEBUG) $(BFLAGS)

debug: $(OBJS)

    ar crsu libpal_debug.a $(OBJS)



libpal.a: $(OBJS)

    ar crsu libpal.a $(OBJS)



cleandeps:  

    $(RM) ./Sources/*.o .depend* core



clean: cleandeps    

    $(RM) ./libpal.a ./libpal_debug.a

    $(RM) $(ALL)

And the resultant error is:

Makefile:34: *** missing separator.  Stop.
Naseef Chowdhury
  • 2,357
  • 3
  • 28
  • 52

3 Answers3

49

You can find an explanation of this error in Appendix B Errors Generated by Make.

Every line in a recipe must begin with a tab character. The recipes starting with $(C++) and $(CC) near the top of your file do not seem to start with a tab character.

Additionally, the section

INCLUDE = \
    -I./usr/include/sys
    -I./Headers \

seems to be missing a backslash after sys and that same section (and many more) have superfluous empty lines.

Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69
  • Do you get the exact same error? If yes, which line exactly is line 34? By the way, you should remove some of the superfluous empty lines. Also, the line `-I./usr/include/sys` seems to miss a backslash and others have an extra backslash – Reinier Torenbeek Jan 29 '13 at 07:05
  • Did you remove the empty lines? – Reinier Torenbeek Jan 29 '13 at 07:17
  • Friendly note to people using Sublime Text, make sure you have tab set as shown in this [question](http://stackoverflow.com/questions/9575739/how-to-replace-four-spaces-with-a-tab-in-sublime-text-2). Double check your text-editor settings. Also make sure your Makefile is in the right directory (although if it was in the wrong directory it'd throw a different error). – aug Jul 24 '14 at 18:58
  • When copy/pasting from one makefile to another using the vi (or vim) editor be sure not to accidentally grab the ~ (tilde) line indicating end of file. A real ~ looks like a vi marker and will cause the "*** missing separator. Stop." error. This may seem obvious but when it happens accidentally it's far from evident. See [my blog commentary](http://skycoast.us/pscott/archives/000071.html) for more information. – Scott Feb 26 '16 at 00:48
26

Open your make file in vim rather than in editors like gedit. Every line in a recipe must begin with a tab character.

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
  • 7
    +1 simple and direct. And *of course* I have my vim configured to tab with two spaces (0x20) instead of a tab. Had to look up an ASCII table to find the relevant control character (0x09, or ^I since 'I' is the 9th character in the alphabet). So for anyone else in a similar situation, an easy way to insert a tab in vim is via ^V^I (Ctrl-V, Ctrl-I) while in insert mode. Also, I have to ask who's *brilliant* idea it was to force you to use tabs. Even python isn't that strict with whitespace :P – Braden Best Jan 03 '14 at 08:01
  • 1
    @BradenBest `make` does not force you to use tabs, it is just the default character used to indicate the start of a recipe. If you do not like that, just set `.RECIPEPREFIX` to a different value. Of course, nobody will understand how to deal with your `makefile` anymore but you just force them to read [the documentation](https://www.gnu.org/software/make/manual/html_node/Special-Variables.html) :-). – Reinier Torenbeek Feb 26 '16 at 06:08
7

This answer is for other Make newbies such as myself who find this question from Googling and get stuck because they are modifying a large pre-existing Makefile, with no lines beginning with a space character. My problem occurred because a makefile in a subdirectory with spaces instead of tabs was getting called by a parent makefile, where I erroneously thought the problem existed.

Once I fixed the makefile in the subdirectory, everything worked like a charm.

entpnerd
  • 10,049
  • 8
  • 47
  • 68