blob: 862a99ac0c50317c8b6ee9f7ca05182ce0fa9f49 (
plain)
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
|
default: all
#==============================================================================#
#--------------------------------- SHELL --------------------------------------#
#==============================================================================#
SHELL := /bin/sh
#==============================================================================#
#------------------------------ DIRECTORIES -----------------------------------#
#==============================================================================#
SRCS_DIR = src/
OBJS_DIR = obj/
LFT_DIR = libft/
LFT_INCS_DIR = ${LFT_DIR}inc/
LFT_SRCS_DIR = ${LFT_DIR}src/
#==============================================================================#
#--------------------------------- FILES --------------------------------------#
#==============================================================================#
SRCS_NAME = minishell.c
SRCS_NAME += ft_b_echo.c
SRCS_NAME += ft_b_env.c
SRCS_NAME += ft_e_lcom.c
SRCS_NAME += ft_m_funptr.c
SRCS_NAME += ft_m_loop.c
SRCS_NAME += ft_m_prompt.c
SRCS_NAME += ft_s_destroy.c
SRCS_NAME += ft_s_init.c
SRCS_NAME += ft_s_lcom.c
SRCS_NAME += ft_p_line.c
SRCS_NAME += ft_p_lcom.c
#------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR}, ${SRCS_NAME})
#------------------------------------------------------------------------------#
INCS_NAME = ft_d_enum.h
INCS_NAME += ft_d_define.h
INCS_NAME += ft_s_struct.h
INCS_NAME += $(patsubst %.c,%.h,${SRCS_NAME})
#------------------------------------------------------------------------------#
INCS = $(addprefix ${SRCS_DIR}, ${INCS_NAME})
#------------------------------------------------------------------------------#
OBJS = $(patsubst ${SRCS_DIR}%.c,${OBJS_DIR}%.o,${SRCS})
#------------------------------------------------------------------------------#
NAME = minishell
#------------------------------------------------------------------------------#
HISTFILE = minishell_history
#------------------------------------------------------------------------------#
LFT_SRCS = $(shell find ${LFT_SRCS_DIR} -name "*.c")
#==============================================================================#
#-------------------------------- COMPILER ------------------------------------#
#==============================================================================#
CC = clang
CFLAGS = -std=c89
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Werror
CFLAGS += -pedantic
#------------------------------------------------------------------------------#
CDEFS = -DFT_HISTFILE=${HISTFILE}
#------------------------------------------------------------------------------#
LDFLAGS = -L${LFT_DIR}
LDFLAGS += -lft
#==============================================================================#
#--------------------------------- UNIX ---------------------------------------#
#==============================================================================#
RM = rm -rf
MKDIR = mkdir -p
#==============================================================================#
#--------------------------------- RULES --------------------------------------#
#==============================================================================#
LFTRULE = all
#------------------------------------------------------------------------------#
${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS}
@${MKDIR} ${OBJS_DIR}
${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_INCS_DIR} -o $@ $<
#------------------------------------------------------------------------------#
$(NAME): ${OBJS} ${LFT_SRCS} ${LFT_INCS_DIR}libft.h
@$(MAKE) --no-print-directory -C ${LFT_DIR} ${LFTRULE}
${CC} ${CFLAGS} -o ${NAME} ${OBJS} ${LDFLAGS}
#------------------------------------------------------------------------------#
all: ${NAME}
#------------------------------------------------------------------------------#
debug: CFLAGS += -glldb
debug: LFTRULE = debug
debug: all
#------------------------------------------------------------------------------#
asan: CFLAGS += -glldb
asan: CFLAGS += -fsanitize=address
asan: LFTRULE = asan
asan: all
#------------------------------------------------------------------------------#
clean:
@$(MAKE) --no-print-directory -C ${LFT_DIR} clean
${RM} ${OBJS_DIR}
#------------------------------------------------------------------------------#
fclean: clean
@$(MAKE) --no-print-directory -C ${LFT_DIR} fclean
${RM} ${NAME} ${NAME}.core ${NAME}.dSYM/ ${HISTFILE}
#------------------------------------------------------------------------------#
re: fclean all
#------------------------------------------------------------------------------#
.PHONY: all clean clean fclean re debug asan
|