-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
113 lines (85 loc) · 3.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mabbas <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/08/08 21:06:32 by mabbas #+# #+# #
# Updated: 2022/12/10 14:54:39 by mabbas ### ########.fr #
# #
# **************************************************************************** #
NAME = fractol
#define compiler and flags for Debugger
CC = gcc
CFLAGS = -Wall -Werror -Wextra -I ./includes/fractol.h
# Including the directories
LIBFT = ./libs/libft/
#MINILIBX = ./libs/minilibx-linux/libmlx.a
MLX := ./libs/minilibx-linux/
# SRCS = ./src
SRCS = $(wildcard ./src/*.c)
# Making it cross-platform
OS := $(shell uname -s)
# Choice for mac/linux version
ifeq ($(OS),Windows_NT)
NAME := $(addsuffix .exe, $(NAME))
else ifeq ($(OS), Darwin)
MLX_DIR = libs/minilibx-linux/libmlx.a
LIBFLAGS = -framework OpenGL -framework AppKit -lm -lmlx -I -L/libs/minilibx-linux/libmlx_linux.a
endif
OBJS = $(SRCS:.c=.o)
# Color Codes
SUBM_STATE := $(shell find libs/libft -type f && libs/minilibx-linux -type f)
ifeq ($(SUBM_STATE),)
SUBM_FLAG = submodule
else
SUBM_FLAG =
endif
NC := \033[m
B_RED := \033[1;31m
RED := \033[0;31m
B_GREEN := \033[1;32m
GREEN := \033[0;33m
B_BLUE := \033[1;34m
BLUE := \033[0;34m
PURPLE := \033[0;35m
WHCOLOR := \033[0;40m
##Check for Linux and run Valgrind when debugger on
UNAME = $(shell uname -s)
ifeq ($(UNAME),Linux)
VALGRIND = valgrind -q --leak-check=full --track-origin=yes
else
detected_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
endif
all: $(SUBM_FLAG) libft mlx $(NAME)
%.o : %.c
@$(CC) $(CFLAGS) -c $< -o $@
submodule:
git submodule init
git submodule update
libft:
@echo "____!!!$(BLUE)----- Compiling Libft------$(NC)"
@$(MAKE) -C $(LIBFT)
@$(MAKE) -C $(LIBFT) bonus
@echo "Compilation of Libft: \033[1;32mOK\033[m"
mlx:
@echo "____!!!$(RED)----- Compiling mlx ------$(NC)"
@$(MAKE) -C $(MLX)
@echo "Creation of MLX: \033[1;32mOK\033[m"
$(NAME): $(OBJS)
@$(CC) $(CFLAGS) $(OBJS) $(LIBFLAGS) $(MLX_DIR) $(LIBFT)libft.a -o $(NAME)
@echo "Compilation of Fractol: \033[1;32mSUCCESS\033[m"
# Clean up your trashes
clean:
@echo "$(GREEN)♻️ ${B_RED} Trashing Away objects..... $(GREEN)♻️ "
@rm -f $(OBJS)
@$(MAKE) -C $(LIBFT) clean
@$(MAKE) -C $(MLX) clean
@sleep 0.5
@echo " $(B_RED) Cleaning Done $(NC)"
fclean: clean
@rm -f $(NAME)
@echo "$(GREEN)♻️ ${B_RED} Trashing Away all objects and library...."
re: fclean all
.phony: all libft clean fclean mlx