Browse Source

Better Makefile

master
narnaud 3 years ago
parent
commit
3b2e60240d
  1. 37
      Makefile
  2. 20
      libft/Makefile

37
Makefile

@ -14,31 +14,34 @@ ifeq ($(UNAME_S), Darwin)
LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft
endif endif
all: $(NAME)
$(VERBOSE).SILENT:
$(NAME): $(LIBFT) $(OBJS) $(NAME): $(LIBFT) $(OBJS)
@echo "Making Minishell." echo Making Minishell...
@gcc -g ${OBJS} ${LIB} -o ${NAME} gcc -g ${OBJS} ${LIB} -o ${NAME}
@echo "Done." echo
$(LIBFT): $(LIBFT):
@${MAKE} -C ./libft ${MAKE} -C ./libft
@cp ./libft/libft.a . cp ./libft/libft.a .
all: $(NAME)
%.o: %.c %.o: %.c
@gcc -Werror -Wextra -Wall -g -c $< ${READLINE_INC} gcc -Werror -Wextra -Wall -g -c $< ${READLINE_INC}
clean: clean:
@echo "Cleaning objects." echo Cleaning objects...
@rm -rf ${OBJS} rm -rf ${OBJS}
@echo "Done." echo
fclean: clean fclean: clean
@${MAKE} -C ./libft fclean ${MAKE} -C ./libft fclean
@rm -rf libft.a rm -rf libft.a
@echo "Cleaning binary." echo Cleaning binary...
@rm -rf ${NAME} rm -rf ${NAME}
@echo "Done." echo
re: fclean all re: fclean all

20
libft/Makefile

@ -36,24 +36,26 @@ RM = rm -rf
CFLAGS = -Wall -Wextra -Werror CFLAGS = -Wall -Wextra -Werror
$(VERBOSE).SILENT:
.c.o: .c.o:
@${CC} ${CFLAGS} -c $< -o ${<:.c=.o} ${CC} ${CFLAGS} -c $< -o ${<:.c=.o}
all : $(NAME) all : $(NAME)
$(NAME): $(OBJS) $(NAME): $(OBJS)
@echo "Making libft." echo Making libft...
@${AR} ${NAME} ${OBJS} ${AR} ${NAME} ${OBJS}
@echo "Done." echo
clean: clean:
@echo "Cleaning libft." echo Cleaning libft...
@${RM} ${OBJS} ${RM} ${OBJS}
@${RM} ${OBJS_BONUS} ${RM} ${OBJS_BONUS}
@echo "Done." echo
fclean: clean fclean: clean
@${RM} ${NAME} ${RM} ${NAME}
re: fclean all re: fclean all

Loading…
Cancel
Save