From 8cd1f1b183b1bc0d7aaa9b6b8e67e4c52ab560bc Mon Sep 17 00:00:00 2001 From: narnaud Date: Wed, 4 May 2022 14:16:33 +0200 Subject: [PATCH] fix: Makefile portability --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0a19b58..5d140a2 100755 --- a/Makefile +++ b/Makefile @@ -3,10 +3,15 @@ LIBFT = libft.a SRCS = minishell.c lexer.c parser.c utils.c caller.c built-in.c env.c OBJS = ${SRCS:.c=.o} -#READLINE_INC = ~/.brew/opt/readline/include -#LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft -LIB = -lreadline -lhistory -L. -lft +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S), Linux) + LIB = -lreadline -lhistory -L. -lft +endif +ifeq ($(UNAME_S), Darwin) + READLINE_INC = -I ~/.brew/opt/readline/include + LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft +endif $(NAME): $(LIBFT) $(OBJS) gcc ${OBJS} ${LIB} -o ${NAME} @@ -18,7 +23,7 @@ $(LIBFT): all: $(NAME) %.o: %.c - gcc -Werror -Wextra -Wall -g -c $< # -I ${READLINE_INC} #for rl_replace_line + gcc -Werror -Wextra -Wall -g -c $< ${READLINE_INC} clean: rm -rf ${OBJS}