53 lines
864 B
Makefile
53 lines
864 B
Makefile
NAME = libft.a
|
|
|
|
SRC_FILES = ft_strdup.c \
|
|
ft_strlen.c \
|
|
|
|
INC_FILES = libft.h \
|
|
|
|
OBJ_FILES = $(SRC_FILES:.c=.o)
|
|
|
|
SRC_DIR = src/
|
|
INC_DIR = inc/
|
|
OBJ_DIR = obj/
|
|
|
|
SRC = $(addprefix $(SRC_DIR), $(SRC_FILES))
|
|
INC = $(addprefix $(INC_DIR), $(INC_FILES))
|
|
OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILES))
|
|
|
|
CC = gcc
|
|
|
|
CFLAGS = -Wall -Werror -Wextra
|
|
|
|
RED = \033[31m
|
|
GREEN = \033[32m
|
|
YELLOW = \033[33m
|
|
BLUE = \033[34m
|
|
CYAN = \033[36m
|
|
WHITE = \033[0m
|
|
|
|
all: $(NAME)
|
|
|
|
$(NAME): $(OBJ) $(INC)
|
|
@$(CC) $(CFLAGS) -I $(INC_DIR) -c $(SRC)
|
|
@mv $(OBJ_FILES) $(OBJ_DIR)
|
|
@ar rc $(NAME) $(OBJ)
|
|
@echo "$(GREEN)[OK]$(WHITE) $(NAME)"
|
|
|
|
$(OBJ_DIR)%.o: $(SRC_DIR)%.c
|
|
@if [ ! -d ./obj ]; then \
|
|
mkdir -p ./obj; \
|
|
fi;
|
|
@$(CC) $(CFLAGS) -I $(INC_DIR) -o $@ -c $<
|
|
@echo "$(CYAN)[CC]$(WHITE) $<"
|
|
|
|
clean:
|
|
@rm -rf $(OBJ)
|
|
|
|
fclean: clean
|
|
@rm -f $(NAME)
|
|
|
|
re: fclean all
|
|
|
|
.PHONY: all clean fclean re
|