Adding the minilibx and updated the makefile

This commit is contained in:
Raphael 2024-11-08 11:46:08 +01:00
parent b85a8ddeed
commit 0391323626
3 changed files with 29 additions and 22 deletions

View file

@ -6,11 +6,10 @@
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ # # By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
# Updated: 2024/11/01 12:17:05 by rparodi ### ########.fr # # Updated: 2024/11/08 11:45:04 by rparodi ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
# Variables # Variables
# Name # Name
@ -24,18 +23,24 @@ RM = rm -rf
# Flags # Flags
CFLAGS = -Werror -Wextra -Wall CFLAGS = -Werror -Wextra -Wall
CFLAGS += -g3 -MMD CFLAGS += -g3 -MMD
# CFLAGS += -fsanitize=address # CFLAGS += -fsanitize=address
# CFLAGS += -fsanitize=thread # CFLAGS += -fsanitize=thread
INCLUDES = -I ./includes/ -I ./includes/libft/ INCLUDES = -I ./includes/ -I ./includes/libft/ -I ./minilibx-linux
# Paths
LIBFT_DIR = ./libft
LIBFT_PERSONAL_DIR = ./libft_personal
MLX_DIR = ./minilibx-linux
# Library flags # Library flags
LDFLAGS = -L./build -lft -lft_personal -lm
LDFLAGS =\ # MiniLibX flags for macOS with XQuartz
-L./build -lft -lft_personal MLXFLAGS = -L$(MLX_DIR) -lmlx -L/opt/X11/lib -lX11 -lXext -lXrender -lXrandr -lXi
# -lm \ # Add MLXFLAGS to the linker flags
LDFLAGS += $(MLXFLAGS)
SRC = sources/main.c \ SRC = sources/main.c \
sources/error.c \ sources/error.c \
@ -53,7 +58,7 @@ GOLD = \033[38;5;220m
END = \033[0m END = \033[0m
# Rules # Rules
#
# All (make all) # All (make all)
all: header $(NAME) footer all: header $(NAME) footer
@ -61,7 +66,7 @@ all: header $(NAME) footer
bonus: header $(OBJ) footer bonus: header $(OBJ) footer
@mkdir -p $(OBJDIRNAME) @mkdir -p $(OBJDIRNAME)
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n' @printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
@cc $(CFLAGS) -D BONUS=1 -o $(NAME_BONUS) $(OBJ) $(LDFLAGS) @$(CC) $(CFLAGS) -D BONUS=1 -o $(NAME_BONUS) $(OBJ) $(LDFLAGS)
# Clean (make clean) # Clean (make clean)
clean: clean:
@ -79,25 +84,25 @@ fclean: clean
# Restart (make re) # Restart (make re)
re: header fclean all re: header fclean all
# Compile external libraries
build/libft.a: build/libft.a:
@make --no-print-directory -C ./libft @make --no-print-directory -C $(LIBFT_DIR)
build/libft_personal.a: build/libft_personal.a:
@make --no-print-directory -C ./libft_personal @make --no-print-directory -C $(LIBFT_PERSONAL_DIR)
build/libmlx.a:
build/mlx.a: @make --no-print-directory -C $(MLX_DIR)
@./minilibx-linux/configure
# Dependences for all # Dependences for all
$(NAME): $(OBJ) build/libft.a build/libft_personal.a build/mlx.a $(NAME): $(OBJ) build/libft.a build/libft_personal.a build/libmlx.a
@mkdir -p $(OBJDIRNAME) @mkdir -p $(OBJDIRNAME)
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n' @printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
@cc $(CFLAGS) ./build/libft.a -o $(NAME) $(OBJ) $(LDFLAGS) @$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $(NAME)
# Creating the objects # Creating the objects
$(OBJDIRNAME)/%.o: %.c $(OBJDIRNAME)/%.o: %.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
@cc $(CFLAGS)-o $@ -c $< $(INCLUDES) @$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<
# Header # Header
header: header:
@ -130,7 +135,7 @@ footer:
@printf "$(GOLD) '\"' '\"'$(END)\n" @printf "$(GOLD) '\"' '\"'$(END)\n"
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n' @printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
# Phony # Phony targets
.PHONY: all bonus clean fclean re .PHONY: all bonus clean fclean re
-include ${OBJ:.o=.d} -include ${OBJ:.o=.d}

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */ /* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
/* Updated: 2024/10/31 16:54:38 by rparodi ### ########.fr */ /* Updated: 2024/11/08 11:40:44 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,6 +22,7 @@
# include <stdbool.h> # include <stdbool.h>
# include "libft.h" # include "libft.h"
# include "../minilibx-linux/mlx.h"
# include "message_error.h" # include "message_error.h"
# ifndef BONUS # ifndef BONUS

1
minilibx-linux Submodule

@ -0,0 +1 @@
Subproject commit 7dc53a411a7d4ae286c60c6229bd1e395b0efb82