This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (109 loc) · 3.41 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
##
## EPITECH PROJECT, 2022
## PROJECT_NAME
## File description:
## Makefile to compile project_name
##
NAME = 42sh
SRC = src/main.c \
src/b_sh42.c \
src/t_sh42.c \
src/inits/init_shell.c \
src/inits/init_env.c \
src/inits/init_history.c \
src/inits/init_alias.c \
src/inits/init_auto_completion.c \
src/special_chars/add_char.c \
src/special_chars/arrow.c \
src/special_chars/newline.c \
src/special_chars/delete.c \
src/special_chars/keys.c \
src/special_chars/scan_input.c \
src/special_chars/tab.c \
src/parsing/check_cmd.c \
src/parsing/getcmd.c \
src/parsing/parsing.c \
src/utils/free_struct_shell.c \
src/utils/prompt.c \
src/commands/alias/alias.c \
src/commands/alias/display_alias.c \
src/commands/alias/exec_alias.c \
src/commands/history/free_history.c \
src/commands/history/history_error_handling.c \
src/commands/history/history_flag.c \
src/commands/history/history.c \
src/commands/history/print_history.c \
src/commands/unalias/unalias.c \
src/commands/cd/change_pwd.c \
src/commands/cd/cd_cmd.c \
src/commands/env_cmds/env.c \
src/commands/env_cmds/setenv.c \
src/commands/env_cmds/unsetenv.c \
src/commands/execve_handling/basic_cmds.c \
src/commands/execve_handling/errors_printing.c \
src/commands/execve_handling/processes.c \
src/commands/exit/exit.c \
src/commands/echo/echo.c \
src/parsing/redirection/redirection.c \
src/parsing/redirection/file_red.c \
src/parsing/redirection/red_input.c \
src/options/inhibitors/escape_char.c \
src/options/auto_completion/stock_cmds.c \
src/options/auto_completion/free_cpl.c \
OBJ_DIR = ./obj/
OBJ = $(addprefix $(OBJ_DIR), $(subst src/,,$(SRC:.c=.o)))
WARNING_FLAGS := -Wall -Wextra -W -g -g3 -ggdb -Wno-unused-parameter
LIB_FLAGS := -I include/ -L ./lib/my -l:libmy.a
FILE = coding-style.sh
all: $(OBJ_DIR) $(NAME)
build_lib:
make -C lib/my/
$(NAME): $(OBJ)
make build_lib
gcc $(SRC) $(WARNING_FLAGS) -o $(NAME) $(LIB_FLAGS)
@echo -n "[ "
@echo -n "\e[1;34mOK\e[0m"
@echo -n " ] "
@echo "\e[1;32mSuccessfully compiled all the files\e[0m"
$(OBJ_DIR)%.o: src/%.c
gcc $(WARNING_FLAGS) -c -o $(OBJ_DIR)$(subst src/,,$(basename $<)).o $< \
$(LIB_FLAGS)
$(OBJ_DIR):
mkdir -p $(dir $(OBJ))
clean:
make clean -C lib/my/
rm -f $(OBJ)
@echo -n "[ "
@echo -n "\e[1;34mOK\e[0m"
@echo -n " ] "
@echo "\e[1;32mSuccessfully removed .o & .log files\e[0m"
cstyle: fclean
FILE=$$(find ~/ -name "$(FILE)" -print -quit); \
if [ -z "$$FILE" ]; then \
echo "[ \e[1;93mWARNING\e[0m ]" \
"\e[1;31mFile $(FILE) not found.\e[0m"; \
exit 69; \
else \
bash $$FILE . .; \
fi
if [ -s coding-style-reports.log ]; then \
echo "[ \e[1;93mWARNING\e[0m ]" \
"\e[1;31mFound coding style errors in coding-style-reports.log\e[0m"; \
cat coding-style-reports.log; \
else \
echo "[ \e[1;34mOK\e[0m ]" \
"\e[1;32mNo coding style error found\e[0m"; \
rm -f coding-style-reports.log; \
fi
fclean: clean
make fclean -C lib/my/
rm -rf $(OBJ_DIR)
rm -f $(NAME)
rm -f *.log
@echo -n "[ "
@echo -n "\e[1;34mOK\e[0m"
@echo -n " ] "
@echo "\e[1;32mSuccessfully removed binary files\e[0m"
re: fclean all
make clean
.PHONY: all build_lib clean cstyle fclean re