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_cd.c SRCS_NAME += ft_b_echo.c SRCS_NAME += ft_b_env.c SRCS_NAME += ft_b_exit.c SRCS_NAME += ft_b_export.c SRCS_NAME += ft_b_pwd.c SRCS_NAME += ft_b_type.c SRCS_NAME += ft_b_unset.c SRCS_NAME += ft_e_builtins.c SRCS_NAME += ft_e_externs.c SRCS_NAME += ft_e_externs_next.c SRCS_NAME += ft_e_lcom.c SRCS_NAME += ft_f_fail.c SRCS_NAME += ft_f_file.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_NAME += ft_u_utils.c #------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR}, ${SRCS_NAME}) #------------------------------------------------------------------------------# INCS_NAME = ft_b_builtins.h 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 #------------------------------------------------------------------------------# LFT_SRCS = $(shell find ${LFT_SRCS_DIR} -name "*.c") #==============================================================================# #-------------------------------- COMPILER ------------------------------------# #==============================================================================# CC = clang CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror CFLAGS += -pedantic #------------------------------------------------------------------------------# 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} vgcore* #------------------------------------------------------------------------------# fclean: clean @$(MAKE) --no-print-directory -C ${LFT_DIR} fclean ${RM} ${NAME} ${NAME}.core ${NAME}.dSYM/ ${HISTFILE} qwe #------------------------------------------------------------------------------# re: fclean all #------------------------------------------------------------------------------# .PHONY: all clean clean fclean re debug asan