I need to compile my .c files into a .a library. The problem is that on MacOS the makefile works fine and on Linux it gives the following error when doing the make "Makefile:38: *** empty variable name. Stop."
These are my .c
SRCS = ft_memset.c ft_bzero.c ft_memcpy.c ft_memccpy.c ft_memmove.c\
ft_memchr.c ft_memcmp.c ft_strlen.c ft_strlcpy.c ft_strlcat.c\
ft_strchr.c ft_strrchr.c ft_strnstr.c ft_strncmp.c ft_atoi.c\
ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c\
ft_toupper.c ft_tolower.c ft_calloc.c ft_strdup.c\
ft_substr.c ft_strjoin.c ft_strtrim.c ft_split.c ft_itoa.c\
ft_strmapi.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c\
ft_putnbr_fd.c\
SRCS_BONUS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c\
ft_lstadd_back.c ft_lstdelone.c ft_lstclear.c ft_lstiter.c\
ft_lstmap.c\
Then the compilation rules to generate the objects, with the flags and the compiler
OBJS = ${SRCS:.c=.o}
OBJS_BONUS = ${SRCS_BONUS:.c=.o}
NAME = libft.a
CC = cc
RM = rm -f
CFLAGS = -Wall -Wextra -Werror
This rule is the one that gives me the error saying that it is empty when in MacOS it compiles perfectly (I am currently with Linux Mint 19.3 Updated)
.c.o: =
@${CC} ${FLAGS} -c $< -o ${<:.c=.o}
And else
$(NAME): ${OBJS}
ar rc ${NAME} ${OBJS}
ranlib ${NAME}
bonus: ${OBJS} ${OBJS_BONUS}
ar rc ${NAME} ${OBJS} ${OBJS_BONUS}
ranlib ${NAME}
all: ${NAME}
clean:
${RM} ${OBJS} ${OBJS_BONUS}
fclean: clean
${RM} ${NAME}
re: fclean bonus
.PHONY: clean fclean all re bonus
The error is the '=' that you put, since when you put '=' you say that it is a variable, but what is in front of it is not a variable name, but the name of a .oc rule: and between this and the '=' is nothing.
The solution would be:
To make make not show the commands being executed, you can use the " -s -> --silent, --quiet " option of the form " make -s "
I don't know why on MacOS it works for you. It may be another version of Make.