summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-20 14:51:45 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-20 14:51:45 +0200
commitc9e4fb6e2ad07e13cf41d6ce6afad30b04011765 (patch)
tree74d816c107c959315ae52166dac96fe2fe0c2a5e /Makefile
parentWell well well that wasn't too bad, now remake everything (diff)
download42-minishell-c9e4fb6e2ad07e13cf41d6ce6afad30b04011765.tar.gz
42-minishell-c9e4fb6e2ad07e13cf41d6ce6afad30b04011765.tar.bz2
42-minishell-c9e4fb6e2ad07e13cf41d6ce6afad30b04011765.tar.xz
42-minishell-c9e4fb6e2ad07e13cf41d6ce6afad30b04011765.tar.zst
42-minishell-c9e4fb6e2ad07e13cf41d6ce6afad30b04011765.zip
Solid base
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile96
1 files changed, 48 insertions, 48 deletions
diff --git a/Makefile b/Makefile
index a024d25..3196174 100644
--- a/Makefile
+++ b/Makefile
@@ -1,78 +1,80 @@
-# **************************************************************************** #
-# 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
+default: all
#==============================================================================#
-#--------------------------------- Shell --------------------------------------#
+#--------------------------------- SHELL --------------------------------------#
#==============================================================================#
SHELL := /bin/sh
#==============================================================================#
-#------------------------------ Directories -----------------------------------#
+#------------------------------ DIRECTORIES -----------------------------------#
#==============================================================================#
SRCS_DIR = src/
OBJS_DIR = obj/
LFT_DIR = libft/
-INCS_DIR = inc/
-LFT_INCS_DIR = ${LFT_DIR}/inc/
+LFT_INCS_DIR = ${LFT_DIR}inc/
+LFT_SRCS_DIR = ${LFT_DIR}src/
#==============================================================================#
-#--------------------------------- Files --------------------------------------#
+#--------------------------------- 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_NAME = minishell.c
+SRCS_NAME += ft_s_init.c
+SRCS_NAME += ft_s_destroy.c
+#------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR}, ${SRCS_NAME})
#------------------------------------------------------------------------------#
+INCS_NAME = ft_s_struct.h
+INCS_NAME += ft_d_enum.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 ------------------------------------#
+#-------------------------------- COMPILER ------------------------------------#
#==============================================================================#
CC = clang
-CFLAGS = -Wall
+CFLAGS = -std=c89
+CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Werror
-CFLAGS += ${DEBUG}
-CFLAGS += ${FSANITIZE}
+CFLAGS += -pedantic
#------------------------------------------------------------------------------#
-DEBUG = -glldb
-FSANITIZE = -fsanitize=address
+CDEFS = -DFT_HISTFILE=${HISTFILE}
#------------------------------------------------------------------------------#
-NAME = minishell
+LDFLAGS = -L${LFT_DIR}
+LDFLAGS += -lft
#==============================================================================#
#--------------------------------- UNIX ---------------------------------------#
#==============================================================================#
RM = rm -rf
MKDIR = mkdir -p
#==============================================================================#
-#--------------------------------- Rules --------------------------------------#
+#--------------------------------- RULES --------------------------------------#
#==============================================================================#
-${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS_DIR}minishell.h ${LFT_INCS_DIR}libft.h
+LFTRULE = all
+#------------------------------------------------------------------------------#
+${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS}
@${MKDIR} ${OBJS_DIR}
- ${CC} ${CFLAGS} -I${INCS_DIR} -I${LFT_INCS_DIR} -o $@ -c $<
+ ${CC} -c ${CFLAGS} ${CDEFS} -I${SRCS_DIR} -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}
#------------------------------------------------------------------------------#
-$(NAME): ${OBJS}
- ${CC} ${CFLAGS} -o ${NAME} ${OBJS} -L${LFT_DIR} -l${LFT}
+debug: CFLAGS += -ggdb
+debug: LFTRULE = debug
+debug: all
#------------------------------------------------------------------------------#
-all:
- @$(MAKE) --no-print-directory -C ${LFT_DIR} all
- @printf "\n"
- @$(MAKE) --no-print-directory ${NAME}
+asan: CFLAGS += -ggdb
+asan: CFLAGS += -fsanitize=address
+asan: LFTRULE = asan
+asan: all
#------------------------------------------------------------------------------#
clean:
@$(MAKE) --no-print-directory -C ${LFT_DIR} clean
@@ -80,10 +82,8 @@ clean:
#------------------------------------------------------------------------------#
fclean: clean
@$(MAKE) --no-print-directory -C ${LFT_DIR} fclean
- ${RM} ${NAME}
- ${RM} ${NAME}.dSYM/
- ${RM} joe-sh_history
+ ${RM} ${NAME} ${NAME}.dSYM/ ${HISTFILE}
#------------------------------------------------------------------------------#
re: fclean all
#------------------------------------------------------------------------------#
-.PHONY: all clean clean fclean re
+.PHONY: all clean clean fclean re debug asan