função definir no makefile
Eu tenho a exibição da estrutura de pastas do projeto de teste:
TOPDIR
├── a
│ └── a.c
├── b
│ └── b.c
├── c
│ └── c.c
└── makefile
Eu escrevi um makefile de teste:
CC := gcc
LD := ld
MAKE_DIR = $(PWD)
MODULES := a b c
SRC_DIR := $(addprefix ${MAKE_DIR}/,$(MODULES))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
OBJ := $(patsubst %.c,%.o,$(SRC))
INCLUDES := $(addprefix -I,$(SRC_DIR))
vpath %.c $(SRC_DIR)
define make-goal
$1/%.o: %.c
$(CC) $(INCLUDES) -c $< -o $@
endef
all:
$(foreach sdir,$(SRC_DIR),$(eval $(call make-goal,$(sdir))))
durante o make, ele parou e mostra:
makefile:37: *** prerequisites cannot be defined in command scripts. Stop.
a linha 37 é:
$(foreach sdir,$(SRC_DIR),$(eval $(call make-goal,$(sdir))))
o que há de errado com meu makefile?