summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2019-12-27 17:24:35 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2019-12-27 17:24:35 +0100
commitfc29371a10bf6cfd93c4e9ccfe9193c1311efc98 (patch)
treee5e67174f06e99d945fa2631bbd0648e1fafeec1 /Makefile
parentSTDIN corrected (diff)
download42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.gz
42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.bz2
42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.xz
42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.zst
42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.zip
updated libft, better Makefile and .gitignore
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile104
1 files changed, 61 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 78a34e0..1dcc40e 100644
--- a/Makefile
+++ b/Makefile
@@ -10,62 +10,80 @@
# / #
# / #
# **************************************************************************** #
-
+.DEFAULT_GOAL := all
+#==============================================================================#
+#--------------------------------- Shell --------------------------------------#
+#==============================================================================#
+SHELL := /bin/sh
+#==============================================================================#
+#------------------------------ Directories -----------------------------------#
+#==============================================================================#
SRCS_DIR = src/
-SRCS = \
- ${SRCS_DIR}main.c \
- ${SRCS_DIR}ft_process_arg.c \
- ${SRCS_DIR}ft_error.c \
- ${SRCS_DIR}ft_exit.c \
- ${SRCS_DIR}ft_echo.c \
- ${SRCS_DIR}ft_pwd.c \
- ${SRCS_DIR}ft_exec.c \
- ${SRCS_DIR}ft_history.c \
-
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})
-
-INCS_DIR = -Iinc/ -Ilibft/inc/
-
-LIB_DIR = -Llibft/
-LIB = -lft
-
-CC = clang
-CFLAGS = -Wall -Wextra -Werror
-
-DEBUG = -g3
+#------------------------------------------------------------------------------#
+#==============================================================================#
+#-------------------------------- Compiler ------------------------------------#
+#==============================================================================#
+CC = gcc
+CFLAGS = -Wall
+CFLAGS += -Wextra
+CFLAGS += -Werror
+CFLAGS += ${DEBUG}
+CFLAGS += ${FSANITIZE}
+#------------------------------------------------------------------------------#
+DEBUG = -Og -ggdb
FSANITIZE = -fsanitize=address
-
+#------------------------------------------------------------------------------#
NAME = minishell
-
+#==============================================================================#
+#--------------------------------- UNIX ---------------------------------------#
+#==============================================================================#
RM = rm -rf
MKDIR = mkdir -p
-
-
-${OBJS_DIR}%.o: ${SRCS_DIR}%.c inc/minishell.h libft/inc/libft.h
+#==============================================================================#
+#--------------------------------- Rules --------------------------------------#
+#==============================================================================#
+${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS_DIR}minishell.h ${LFT_INCS_DIR}libft.h
@${MKDIR} ${OBJS_DIR}
- ${CC} ${CFLAGS} ${DEBUG} ${INCS_DIR} -o $@ -c $<
-
+ ${CC} ${CFLAGS} -I${INCS_DIR} -I${LFT_INCS_DIR} -o $@ -c $<
+#------------------------------------------------------------------------------#
$(NAME): ${OBJS}
- ${CC} ${CFLAGS} ${DEBUG} ${LIB_DIR} ${LIB} -o ${NAME} ${OBJS}
-
-all: ${NAME}
-
+ ${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}
-
-xclean:
+#------------------------------------------------------------------------------#
+fclean: clean
+ @$(MAKE) --no-print-directory -C ${LFT_DIR} fclean
${RM} ${NAME}
${RM} ${NAME}.dSYM/
${RM} joe-sh_history
-
-fclean: clean xclean
-
+#------------------------------------------------------------------------------#
re: fclean all
-
-build: ${OBJS}
- ${CC} ${CFLAGS} ${DEBUG} ${FSANITIZE} ${LIB_DIR} ${LIB} -o minishell ${OBJS}
-
-default: all
-
+#------------------------------------------------------------------------------#
.PHONY: all clean clean fclean re