default: debug #==============================================================================# #--------------------------------- SHELL --------------------------------------# #==============================================================================# SHELL := /bin/sh OS = $(shell uname) #==============================================================================# #------------------------------ DIRECTORIES -----------------------------------# #==============================================================================# SRCS_DIR = src/ OBJS_DIR = obj/ LFT_DIR = libft/ LFT_INCS_DIR = ${LFT_DIR}include/ LFT_SRCS_DIR = ${LFT_DIR}src/ #==============================================================================# #--------------------------------- FILES --------------------------------------# #==============================================================================# SRCS_NAME = b_alias SRCS_NAME += b_alias_print SRCS_NAME += b_alias_register SRCS_NAME += b_cd SRCS_NAME += b_echo SRCS_NAME += b_env SRCS_NAME += b_exit SRCS_NAME += b_export SRCS_NAME += b_export_next SRCS_NAME += b_export_mute SRCS_NAME += b_h SRCS_NAME += b_pwd SRCS_NAME += b_sqb SRCS_NAME += b_sqb_err SRCS_NAME += b_sqb_file SRCS_NAME += b_sqb_nbr SRCS_NAME += b_sqb_str SRCS_NAME += b_type SRCS_NAME += b_unset SRCS_NAME += c_ctrls SRCS_NAME += c_init SRCS_NAME += c_input SRCS_NAME += c_keys SRCS_NAME += c_utils_next SRCS_NAME += c_utils SRCS_NAME += e_builtins SRCS_NAME += e_externs SRCS_NAME += e_line SRCS_NAME += e_pipes SRCS_NAME += e_pipes_next SRCS_NAME += e_redirs SRCS_NAME += e_unshebanged SRCS_NAME += f_alloc SRCS_NAME += f_chdir SRCS_NAME += f_com SRCS_NAME += f_errno SRCS_NAME += f_exec SRCS_NAME += f_fail SRCS_NAME += f_file SRCS_NAME += f_parse SRCS_NAME += f_redir SRCS_NAME += f_shlvl SRCS_NAME += m_argv SRCS_NAME += m_comm SRCS_NAME += m_funptr SRCS_NAME += m_init SRCS_NAME += m_loop SRCS_NAME += m_loop_counter SRCS_NAME += m_loop_multis SRCS_NAME += m_loop_next SRCS_NAME += m_minishell SRCS_NAME += m_mshrc SRCS_NAME += m_prompt SRCS_NAME += m_prompt_seq SRCS_NAME += s_destroy SRCS_NAME += s_com SRCS_NAME += s_init SRCS_NAME += s_init_next SRCS_NAME += s_set_cwd SRCS_NAME += s_lalias SRCS_NAME += s_line SRCS_NAME += s_lvars SRCS_NAME += s_lpipes SRCS_NAME += s_lpipes_split SRCS_NAME += s_lredir SRCS_NAME += p_args SRCS_NAME += p_args_next SRCS_NAME += p_args_len SRCS_NAME += p_args_escape SRCS_NAME += p_line SRCS_NAME += p_lblock SRCS_NAME += p_lblock_next SRCS_NAME += p_lblock_more SRCS_NAME += p_redirs SRCS_NAME += p_redirs_heredoc SRCS_NAME += p_split SRCS_NAME += p_subst_alias SRCS_NAME += p_subst_home SRCS_NAME += p_subst_vars SRCS_NAME += u_alias SRCS_NAME += u_parse SRCS_NAME += u_path SRCS_NAME += u_utils SRCS_NAME += u_vars SRCS_NAME += u_vars_next #------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR}, $(addsuffix .c, ${SRCS_NAME})) #------------------------------------------------------------------------------# INCS_NAME = b_builtins INCS_NAME += d_enum INCS_NAME += d_define INCS_NAME += s_struct #------------------------------------------------------------------------------# INCS = $(addprefix ${SRCS_DIR}, $(addsuffix .h, ${INCS_NAME})) INCS += $(patsubst %.c,%.h,${SRCS}) #------------------------------------------------------------------------------# OBJS = $(patsubst ${SRCS_DIR}%.c,${OBJS_DIR}%.o,${SRCS}) #------------------------------------------------------------------------------# NAME = minishell #------------------------------------------------------------------------------# LFT_SRCS = $(shell find ${LFT_SRCS_DIR} -name "*.c") #==============================================================================# #-------------------------------- COMPILER ------------------------------------# #==============================================================================# ifeq (${OS}, FreeBSD) CC = cc endif ifeq (${OS}, Linux) CC = clang endif ifeq (${OS}, Darwin) CC = cc endif CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror CFLAGS += -pedantic #------------------------------------------------------------------------------# CDEFS = -D_POSIX_C_SOURCE=200112L #------------------------------------------------------------------------------# LDFLAGS = -L${LFT_DIR} LDFLAGS += -lft LDFLAGS += -lncurses #==============================================================================# #--------------------------------- UNIX ---------------------------------------# #==============================================================================# RM = rm -rf MKDIR = mkdir -p #==============================================================================# #--------------------------------- RULES --------------------------------------# #==============================================================================# LFTRULE = all #------------------------------------------------------------------------------# ${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS} ${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_INCS_DIR} -o $@ $< #------------------------------------------------------------------------------# ${OBJS_DIR}: ${MKDIR} ${OBJS_DIR} #------------------------------------------------------------------------------# $(NAME): ${OBJS} ${LFT_SRCS} ${LFT_INCS_DIR}libft.h $(MAKE) --no-print-directory -C ${LFT_DIR} ${LFTRULE} ${CC} ${CFLAGS} ${CDEFS} -o ${NAME} ${OBJS} ${LDFLAGS} #------------------------------------------------------------------------------# all: ${OBJS_DIR} ${NAME} #------------------------------------------------------------------------------# debug: CFLAGS += -glldb debug: LFTRULE = debug debug: all #------------------------------------------------------------------------------# asan: CFLAGS += -glldb asan: CFLAGS += -fsanitize=address asan: LFTRULE = asan asan: all #------------------------------------------------------------------------------# msan: CFLAGS += -glldb msan: CFLAGS += -fsanitize=memory msan: CFLAGS += -fsanitize-memory-track-origins msan: CFLAGS += -fno-common msan: CFLAGS += -fno-omit-frame-pointer msan: LFTRULE = msan msan: 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/ qwe minishell_history #------------------------------------------------------------------------------# re: fclean all #------------------------------------------------------------------------------# run: all clear; ./${NAME} #------------------------------------------------------------------------------# .PHONY: all clean clean fclean re debug asan run