Files
ft_ping/Makefile
vauden 26d9f40030 Added bonus and refactor again
Added the following flags :
-c to make a NUMBER of pings
-f to add flood mode
-i to set an interval of NUMBER seconds between pings
-l to send a NUMBER of pings as fast as possible then swapping to normal mode
-q to add quiet mode

Refactored main.c :
Made flags.c for avoiding the main() function becoming a masterclass and make the file more readable
Moved some function from main.c to utils.c

Made some change to mimic the behavior of the ping binary of inetutils2.0
2024-11-16 02:23:41 +01:00

54 lines
857 B
Makefile

NAME = ./ft_ping
SRCS = src/main.c \
src/utils.c \
src/flags.c
OBJ_DIR = objs
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.c=.o))
CC = clang
CFLAGS = -Wall -Wextra -Werror -I includes
DEBUG ?= false
MODE = "release"
TOOLCHAIN ?= clang
ifeq ($(TOOLCHAIN), gcc)
CC = gcc
endif
ifeq ($(DEBUG), true)
CFLAGS += -g -D DEBUG
MODE = "debug"
endif
RM = rm -rf
$(OBJ_DIR)/%.o: %.c
@echo "\e[1;32m[compiling "$(MODE)" {"$(CC)"}...]\e[1;00m "$<
@$(CC) $(CFLAGS) $(COPTS) -c $< -o $@
all: $(NAME)
$(NAME): $(OBJ_DIR) $(OBJS)
@echo "\e[1;32m[linking "$(MODE)" {"$(CC)"}...]\e[1;00m "$@
@$(CC) -o $(NAME) $(OBJS) -lm
@echo "\e[1;32m[build finished]\e[1;00m"
$(OBJ_DIR):
@mkdir -p $(sort $(addprefix $(OBJ_DIR)/, $(dir $(SRCS))))
clean:
@$(RM) $(OBJ_DIR)
fclean: clean
@$(RM) $(NAME)
re: fclean all
.PHONY: all clean fclean re