-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (52 loc) · 2.42 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jdaufin <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/10/15 18:18:37 by jdaufin #+# #+# #
# Updated: 2021/04/30 10:26:03 by jdaufin ### ########lyon.fr #
# #
# **************************************************************************** #
.PHONY: demo re clean bclean fclean authorize
CC = clang
CFLAGS = -Wall -Wextra -Werror
NAME = ft_ping
SRCDIR = srcs/
OBJDIR = builds/
HDRDIR = includes/
LIBDIR = libft/
LIBHDRDIR = $(addsuffix includes/, $(LIBDIR))
FILES = ft_ping parse_args set_options show_help show_errors parse_address \
resolve_address dynarray_init dynarray_add dynarray_free \
dynarray_getbuflen handle_cycle send_echo handle_reply \
handle_reply_utils exit_ping exit_ping_utils send_echo_reply \
icmp_checksum wait_cooldown translate_icmp_codes
SRC = $(addprefix $(SRCDIR), $(addsuffix .c, $(FILES)))
OBJ = $(addprefix $(OBJDIR), $(addsuffix .o, $(FILES)))
HDR = $(addprefix $(HDRDIR), ft_ping.h)
LIBHDR = $(addprefix $(LIBHDRDIR), libft.h)
LIB = $(addprefix $(LIBDIR), libft.a)
$(NAME) :$(OBJ) $(LIB)
$(CC) $(CFLAGS) -o $@ $^ -I $(HDRDIR) -L $(LIBDIR) -lft
$(LIB) :
make -C $(LIBDIR)
$(OBJDIR)%.o : $(SRCDIR)%.c $(HDR) $(LIBHDR)
[ -d $(OBJDIR) ] || mkdir $(OBJDIR)
$(CC) $(CFLAGS) -o $@ -c $< -I $(HDRDIR) -I $(LIBHDRDIR)
bclean :
rm -rf $(OBJDIR)
clean : bclean
make -C $(LIBDIR) clean
fclean : bclean
make -C $(LIBDIR) fclean
rm -rf $(NAME)
re : fclean $(NAME)
demo : authorize
@echo "\n\e[32mBasic usage\e[0m : $(NAME) -c 4 8.8.8.8" && ./$(NAME) -c 4 8.8.8.8
@echo "\n\e[31mInsufficient TTL\e[0m : $(NAME) -c 5 google.com -t 3" && ./$(NAME) -c 5 google.com -t 3
@echo "\n\e[31mInsufficient TTL (verbose mode)\e[0m : $(NAME) -c 5 google.com -t 3 -v" && ./$(NAME) -c 5 google.com -t 3 -v
authorize : $(NAME)
@sudo setcap cap_net_raw=pe $(NAME)
@getcap $(NAME)