views:

735

answers:

5

Hi guys...

I have a makefile (provided by third party) which gives the following error

Makefile:108: *** missing separator.  Stop.

The line in question is the following if statement.... any ideas? have tried various replacing tabs with spaces and not got very far at all...

if have_sdl
        libiulib_a_SOURCES += $(srcdir)/utils/dgraphics.cc
        libiulib_a_SOURCES += $(srcdir)/utils/SDL_lines.cc
        include_HEADERS += $(srcdir)/utils/SDL_lines.h
else
        libiulib_a_SOURCES += $(srcdir)/utils/dgraphics_nosdl.cc
endif
+1  A: 

If I remember correctly, the makefile-mode in emacs highlights whitespace syntax errors with red. Try loading the Makefile in emacs to see if the error is obvious.

Steven
+1  A: 

IIRC (it's been a while) that if/else is a GNU makeism. If you are not running GNU make then this may well fail. Solution is to install GNU make.

Dean Povey
Yes - it is laden with GNU make-isms and not using GNU make would come up with that error.
Jonathan Leffler
+1  A: 

Try it this way:

ifneq ($(have_sdl),)
        libiulib_a_SOURCES += $(srcdir)/utils/dgraphics.cc
        libiulib_a_SOURCES += $(srcdir)/utils/SDL_lines.cc
        include_HEADERS += $(srcdir)/utils/SDL_lines.h
else
        libiulib_a_SOURCES += $(srcdir)/utils/dgraphics_nosdl.cc
endif

This checks if have_sdl is non empty (meaning defined to TRUE, yes, 1 or something other than empty string)

Aleksei Potov
A: 

I have seen problems like this caused by blank lines that aren't blank - they contain tabs or spaces. Clearing out all whitespace on the blank lines may solve it.

Edited to add: Upon rereading your question, I see that this may not be your particular problem given the line number and code you posted, but it could be a problem for others so I will leave my answer.

Graeme Perrow
+2  A: 

I am not aware of any make dialect that allows if keyword. The code you cited is neither POSIX make, nor GNU make.

Examples of working syntax include:

ifdef have_sdl
... (rest is the same)

and

ifneq ($(have_sdl),)  #not equal to empty string
... (rest is the same)

.

Pavel Shved