aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-01-23 15:18:45 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-01-23 15:18:45 +0100
commita6acf55cddec28eebf8d0e1c44603270d591cdee (patch)
treedff9c6d1075c05ee89631021e7211343e6949b28 /Makefile
parentDeleted libx (diff)
download42-cub3d-a6acf55cddec28eebf8d0e1c44603270d591cdee.tar.gz
42-cub3d-a6acf55cddec28eebf8d0e1c44603270d591cdee.tar.bz2
42-cub3d-a6acf55cddec28eebf8d0e1c44603270d591cdee.tar.xz
42-cub3d-a6acf55cddec28eebf8d0e1c44603270d591cdee.tar.zst
42-cub3d-a6acf55cddec28eebf8d0e1c44603270d591cdee.zip
Added back minilibx, added gitignore
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile82
1 files changed, 82 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index e69de29..eea9427 100644
--- a/Makefile
+++ b/Makefile
@@ -0,0 +1,82 @@
+default: run
+#==============================================================================#
+#--------------------------------- Shell --------------------------------------#
+#==============================================================================#
+SHELL := /bin/sh
+#==============================================================================#
+#------------------------------ Directories -----------------------------------#
+#==============================================================================#
+INCS_DIR = inc/
+SRCS_DIR = src/
+OBJS_DIR = obj/
+LFT_DIR = libft/
+MLX_DIR = minilibx/
+#==============================================================================#
+#--------------------------------- Files --------------------------------------#
+#==============================================================================#
+INCS = cub3d.h
+#------------------------------------------------------------------------------#
+SRCS_NAME = main.c
+#------------------------------------------------------------------------------#
+SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
+#------------------------------------------------------------------------------#
+OBJS = $(patsubst ${SRCS_DIR}%.c,${OBJS_DIR}%.o,${SRCS})
+#==============================================================================#
+#-------------------------------- Compiler ------------------------------------#
+#==============================================================================#
+CC = clang
+CFLAGS = -std=c89
+CFLAGS += -Wall
+CFLAGS += -Wextra
+CFLAGS += -Werror
+CFLAGS += -pedantic
+ifdef ASAN
+ CFLAGS += ${DEBUG}
+ CFLAGS += ${FSANITIZE}
+endif
+#------------------------------------------------------------------------------#
+DEBUG = -glldb
+FSANITIZE = -fsanitize=address
+#------------------------------------------------------------------------------#
+NAME = cub3d
+#==============================================================================#
+#--------------------------------- UNIX ---------------------------------------#
+#==============================================================================#
+MKDIR = mkdir -p
+RM = rm -rf
+#==============================================================================#
+#--------------------------------- Rules --------------------------------------#
+#==============================================================================#
+${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS_DIR}${INCS}
+ @${MKDIR} ${OBJS_DIR}
+ ${CC} -c ${CFLAGS} -I${LFT_DIR}${INCS_DIR} -I${INCS_DIR} -o $@ $<
+#------------------------------------------------------------------------------#
+${NAME}: ${OBJS}
+ ${CC} ${CFLAGS} -o $@ $< -L${LFT_DIR} -lft
+#------------------------------------------------------------------------------#
+all:
+ @$(MAKE) --no-print-directory -C ${MLX_DIR} all
+ifdef ASAN
+ @$(MAKE) --no-print-directory -C ${LFT_DIR} all ASAN=1
+else
+ @$(MAKE) --no-print-directory -C ${LFT_DIR} all
+endif
+ @$(MAKE) ${NAME}
+#------------------------------------------------------------------------------#
+clean:
+ @$(MAKE) --no-print-directory -C ${MLX_DIR} clean
+ @$(MAKE) --no-print-directory -C ${LFT_DIR} clean
+ ${RM} ${OBJS_DIR}
+#------------------------------------------------------------------------------#
+fclean: clean
+ @$(MAKE) --no-print-directory -C ${MLX_DIR} clean
+ @$(MAKE) --no-print-directory -C ${LFT_DIR} fclean
+ ${RM} ${NAME}
+#------------------------------------------------------------------------------#
+re: fclean all
+#------------------------------------------------------------------------------#
+run: all
+ ./${NAME}
+#------------------------------------------------------------------------------#
+.PHONY: all clean clean fclean re run default
+#==================================== EOF =====================================#