-1

I know there are other issues with similar titles, but they don't seem to hold the solution.

Heres my makefile:

# Compiler Command
CC = mpiCC
CFLAGS = -c -I./header

# collecting object file names
src = $(wildcard source/*.cpp)
src1 = $(src:.cpp=.o)

objects := $(src1:source/%=bin/%)

# Compile object files into binary
all : $(objects)
    $(CC) -o run $(objects)
ifneq($(n),)                         // <- error location , line 15
    mpirun -np $(n) run
endif

# Generate object files by compiling .cpp and .h files
bin/%.o : source/%.cpp
    $(CC) $(CFLAGS) $?
    mv *.o bin

# Clean Recipe
.PHONY : clean
clean : 
    rm -rf all $(objects)

The goal of the ifneq is to have the binary run whenever it finishes compiling. for example, a user runs the command:

make <- builds without running

make n=5 <- builds and runs on 5 processes

Whenever I use either of these, I get the error: makefile:15: *** missing separator. Stop.

I've used cat -e -t -v to verify everything is tabbed instead of spaced. according to (https://www.gnu.org/software/make/manual/make.html#Conditional-Example) this conditional should function.

3
  • You must have a space between ifneq and its argument. You can't run them together. May 20, 2022 at 16:19
  • dang, should have seen that. Thanks for pointing that out! May 20, 2022 at 16:23
  • You could have pared this down to half a dozen lines that still reproduced the error. And with a working example of ineq from the documentation, you could have pasted together a working makefile that did everything your failing makefile tried to do. And you could have edited these two toward each other until there was literally no difference except that space.
    – Beta
    May 20, 2022 at 16:41

1 Answer 1

0

@MadScientist solved it. You need to put a space in between ifneq and its argument. For example:

ifneq($(n),0) is invalid. ifneq ($(n),0) is valid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.