-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
55 lines (40 loc) · 1.27 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SRC_DIR = ./sources_files
OBJ_DIR = ./objects_files
INC_DIR = ./includes
BT_DIR = ./builtins
INCLUDES = $(wildcard $(INC_DIR)/*)
SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c)
OBJ = $(addprefix $(OBJ_DIR)/, $(notdir $(SRCS:.c=.o)))
BT_SRCS = $(wildcard $(BT_DIR)/*.c)
BT_OBJ = $(BT_SRCS:.c=)
RM = rm -f
NAME = minishell
LIB = $(INC_DIR)/libft/libft.a
CC = gcc
CFLAGS = -g -Wall -Werror -Wextra
AUTHOR = babreton - [email protected]
.PHONY: all clean fclean re table
all: $(NAME) ${LIB} builtins
$(BT_DIR)/%: $(BT_DIR)/%.c ${LIB}
@$(CC) $(CFLAGS) $< -L$(INC_DIR)/libft -lft -o $@
@echo "\033[32m[✓] $@ succesfully compiled\033[0m"
builtins: $(BT_OBJ)
${LIB}:
@echo "$(GREEN)Compiling libft : $(NC)"
@make -s -C $(INC_DIR)/libft/ all
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INCLUDES) | $(OBJ_DIR)
@$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/*/%.c $(INCLUDES) | $(OBJ_DIR)
@$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR):
@mkdir -p $@
$(NAME): $(OBJ) ${LIB}
@$(CC) $(CFLAGS) $(OBJ) -L$(INC_DIR)/libft -lft -lreadline -o $(NAME)
@echo "\033[32m[✓] minishell succesfully compiled\033[0m"
clean:
@$(RM) -r $(OBJ_DIR)
@make -s -C $(INC_DIR)/libft/ clean
fclean: clean
@$(RM) $(NAME) $(BT_OBJ)
@make -s -C $(INC_DIR)/libft/ fclean
re: fclean all