-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (103 loc) · 4.26 KB
/
Makefile
File metadata and controls
133 lines (103 loc) · 4.26 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mfouadi <mfouadi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/03/14 10:52:24 by mfouadi #+# #+# #
# Updated: 2023/04/03 02:15:23 by mfouadi ### ########.fr #
# #
# **************************************************************************** #
# obj folder where .o files will be placed
OBJDIR := obj
# Directory of headers files
INCDIR := include
# Finding all .c files in the source directory and its subdirectories
SRC := mand_src/main.c \
mand_src/parsing.c \
mand_src/push_swap.c \
mand_src/push_swap_2.c \
mand_src/utils/utils.c \
mand_src/utils/utils2.c \
mand_src/utils/debbuging.c \
mand_src/utils/instructions.c \
mand_src/utils/instructions2.c \
mand_src/utils/instructions3.c \
BONUS_SRC = bonus_src/checker.c \
bonus_src/utils/instructions.c \
bonus_src/utils/instructions2.c \
bonus_src/utils/instructions3.c \
bonus_src/parsing_bonus.c \
mand_src/utils/utils.c \
mand_src/utils/utils2.c \
mand_src/utils/debbuging.c \
BONUS_NAME = checker
OBJ_BONUS := $(patsubst %, $(OBJDIR)/%,$(BONUS_SRC:.c=.o))
# patsubst ('pattern substitution') takes a pattern, a replacement string and a list of names
# List of object files to be generated
OBJ := $(patsubst %, $(OBJDIR)/%,$(SRC:.c=.o))
# Headers files
HEADERS := include/push_swap.h
#----------------------------------------------------------------------------------------------
# Variables
#----------------------------------------------------------------------------------------------
# Goal of this Makefile
NAME := push_swap
# Flags used in compilation
CFLAGS := -Werror -Wextra -Wall -I$(INCDIR)
# libft static archive
LIBFT_ARCHIVE = libft/libft.a
# Command used to rm files and obj directory
RM := /bin/rm -rf
#----------------------------------------------------------------------------------------------
# Terminal ANSI colors
#----------------------------------------------------------------------------------------------
HBLK = '\e[1;90m'
HRED = '\e[1;91m'
HGRN = '\e[1;92m'
HYEL = '\e[1;93m'
HBLU = '\e[1;94m'
HMAG = '\e[1;95m'
HCYN = '\e[1;96m'
HWHT = '\e[1;97m'
NC ='\033[0m'
#----------------------------------------------------------------------------------------------
# Main dependencies
#----------------------------------------------------------------------------------------------
# Ultimate Goal
all : $(NAME)
$(NAME) : libft_ar $(OBJ)
$(CC) $(CFLAGS) $(OBJ) $(LIBFT_ARCHIVE) -o $(NAME)
$(OBJDIR)/%.o : %.c $(HEADERS)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I../libft/inc -I$(HEADERS) -c $< -o $@
bonus : libft_ar $(OBJ_BONUS)
$(CC) $(CFLAGS) $(OBJ_BONUS) $(LIBFT_ARCHIVE) -o $(BONUS_NAME)
# Creates static archive 'libft.a'
libft_ar:
make -C libft
debug : libft_ar $(NAME) $(OBJ)
$(CC) $(CFLAGS) -fsanitize=address -g $(OBJ) $(LIBFT_ARCHIVE)
#----------------------------------------------------------------------------------------------
# Deleting object files
#----------------------------------------------------------------------------------------------
# Deletes object files
clean :
make -C libft clean
$(RM) $(OBJDIR)
# Deletes libft.a, and executable
fclean : clean
make -C libft fclean
$(RM) $(NAME) $(BONUS_NAME)
# re-compile all .c files
re : fclean all
#----------------------------------------------------------------------------------------------
# Special Built-in Target Names
#----------------------------------------------------------------------------------------------
# Words that do not represent files of the project
.Phony : all clean fclean re debug bonus libft_ar
# Prevents output of these targets from being printed
.SILENT : bonus $(NAME) clean fclean re libft_ar
# Makes 'all' the default target
.DEFAULT_GOAL := all