0

I've made minimum reproducible example to learn Makefile syntax but I still receive syntax error

Makefile:16: *** missing separator.  Stop.

I've tried a number of examples but still receive separator error, over and over again

The minimum reproducible example of the Makefile with separator error looks as follows:

TARGET=ice
CC=gcc

SOURCES = \
    src/main.c \
    driver/driver.c \

INCLUDES=\
    -Iinclude \

OBJECTS = $(SOURCES:.c=.o)

all: $(TARGET)

$(TARGET): $(OBJECTS)
    $(CC) -o $@ $^

%.o: %.c
    $(CC) $(INCLUDES) -c $@ -o $<

clean:
    rm $(TARGET)

.PHONY: all good clean


I've made a little progress by writing Makefile in "gedit" rather than "sublime 3"

OK, so the same Makefile syntax but now I have this syntax error

[root][ice] $ make
gcc -Iinclude  -c src/main.o -o src/main.c
gcc: error: src/main.o: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Makefile:19: recipe for target 'src/main.o' failed
make: *** [src/main.o] Error 1

OK I've fixed Just corrected Makefile this way

%.o: %.c
    $(CC) $(INCLUDES) -c -o $@ $<

Thanks for the help

IceMarek
  • 21
  • 2
  • 1
    you need to indent the command lines with TAB, not spaces. The error means you used spaces. – Barmar Apr 07 '23 at 22:22
  • @Barmar I've used Tabs – IceMarek Apr 07 '23 at 22:23
  • If you did you wouldn't get that error. Maybe your editor is converting the tabs to spaces when it saves the file? – Barmar Apr 07 '23 at 22:25
  • @Barmar You are right, I've changed editor from "sublime 3" to "gedit" and now I have syntax error rather than separator. From error I see that object files was not compiled – IceMarek Apr 07 '23 at 22:33

0 Answers0