Reputation: 55
I have a makefile including the following lines:
buildrepo:
@$(call make-repo)
define make-repo
for dir in $(C_SRCS_DIR); \
do \
mkdir -p $(OBJDIR)/$$dir; \
done
endef
On the line with the commands for dir in $(C_SRCS_DIR); \
I get the following error message:
"dir not expected at this moment"
make: *** [buildrepo] Error 255
I am using GNU make
.
Can anybody tell me what is going wrong?
Upvotes: 2
Views: 64
Reputation: 1933
Actually this for ... in ... ; do ... done
statement is a Unix command not a GNU make command, therefore I guess you are using a Windows machine (or any other one). You have to find the equivalent for your system.
But GNU make has a foreach function which works like this :
$(foreach dir,$(C_SRCS_DIR),mkdir -p $(OBJDIR)/$(dir);)
Also note that in your very specific case (not related to GNU make but to Windows) you can create all the dirs without a for/foreach loop, just like this :
mkdir -p $(addprefix $(OBJDIR)/,$(C_SRCS_DIR))
Upvotes: 1