-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
199 lines (176 loc) · 6.37 KB
/
Makefile
File metadata and controls
199 lines (176 loc) · 6.37 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: pvershin <pvershin@student.hive.fi> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/05/12 14:02:40 by imunaev- #+# #+# #
# Updated: 2025/05/16 10:23:24 by pvershin ### ########.fr #
# #
# **************************************************************************** #
# Detect OS
UNAME := $(shell uname)
BIGTEST ?= 0
# Default flags
LDFLAGS :=
CFLAGS := -g -Wall -Wextra -Werror
CFLAGS += -DBIGTEST=$(BIGTEST)
# macOS-specific flags for Readline (2DO: fix extern void rl_replace_line(const char *, int) in signals.c)
ifeq ($(UNAME), Darwin)
READLINE_PATH := $(shell brew --prefix readline 2>/dev/null)
ifneq ($(READLINE_PATH),)
LDFLAGS += -L$(READLINE_PATH)/lib
CFLAGS += -I$(READLINE_PATH)/include
CFLAGS += -Wno-strict-prototypes
endif
endif
NAME := minishell
CC := cc
RM := rm -rf
# --- Explicit list of source files ---
SRC_FILES := \
src/memory_management/free_cmd.c \
src/memory_management/free_minishell.c \
src/memory_management/free_utils.c \
src/parser/parser_helpers2.c \
src/parser/tokenizer2.c \
src/parser/parser2.c \
src/parser/parser_utils_explain.c \
src/parser/unsupported_cmd.c \
src/parser/tokenizer6.c \
src/parser/parser1.c \
src/parser/parser_helpers1.c \
src/parser/tokenizer1.c \
src/parser/tokenizer5.c \
src/parser/parser5.c \
src/parser/parser7.c \
src/parser/expand2.c \
src/parser/expand_helpers_escape.c \
src/parser/parser_utils_token.c \
src/parser/parser_utils_free.c \
src/parser/tokenizer4.c \
src/parser/parser_helpers4.c \
src/parser/parser4.c \
src/parser/parser6.c \
src/parser/tokenizer3.c \
src/parser/parser_utils_cmd.c \
src/parser/parser_helpers3.c \
src/parser/expand_tokens.c \
src/parser/parser3.c \
src/parser/expand_helpers_tilde.c \
src/parser/expand_helpers_dollar.c \
src/parser/expand_helpers_quotes.c \
src/parser/expand.c \
src/utils.c \
src/main.c \
src/main_utils.c \
src/main_script_mode.c \
src/main_interactive_mode.c \
src/main_non_interactive_mode.c \
src/mshell/init_minishell.c \
src/mshell/find_binary_utils.c \
src/mshell/env/setup_env.c \
src/mshell/env/update_env.c \
src/mshell/env/update_env_utils.c \
src/mshell/find_binary.c \
src/mshell/varables_hash_table/setup_hash_table_utils_1.c \
src/mshell/varables_hash_table/setup_hash_table_utils_2.c \
src/mshell/varables_hash_table/setup_hash_table_utils_3.c \
src/mshell/varables_hash_table/setup_hash_table.c \
src/executor/executor.c \
src/executor/pipeline/pipe_utils.c \
src/executor/pipeline/pipe_creators/handle_child_and_track.c \
src/executor/pipeline/pipe_creators/wait_for_children.c \
src/executor/pipeline/close_unused_fds.c \
src/executor/pipeline/pipe_executors/execute_command.c \
src/executor/pipeline/exec_in_pipes.c \
src/executor/pipeline/exec_in_pipes1.c \
src/executor/redirections/apply_redirections.c \
src/executor/redirections/heredoc/write_heredoc_to_pipe.c \
src/executor/redirections/heredoc/write_heredoc_utils.c \
src/executor/redirections/heredoc/write_heredoc_utils1.c \
src/executor/redirections/heredoc/apply_heredoc_utilc.c \
src/executor/redirections/heredoc/apply_heredoc_utils1.c \
src/executor/redirections/heredoc/apply_heredocs.c \
src/executor/builtins/unset/unset.c \
src/executor/builtins/echo/echo_utils.c \
src/executor/builtins/echo/echo.c \
src/executor/builtins/pwd/pwd.c \
src/executor/builtins/exec_builtins.c \
src/executor/builtins/env/env.c \
src/executor/builtins/builtin_utils.c \
src/executor/builtins/exit/exit.c \
src/executor/builtins/exit/exit_utils.c \
src/executor/builtins/cd/cd_utils.c \
src/executor/builtins/cd/cd.c \
src/executor/builtins/export/export_utils_1.c \
src/executor/builtins/export/export.c \
src/executor/builtins/export/export_utils_2.c \
src/executor/executor_helpers/command_too_long.c \
src/executor/executor_helpers/update_underscore.c \
src/executor/executor_helpers/executor_utils.c \
src/executor/exec_in_current_process.c \
src/errors/child_execve_error_utils.c \
src/errors/error_utils_2.c \
src/errors/error_utils_1.c \
src/errors/child_execve_error.c \
src/signals.c
# --- End of explicit list ---
OBJ_DIR := obj
LIBFT_DIR := libs/libft
# Convert source files to object files, preserving directory structure
# This patsubst should still work with the explicit list
OBJ_FILES := $(patsubst src/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
INCLUDES := -Iinclude -I$(LIBFT_DIR)
# Libft
LIBFT := $(LIBFT_DIR)/libft.a
# Define the documentation output directory
DOCS_DIR = docs
# Default Doxygen configuration file
DOXYFILE = Doxyfile
# Compile all
$(NAME): $(OBJ_FILES) $(LIBFT)
$(CC) $(CFLAGS) $(OBJ_FILES) $(LIBFT) -g -o $(NAME) $(LDFLAGS) -lreadline
@echo "\033[32m\"$(NAME)\": successfully created!\033[0m"
# Rule for compiling object files with correct paths
# This rule creates the necessary subdirectories in obj/
$(OBJ_DIR)/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Build libft
$(LIBFT):
make -C $(LIBFT_DIR)
# Norminette
norm:
@if command -v norminette > /dev/null; then \
norminette_output=$$(norminette .); \
norminette_status=$$?; \
if [ $$norminette_status -eq 0 ]; then \
echo "\033[32m$$norminette_output\033[0m"; \
else \
echo "\033[31m$$(echo "$$norminette_output" | head -n 10)\033[0m"; \
fi; \
else \
echo "\033[31mno norminette\033[0m"; \
fi
# Rule to generate Doxygen documentation
docs:
@echo "Generating documentation..."
@doxygen $(DOXYFILE)
@echo "\033[32mDocumentation generated in $(DOCS_DIR)/html/index.html\033[0m"
# Clean
clean:
$(RM) $(OBJ_DIR)
make -C $(LIBFT_DIR) clean
fclean: clean
$(RM) $(NAME)
make -C $(LIBFT_DIR) fclean
rm -f sources_dump.txt
re: fclean $(NAME)
# Rule to clean up old documentation
dclean:
@echo "Cleaning documentation files..."
@rm -rf $(DOCS_DIR)
@echo "\033[32mDocumentation cleaned.\033[0m"
.PHONY: all clean fclean re docs dclean norm