-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (65 loc) · 1.88 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
# Makeconfig
MAKEFLAGS = --no-print-directory
# Compiler
CC := cc
CFLAGS := -g -Wall -Werror -Wextra
# Targets
TARGET := minishell
# Dependencies
LIB_DEPS := libft.a libreadline.a
LIB_DIRS := libft
# Includes
INC_DIRS := $(wildcard */) $(wildcard */*/) $(wildcard */*/*/) $(wildcard */*/*/*/)
# Directories
SRC_DIR := src
BLD_DIR := build
# =====DO NOT EDIT BELOW THIS LINE=====
# Sources, Objects and Includes
SRC := $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/parser/lexer/*.c) \
$(wildcard $(SRC_DIR)/parser/*.c) \
$(wildcard $(SRC_DIR)/interpreter/*.c) \
$(wildcard $(SRC_DIR)/interpreter/redirections/*.c) \
$(wildcard $(SRC_DIR)/interpreter/expander/*.c) \
$(wildcard $(SRC_DIR)/signals/*.c)\
$(wildcard $(SRC_DIR)/builtins/*.c)
OBJ := $(addprefix $(BLD_DIR)/, $(SRC:.c=.o))
E_INC_DIRS := $(foreach dir, $(INC_DIRS), $(addprefix -I./, $(dir)))
E_LIB_DIRS := $(foreach dir, $(LIB_DIRS), $(addprefix -L./, $(dir)))
E_LIB_DEPS := $(foreach lib, $(LIB_DEPS), $(addprefix -l, $(subst .a, , $(subst lib, , $(lib)))))
# =======BUILD=======
all: $(TARGET)
# Linker
$(TARGET): $(OBJ)
@$(MAKE) -C ./libft
@printf "Creating libft: $(GREEN)OK!\n$(DEF_COLOR)"
@$(CC) $(CFLAGS) $^ $(E_LIB_DIRS) $(E_LIB_DEPS) -o $@
@printf "Linking: $(GREEN)OK!\n$(DEF_COLOR)"
# Compiler
$(BLD_DIR)/%.o: %.c
@mkdir -p $(BLD_DIR)
@mkdir -p $(@D)
@$(CC) -c $(CFLAGS) $< $(E_INC_DIRS) -o $@
@printf "Compiling $<: $(GREEN)OK!\n$(DEF_COLOR)"
# Commands
fclean:
@$(MAKE) fclean -C ./libft
@rm -rf $(BLD_DIR) $(TARGET) $(BONUST)
@printf "$(BLUE)F_Cleaned!\n$(DEF_COLOR)"
clean:
@$(MAKE) clean -C ./libft
@rm -rf $(BLD_DIR)
@printf "$(BLUE)Cleaned!\n$(DEF_COLOR)"
re: fclean all
run: $(TARGET)
./$(TARGET)
print-%:
@echo $* = $($*)
# Colors
DEF_COLOR = \033[0;39m
RED = \033[1;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
BLUE = \033[1;34m
MAGENTA = \033[1;35m
CYAN = \033[1;36m
WHITE = \033[1;37m