[SOLVED] make: *** No rule to make target 'rm', needed by 'clean' or Makefile:27: *** missing separator

Issue

hi i have problem when i try to use this command "make fclean" can you help me ?
the makefile return me "Makefile:27: *** missing separator" if I don’t put "" behind "clean:" but when i’m put this, he return : "make: *** No rule to make target ‘rm’, needed by ‘clean’"

##
## **** PROJECT, 2022
## Makefile
## File description:
## Makefile that build the project
##

SRC =       ./main.c    \
            ./calc.c

OBJ = $(SRC:.c=.o)

NAME = fakeProj

CFLAGS = -ftest-coverage -O2

BCK_DIR = backup

CC = clang

all: $(NAME)

$(NAME):    $(OBJ)
    $(CC) -o $(NAME) $(OBJ)

clean:
      rm -f $(OBJ)

fclean: clean     \
      rm -f $(NAME)

re: fclean  all

# .PHONY: all clean fclean re


Solution

Remove your stray backslash:

fclean: clean     \
        rm -f $(NAME)

By adding a backslash at the end of this line, make treats it like:

fclean: clean rm -f $(NAME)

(e.g., these are all prerequisites of the fclean target)

Answered By – MadScientist

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.