Problem with Makefile ifeq

I am trying to use ifeq in my rule template and I am having problems with it. This is the rule I'm having problems with:

$(OBJS): $(OBJDIR)/%.o : ../%.c @mkdir -p $(dir $@ ) ifeq(mcc.exe,$(CC)) o_file:=$(shell echo $@ | sed -e 's/\/cygdrive\///' | sed -e 's/\([a-zA-Z]\)/\1:/') $(CC) $(CFLAGS) $< -o $(o_file) else $(CC) $(CFLAGS) $< -o $@ endif 

When I run this, I get:

 "/bin/sh: -c: line 0: syntax error near unexpected token `mcc.exe,mcc.exe' /bin/sh: -c: line 0: `ifeq(mcc.exe,mcc.exe)'" 

But, when I do not use indentation, I get: "Makefile: 77: * missing separator. Stop."

I am using GNU make 3.81 on Cygwin. The whole problem with ifeq comes from the fact that I have the same Makefile for the two tool chains, and one of them (mcc.exe) cannot handle the path /cygdrive/c/.../something, but should instead be c: /.../ something way. If you know any other way around this, I would also be very grateful!

Thank you in advance!

+7
source share
1 answer

Lines containing ifeq... , else and endif must not begin with a tab. If they do, they are considered part of the recipe and sent to the shell; this results in a syntax error that you get from / bin / sh; see user manual for an example.

I'm not quite sure why you get an error when you are not indenting. Perhaps you cannot define a variable in a recipe like this?

Edit: I see you found the answer. Thus, there is no indentation or space between ifeq and parenthesis.

+10
source

All Articles