-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (47 loc) · 2.02 KB
/
Copy pathMakefile
File metadata and controls
65 lines (47 loc) · 2.02 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
# **************************************************************************** #
# #
# ft_ping — recode of the inetutils ping (42 project) #
# #
# **************************************************************************** #
NAME := ft_ping
CC := cc
CFLAGS := -Wall -Wextra -Werror
LIBFT_DIR := vendor/libft
LIBFT := $(LIBFT_DIR)/build/lib/libft.a
CPPFLAGS := -Iinclude -I$(LIBFT_DIR)/include -I$(LIBFT_DIR) -D_GNU_SOURCE
SRCDIR := src
OBJDIR := obj
HEADER := include/ft_ping.h
SRCS := main.c args.c args2.c usage.c dns.c net.c sockopt.c ipts.c \
checksum.c send.c recv.c loop.c flood.c pattern.c print.c \
stats.c signal.c util.c
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
all: $(NAME)
# libft is an order-only prerequisite: rebuilding the archive must not relink
# ft_ping unless an object actually changed.
$(LIBFT):
$(MAKE) -C $(LIBFT_DIR) all
# Link the static archive by path: only the objects ft_ping references are
# pulled in (the prebuilt libft.so carries unrelated undefined symbols).
$(NAME): $(OBJS) | $(LIBFT)
$(CC) $(CFLAGS) $(OBJS) $(LIBFT) -o $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(HEADER) | $(OBJDIR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(OBJDIR):
mkdir -p $(OBJDIR)
clean:
rm -rf $(OBJDIR)
fclean: clean
rm -f $(NAME)
re: fclean all
# 42 norm check on project sources only (libft has its own verif_norm).
# Fail on real violations (Error!); the lone GLOBAL_VAR notice on the signal
# flag is permitted and justified, so notices/OK do not fail the gate.
norm:
@norminette include src | grep 'Error' && exit 1 || echo "norm: clean"
# project-scoped static analysis (the kit gate scans vendored libft too).
lint:
@cppcheck --enable=warning,style --error-exitcode=1 --quiet include src
bench: all
@sh bench/run.sh
.PHONY: all clean fclean re norm lint bench