-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (47 loc) · 1.73 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: hbourgeo <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/09/30 19:37:13 by hbourgeo #+# #+# #
# Updated: 2022/04/21 11:31:03 by hbourgeo ### ########.fr #
# #
# **************************************************************************** #
NAME = libft.a
# Get DIR
INC_DIR = includes/
SRC_DIR = src/
OBJ_DIR = obj_$(basename $(NAME))/
# Edit FLAGS
CC = gcc
CFLAGS = -Wall -Werror -Wextra -I $(INC_DIR)
DEPS = $(shell find $(INC_DIR) -type f -name "*.h")
# Get .c and convert to .o
SRCS = $(notdir $(shell find $(SRC_DIR) -type f -name "*.c"))
OBJS = $(addprefix $(OBJ_DIR), $(SRCS:.c=.o))
# Add search path
VPATH = $(INC_DIR) $(OBJ_DIR) $(shell find $(SRC_DIR) -type d)
# make rules
all : $(NAME)
$(OBJ_DIR)%.o : %.c $(DEPS)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR) :
@mkdir -p $(OBJ_DIR)
$(NAME) : $(OBJ_DIR) $(OBJS)
@ar -rcs $(NAME) $(OBJS)
clean :
rm -rf $(OBJS)
rm -rf $(OBJ_DIR)
fclean : clean
rm -rf $(NAME)
re : fclean all
.PHONY : clean fclean all re
print-%: ; @echo $* = $($*)
# GIT
MSG = "default"
git:
@-git add .
@git commit -am "`date +'%Y-%m-%d %H:%M:%S'` | $(MSG)"
@-git push