user2808264
user2808264

Reputation: 569

Makefile:Missing Separator

I am trying to build a new makefile but I encountered an error, the code for the same makefile is below:

ifeq($(ARCH),bbb)
    $(CC)=arm-linux-gnueabi-gcc
else ifeq($(ARCH),frdm)
    $(CC)=arm-none-eabi-gcc
else
    $(CC)=gcc
endif

CFLAGS=-c
CFLAG=-o

all:memory.o data.o proj_1.o main.o
    $(CC) memory.o data.o proj_1.o main.o  $(CFLAG) main

main.o: main.c
    $(CC) main.c $(CFLAGS)

memory.o: memory.c
$(CC) memory.c $(CFLAGS)

data.o:data.c
    $(CC) data.c $(CFLAGS)

proj_1.o:proj_1.c
    $(CC) proj_1.c $(CFLAGS)

clean: 
    rm -rf *o

The error message is

test.mk:1: *** missing separator.  Stop.

Can someone point out what I am doing incorrectly?

Thanks

Upvotes: 0

Views: 249

Answers (2)

user657267
user657267

Reputation: 21000

You need a space between ifeq and ( / ' / ".

Your entire makefile can be simplified to the following, make already knows how to do most of what you've written.

ifeq ($(ARCH),bbb)
prefix := arm-linux-gnueabi-
else ifeq ($(ARCH),frdm)
prefix := arm-none-eabi-
endif

CC := $(prefix)$(CC)

objects := memory.o data.o proj_1.o main.o

main: $(objects)
clean: ; $(RM) $(objects) main

Upvotes: 1

acornagl
acornagl

Reputation: 521

The space between ifeq and the ( bracket is missing. The GNU documentation explains the syntax here.

Upvotes: 1

Related Questions