Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extraneous text after `else' directive

First

I reference gnu make manual 3.81, because my version is 3.81 (make --v)

section 7.2

conditional-directive
text-if-one-is-true
else conditional-directive
text-if-true
else
text-if-false
endif

so my makefile

  version=ag101p


  ifeq ($(version),ag101p)
  ag101p:ag101p.o zigbee.o
    cc -o $@ $(CFLAGS) $^
  else ifeq($(version),test)
    @echo "test"
  else
  CFLAGS += -DM2C
  m2c:m2c.o zigbee.o
    cc -o $@ $(CFLAGS) $^
  endif

  .PHONY:clean
  clean:CLL
    rm -rf *.o ag101p m2c
  CLL:

but console display

Makefile:7: Extraneous text after `else' directive

like image 884
nylon Avatar asked Jan 13 '16 08:01

nylon


1 Answers

By adding a space between "else ifeq" and "(" works on linux platform. But on windows it won't work. I fix this on windows by adding anther endif make the "if else" nested.

ifeq ($(version),ag101p)
  ag101p:ag101p.o zigbee.o
    cc -o $@ $(CFLAGS) $^
else
ifeq ($(version),test)
    @echo "test"
else
  CFLAGS += -DM2C
  m2c:m2c.o zigbee.o
    cc -o $@ $(CFLAGS) $^
endif
endif

  .PHONY:clean
  clean:CLL
    rm -rf *.o ag101p m2c
  CLL:
like image 157
MichaelWang Avatar answered Sep 19 '22 07:09

MichaelWang