-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (70 loc) · 2.92 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: gborne <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/07/27 14:38:38 by gborne #+# #+# #
# Updated: 2022/08/01 23:50:29 by gborne ### ########.fr #
# #
# **************************************************************************** #
NAME = minishell
TXT_BOLD = tput bold
TXT_NORMAL = tput sgr0
LIBFT = libft/libft.a
#READLINE = readline/libreadline.a
READLINE = readline/libreadline.a -I ~/.brew/opt/readline/include
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g
LFLAGS = $(LIBFT) $(READLINE) -lreadline -lncurses
# -s --leak-check=full --show-leak-kinds=all --track-origins=yes --suppressions=valgrind_readline.supp
VALGRIND = valgrind --leak-check=full --suppressions=valgrind_readline.supp
SRC = $(wildcard src/*.c src/*/*.c)
OBJ = $(SRC:.c=.o)
%.o : %.c
@$(CC) $(CFLAGS) -o $@ -c $<
all: $(NAME)
$(NAME) : $(OBJ)
@make -C libft
@$(CC) $(CFLAGS) -o $(NAME) $(OBJ) $(LFLAGS)
@echo "\033[1mmake success\033[0m"
run: all
./$(NAME)
leaks: all
$(VALGRIND) ./$(NAME)
clean:
@make clean -C libft
@rm -f src/*.o src/*/*.o
@echo "\033[1mclean success\033[0m"
fclean: clean
@make fclean -C libft
@rm -f minishell
@echo "\033[1mfclean success\033[0m"
re: fclean all
@make re -C libft
@echo "\033[1mreboot success\033[0m"
.PHONY: all init_libft run leaks clean fclean re
#make -C libft
#$(OBJ)
#$(OBJ)
#$(call OBJ_LST $(OBJ))
#$(addprefix $(DIR_OBJ),$(lastword $(subst /, ,$(OBJ))))
#$(addprefix $(DIR_OBJ),$(lastword $(subst /, ,$(OBJ))))
#@echo ${addprefix $(DIR_OBJ),$(subst /,,$(OBJ))}
#@echo ${addprefix $(DIR_OBJ),$(shell echo $(OBJ) | tr ' ' '\n')}
#make -C libft
#@echo $(OBJ)
#@echo $(addprefix $(DIR_OBJ),$(lastword $(subst /, ,${<:$(DIR_SRC)%.c=%.o})))
#@echo $(addprefix $(DIR_OBJ),$(lastword $(subst /, ,$(<:%.c=%.o))))
#$(CC) $(CFLAGS) -c $< -o $(addprefix $(DIR_OBJ),$(lastword $(subst /, ,$(<:%.c=%.o))))
# $@ nom cible
# $< nom premiere dependance
# $^ liste depandances
# $? liste dependances plus recentes que la cible
# $* nom fichier, sans extension
#FUNCTION
#CLEAR_PATH = $(shell $1 rev | cut -d'/' -f-1 | rev)
#OBJ_LST = $(addprefix $(DIR_OBJ),$(subst builtin/,,$(subst parser/,,$(subst src/,,$1))))
#@echo ${addprefix $(DIR_OBJ), $(shell ${<:$(DIR_SRC)%.c=%.o} rev | cut -d'/' -f-1 | rev)}
#$(addprefix $(DIR_OBJ),$(subst builtin/,,$(subst parser/,,$(subst src/,,$(SRC:.c=.o)))))