-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (80 loc) · 2.49 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
_RED = \e[31m
_GREEN = \e[32m
_YELLOW = \e[33m
_BLUE = \e[34m
_END = \e[0m
CC = gcc
CC_FLAGS = -Wall -Wextra -Werror -fno-builtin
DIR_HEADERS = ./includes/
DIR_SRCS = ./srcs/
DIR_OBJS = ./compiled_srcs/
DIR_TESTS = ./tests/
SRCS = ft_ssl.c \
opt_arg.c \
args.c \
logs.c \
utils.c \
hash/process.c \
hash/md5.c \
hash/sha256.c \
hash/sha224.c \
hash/sha512.c \
hash/sha384.c \
cipher/process.c \
cipher/base64.c \
cipher/des-ecb.c \
cipher/des-cbc.c \
std/process.c \
std/genrsa.c \
std/rsa.c \
std/rsautl.c \
std/asn1.c
INCLUDES = ft_ssl.h \
cipher.h \
hash.h \
error.h
OBJS = $(SRCS:%.c=$(DIR_OBJS)%.o)
DEPS = $(SRCS:%.c=$(DIR_OBJS)%.d)
NAME = ft_ssl
LIB = libft_ssl.a
ifeq ($(BUILD),debug)
CC_FLAGS += -DDEBUG -g3 -fsanitize=address
DIR_OBJS = ./debug-compiled_srcs/
NAME = ./debug-ft_ssl
endif
all: $(NAME)
test: $(LIB) $(NAME)
@make -C $(DIR_TESTS)
@printf "\033[2K\r$(_BLUE)Testing Library... $(_END)\n"
$(DIR_TESTS)ftest_ssl
@printf "\033[2K\r$(_BLUE)Testing Executable... $(_END)\n"
$(DIR_TESTS)test_script.sh
$(LIB): $(filter-out $(DIR_OBJS)ft_ssl.o ,$(OBJS)) $(addprefix $(DIR_HEADERS), $(INCLUDES))
@printf "\033[2K\r$(_BLUE) All files compiled into '$(DIR_OBJS)'. $(_END)✅\n"
@ar rc $(LIB) $(filter-out $(DIR_OBJS)ft_ssl.o, $(OBJS))
@ranlib $(LIB)
@printf "\033[2K\r$(_GREEN) Library '$(LIB)' created. $(_END)✅\n"
$(NAME): $(OBJS) $(addprefix $(DIR_HEADERS), $(INCLUDES))
@printf "\033[2K\r$(_BLUE) All files compiled into '$(DIR_OBJS)'. $(_END)✅\n"
@$(CC) $(CC_FLAGS) -I $(DIR_HEADERS) $(OBJS) -o $(NAME) -lm
@printf "\033[2K\r$(_GREEN) Executable '$(NAME)' created. $(_END)✅\n"
$(OBJS): | $(DIR_OBJS)
$(DIR_OBJS)%.o: $(DIR_SRCS)%.c Makefile # Recompile if Makefile change
@mkdir -p $(dir $@)
@printf "\033[2K\r $(_YELLOW)Compiling $< $(_END)⌛ "
@$(CC) $(CC_FLAGS) -MMD -MP -I $(DIR_HEADERS) -c $< -o $@
-include $(DEPS)
$(DIR_OBJS):
@mkdir -p $(DIR_OBJS)
clean:
@rm -rf $(DIR_OBJS)
@printf "\033[2K\r$(_RED) '"$(DIR_OBJS)"' has been deleted. $(_END)🗑️\n"
fclean: clean
@make fclean -C $(DIR_TESTS)
@rm -rf $(LIB)
@printf "\033[2K\r$(_RED) '"$(LIB)"' has been deleted. $(_END)🗑️\n"
@rm -rf $(NAME)
@printf "\033[2K\r$(_RED) '"$(NAME)"' has been deleted. $(_END)🗑️\n"
re: fclean
@$(MAKE) --no-print-directory
.PHONY: all clean fclean re test