71 lines
1.4 KiB
Makefile
71 lines
1.4 KiB
Makefile
NAME = libftprintf.a
|
|
|
|
SRC_FILE = ft_printf.c \
|
|
ft_parser.c \
|
|
ft_int_case.c \
|
|
ft_char_case.c \
|
|
ft_str_case.c \
|
|
ft_ui_case.c \
|
|
ft_x_case.c \
|
|
ft_ptr_case.c \
|
|
ft_percent_case.c \
|
|
ft_printf_memset.c \
|
|
|
|
OBJ_FILE = $(SRC_FILE:.c=.o)
|
|
|
|
INC_FILE = ft_printf.h \
|
|
|
|
SRC_DIR = src/
|
|
OBJ_DIR = obj/
|
|
INC_DIR = inc/
|
|
SRC = $(addprefix $(SRC_DIR), $(SRC_FILE))
|
|
OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILE))
|
|
INC = $(addprefix $(INC_DIR), $(INC_FILE))
|
|
|
|
CC = gcc
|
|
CFLAGS = -Wall -Werror -Wextra
|
|
|
|
LIB = libft/libft.a
|
|
|
|
GREEN = \033[32m
|
|
RED = \033[31m
|
|
ORANGE = \033[33m
|
|
PURPLE = \033[35m
|
|
CYAN = \033[36m
|
|
WHITE = \033[0m
|
|
|
|
all: $(NAME)
|
|
|
|
$(NAME): $(LIB) $(OBJ) $(INC)
|
|
@cp $(LIB) $(NAME)
|
|
@ar -rcs $(NAME) $(OBJ)
|
|
@ranlib $(NAME)
|
|
@echo -e "$(GREEN)[OK]$(WHITE) $(NAME)"
|
|
|
|
$(OBJ_DIR)%.o: $(SRC_DIR)%.c libft/ $(INC)
|
|
@if [ ! -d ./obj ]; then \
|
|
mkdir -p ./obj; \
|
|
fi;
|
|
@$(CC) $(CFLAGS) -I $(INC_DIR) -I libft/inc -o $@ -c $<
|
|
@echo -e "$(CYAN)[CC]$(WHITE) $(<:$(SRC_DIR)%=%)"
|
|
|
|
$(LIB):
|
|
@echo -e "$(PURPLE)[MAKE]$(WHITE) libft"
|
|
@make --no-print-directory -C ./libft
|
|
|
|
clean:
|
|
@make --no-print-directory -C libft clean
|
|
@echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)"
|
|
@rm -rf $(OBJ_DIR)
|
|
|
|
fclean:
|
|
@make --no-print-directory -C libft fclean
|
|
@echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)"
|
|
@rm -rf $(OBJ_DIR)
|
|
@echo -e "$(RED)[DELETE]$(WHITE) $(NAME)"
|
|
@rm -f $(NAME)
|
|
|
|
re: fclean all
|
|
|
|
.PHONY: all clean fclean re
|