|
| 1 | +# **************************************************************************** # |
| 2 | +# # |
| 3 | +# ::: :::::::: # |
| 4 | +# Makefile :+: :+: :+: # |
| 5 | +# +:+ +:+ +:+ # |
| 6 | +# By: World 42 <[email protected]> +#+ +:+ +#+ # |
| 7 | +# +#+#+#+#+#+ +#+ # |
| 8 | +# Created: 2014/11/03 14:55:19 by ale-batt #+# #+# # |
| 9 | +#* Updated: 2017/03/14 17:55:28 by ale-batt ### ########.fr *# |
| 10 | +# # |
| 11 | +# **************************************************************************** # |
| 12 | + |
| 13 | +NAME = ft_nmap |
| 14 | + |
| 15 | +C_DIR = sources |
| 16 | +O_DIR = .objs/ |
| 17 | +H_DIRS = includes |
| 18 | + |
| 19 | +LIBFT = ./libft |
| 20 | +LIBNETWORK = ./libnetwork |
| 21 | + |
| 22 | +CC = gcc |
| 23 | +FLAGS = -Wall -Werror -Wextra |
| 24 | +FLAGS += -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-function |
| 25 | + |
| 26 | +C_DIRS = $(shell find $(C_DIR) -type d -follow -print) |
| 27 | +C_FILES = $(shell find $(C_DIR) -type f -follow -print | grep ".*\.c$$") |
| 28 | +H_FILES = $(shell find includes -type f -follow -print | grep ".*\.h$$") |
| 29 | +O_DIRS = $(C_DIRS:$(C_DIR)%=$(O_DIR)%) |
| 30 | +O_FILES = $(C_FILES:$(C_DIR)%.c=$(O_DIR)%.o) |
| 31 | + |
| 32 | +# Verbose mode |
| 33 | +V = 0 |
| 34 | +# debug mode |
| 35 | +G = 0 |
| 36 | + |
| 37 | +LIB += -L$(LIBNETWORK) -lnetwork |
| 38 | +LIB += -L$(LIBFT) -lft |
| 39 | + |
| 40 | +INCLUDES = -I./$(H_DIRS) -I$(LIBFT)/includes |
| 41 | +INCLUDES += -I$(LIBNETWORK)/includes |
| 42 | + |
| 43 | +C = \033[1;33m |
| 44 | +U = $(C)[$(NAME)]----->\033[0m |
| 45 | +SKIP = $(SKIP_$(V)) |
| 46 | +SKIP_1 := |
| 47 | +SKIP_0 := \033[A |
| 48 | +W := o |
| 49 | +BART := $(shell echo '$(O_FILES)'|wc -w|tr -d ' ') |
| 50 | +BARC = $(words $W)$(eval W := o $W) |
| 51 | +BAR = $(shell printf "%`expr $(BARC) '*' 100 / $(BART)`s" | tr ' ' '=') |
| 52 | + |
| 53 | +#--------------------------------------------------------------------# |
| 54 | + |
| 55 | +all : $(LIBFT)/libft.a $(LIBNETWORK)/libnetwork.a $(O_DIRS) $(NAME) |
| 56 | + |
| 57 | +$(LIBFT)/libft.a: |
| 58 | + @make -C $(LIBFT) |
| 59 | + |
| 60 | +$(LIBNETWORK)/libnetwork.a: |
| 61 | + @make -C $(LIBNETWORK) |
| 62 | + |
| 63 | +$(O_DIRS): |
| 64 | + @mkdir -p $(O_DIR) $(O_DIRS) |
| 65 | + |
| 66 | +$(NAME) : $(O_FILES) |
| 67 | + @echo "$(U)$(C)[COMPILE:\033[1;32m DONE$(C)]" |
| 68 | + @echo "$(U)$(C)[BUILD]\033[0;32m" |
| 69 | + @$(CC) $(FLAGS) -o $(NAME) $(O_FILES) $(LIB) |
| 70 | + @echo "$(SKIP)$(U)$(C)[BUILD :\033[1;32m DONE$(C)]\033[0m\033[K" |
| 71 | + |
| 72 | +$(O_DIR)%.o: $(C_DIR)%.c $(H_FILES) |
| 73 | + @echo "$(U)$(C)[COMPILE: \033[1;31m$<\033[A\033[0m" |
| 74 | + @echo "\033[0;32m" |
| 75 | + @$(CC) $(FLAGS) $(INCLUDES) -c $< -o $@ |
| 76 | + @printf "\033[1;31m[%-100s] %s%%\n" $(BAR) `echo $W|wc -w|tr -d ' '` |
| 77 | + @echo "$(SKIP)\033[A\033[2K$(SKIP)" |
| 78 | + |
| 79 | +clean : |
| 80 | + @rm -rf $(O_FILES) |
| 81 | + @echo "$(U)$(C)[CLEAN]\033[0;32m" |
| 82 | + @echo "$(SKIP)$(U)$(C)[CLEAN:\033[1;32m DONE$(C)]\033[0m" |
| 83 | +# @make -C $(LIBFT) clean |
| 84 | + @make -C $(LIBNETWORK) clean |
| 85 | + |
| 86 | +fclean : clean |
| 87 | + @echo "$(U)$(C)[F-CLEAN]\033[0;32m" |
| 88 | + @rm -rf $(NAME) |
| 89 | + @echo "$(SKIP)$(U)$(C)[F-CLEAN:\033[1;32m DONE$(C)]\033[0m" |
| 90 | +# @make -C $(LIBFT) fclean |
| 91 | + @make -C $(LIBNETWORK) fclean |
| 92 | + |
| 93 | +lib : |
| 94 | + @make -C $(LIBFT) re |
| 95 | + @make -C $(LIBNETWORK) re |
| 96 | + |
| 97 | +re : fclean all |
| 98 | + |
| 99 | +#------------------MY RULES ---------------------------------# |
| 100 | + |
| 101 | +exe : all |
| 102 | + @./$(NAME) |
| 103 | +norme : |
| 104 | + norminette $(SRCS) $(HEADER) |
| 105 | +gdb : all |
| 106 | + gdb $(NAME) |
| 107 | + |
| 108 | +correc : |
| 109 | + cat -e auteur |
| 110 | + norminette **/*.[ch] |
0 commit comments