summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: a024d25fda42f426915ba6c8d19ebd2dfca2ee15 (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
# **************************************************************************** #
#                                                           LE - /             #
#                                                               /              #
#    Makefile                                         .::    .:/ .      .::    #
#                                                  +:+:+   +:    +:  +:+:+     #
#    By: rbousset <marvin@le-101.fr>                +:+   +:    +:    +:+      #
#                                                  #+#   #+    #+    #+#       #
#    Created: 2019/10/08 15:04:55 by rbousset     #+#   ##    ##    #+#        #
#    Updated: 2019/10/13 14:01:21 by rbousset    ###    #+. /#+    ###.fr      #
#                                                          /                   #
#                                                         /                    #
# **************************************************************************** #
.DEFAULT_GOAL	:= all
#==============================================================================#
#--------------------------------- Shell --------------------------------------#
#==============================================================================#
SHELL			:= /bin/sh
#==============================================================================#
#------------------------------ Directories -----------------------------------#
#==============================================================================#
SRCS_DIR		= src/
OBJS_DIR		= obj/
LFT_DIR			= libft/
INCS_DIR		= inc/
LFT_INCS_DIR	= ${LFT_DIR}/inc/
#==============================================================================#
#--------------------------------- Files --------------------------------------#
#==============================================================================#
LFT				= ft
#------------------------------------------------------------------------------#
SRCS_NAME		= main.c
SRCS_NAME		+= ft_process_arg.c
SRCS_NAME		+= ft_error.c
SRCS_NAME		+= ft_exit.c
SRCS_NAME		+= ft_echo.c
SRCS_NAME		+= ft_pwd.c
SRCS_NAME		+= ft_exec.c
SRCS_NAME		+= ft_history.c
SRCS			= $(addprefix ${SRCS_DIR}, ${SRCS_NAME})
#------------------------------------------------------------------------------#
OBJS			= $(patsubst ${SRCS_DIR}%.c,${OBJS_DIR}%.o,${SRCS})
#------------------------------------------------------------------------------#
#==============================================================================#
#-------------------------------- Compiler ------------------------------------#
#==============================================================================#
CC				= clang
CFLAGS			= -Wall
CFLAGS			+= -Wextra
CFLAGS			+= -Werror
CFLAGS			+= ${DEBUG}
CFLAGS			+= ${FSANITIZE}
#------------------------------------------------------------------------------#
DEBUG			= -glldb
FSANITIZE		= -fsanitize=address
#------------------------------------------------------------------------------#
NAME			= minishell
#==============================================================================#
#--------------------------------- UNIX ---------------------------------------#
#==============================================================================#
RM				= rm -rf
MKDIR			= mkdir -p
#==============================================================================#
#--------------------------------- Rules --------------------------------------#
#==============================================================================#
${OBJS_DIR}%.o:		${SRCS_DIR}%.c ${INCS_DIR}minishell.h ${LFT_INCS_DIR}libft.h
	@${MKDIR} ${OBJS_DIR}
	${CC} ${CFLAGS} -I${INCS_DIR} -I${LFT_INCS_DIR} -o $@ -c $< 
#------------------------------------------------------------------------------#
$(NAME):		${OBJS}
	${CC} ${CFLAGS} -o ${NAME} ${OBJS} -L${LFT_DIR} -l${LFT} 
#------------------------------------------------------------------------------#
all:
	@$(MAKE) --no-print-directory -C ${LFT_DIR} all
	@printf "\n"
	@$(MAKE) --no-print-directory ${NAME}
#------------------------------------------------------------------------------#
clean: 
	@$(MAKE) --no-print-directory -C ${LFT_DIR} clean
	${RM} ${OBJS_DIR}
#------------------------------------------------------------------------------#
fclean:			clean
	@$(MAKE) --no-print-directory -C ${LFT_DIR} fclean
	${RM} ${NAME}
	${RM} ${NAME}.dSYM/
	${RM} joe-sh_history
#------------------------------------------------------------------------------#
re:				fclean all
#------------------------------------------------------------------------------#
.PHONY:	all clean clean fclean re