-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (72 loc) · 2.51 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: schetty <schetty@student.42kl.edu.my> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/10/04 16:52:35 by schetty #+# #+# #
# Updated: 2021/10/08 17:46:16 by schetty ### ########.fr #
# #
# **************************************************************************** #
# Compiler and Linker
CC := gcc
# Target Binary Program
NAME := minitalk
# Directories
OBJDIR := obj/
FTPRINTFDIR := ft_printf/
FTPRINTF := ft_printf/libftprintf.a
# Flags, Libraries and Includes
CFLAGS := -Wall -Wextra -Werror
# Functions
ARCHIVE := ar rc
INDEXER := ranlib
DELETE := rm -f
CREATEDIR := mkdir -p
DELETEDIR := rm -Rf
# Colors
RED := "\033[1;31m"
GRN := "\033[1;32m"
YLW := "\033[1;33m"
CLR := "\033[0m"
# Source, Objects and Resources
CLIENTSOURCE:= client.c utils.c
SERVERSOURCE:= server.c
# Defauilt Make
all : outdir $(NAME)
outdir :
@ $(CREATEDIR) $(OBJDIR)
server : $(FTPRINTF)
@ $(CC) $(CFLAGS) $(SERVERSOURCE) $(FTPRINTF) -o server
client : $(FTPRINTF)
@ $(CC) $(CFLAGS) $(CLIENTSOURCE) $(FTPRINTF) -o client
bonus : outdir $(NAME)
# Link
$(NAME) : server client
@ echo $(GRN)$(NAME)$(CLR) Generated Successfully!
$(FTPRINTF) :
@ $(MAKE) -C $(FTPRINTFDIR) --no-print-directory
# Clean Objects
clean :
ifneq ($(wildcard $(OBJDIR)),)
@ $(MAKE) clean -C $(FTPRINTFDIR) --no-print-directory
@ $(DELETEDIR) $(OBJDIR)
@ echo $(YLW)$(basename $(NAME))$(CLR) Object Files Deleted!
else
@ echo No $(RED)$(basename $(NAME))$(CLR)Object Files To Remove..
endif
# Full Clean
fclean :
ifneq ($(wildcard server)$(wildcard client),)
@ $(MAKE) fclean -C $(FTPRINTFDIR) --no-print-directory
@ $(DELETE) server client
@ $(DELETEDIR) $(OBJDIR)
@ echo $(YLW)$(basename $(NAME))$(CLR) Binary \& Object Files Deleted!
else
@ echo No $(RED)$(basename $(NAME))$(CLR) Binary Or Object Files To Removed..
endif
# Recompile
re : fclean all
# Non-File Targets
.PHONY : all clean fclean re server client bonus