user1293997
user1293997

Reputation: 895

Missing Separator Make Error

$(foreach name, $(patsubst lib%.a,%,$(LIBS)), \
          $(eval lib$(name).a : lib$(name).a($$($(name)_OBJS))))

Make fails in the above line saying missing separator.

:68: *** missing separator.  Stop.

Upvotes: 0

Views: 887

Answers (1)

Beta
Beta

Reputation: 99154

From the GNUMake manual:

To specify several members in the same archive, you can write all the member names together between the parentheses. For example:

 foolib(hack.o kludge.o)

is equivalent to:

 foolib(hack.o) foolib(kludge.o)

However this doesn't seem to apply to prerequisites (GNUMake 3.8.2):

# This works:
     flib: foolib(hack.o) foolib(kludge.o)

# This doesn't:
     flib: foolib(hack.o kludge.o)

So we just need a small modification (using @Neil's shortcut and some careful handling of parentheses):

# Change this:
$(foreach name, $(LIBS:lib%.a=%), \
  $(eval lib$(name).a : lib$(name).a($$($(name)_OBJS))))


# to this:
lparen := (
rparen := )

$(foreach name, $(LIBS:lib%.a=%), \
  $(eval lib$(name).a : $($(name)_OBJS:%=lib$(name).a$(lparen)%$(rparen))))

Upvotes: 1

Related Questions