-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (28 loc) · 718 Bytes
/
Makefile
File metadata and controls
40 lines (28 loc) · 718 Bytes
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
NAME=ft_ping
CC=gcc
CFLAGS=-Wall -Wextra -Werror -g -O3
LDFLAGS=-lm
INCLUDE_DIR=include
INCLUDE_EXT=h
INCLUDE=$(shell find $(INCLUDE_DIR) -type f -name "*.$(INCLUDE_EXT)")
SRC_EXT=c
SRC_DIR=src
SRC=$(shell find $(SRC_DIR) -type f -name "*.$(SRC_EXT)")
OBJ_DIR=obj
OBJ=$(patsubst $(SRC_DIR)/%.$(SRC_EXT),$(OBJ_DIR)/%.o,$(SRC))
all: $(NAME)
$(NAME): $(OBJ_DIR) $(OBJ)
$(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
@echo $(NAME) created
$(OBJ_DIR):
@mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.$(SRC_EXT) $(INCLUDE) | $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@
clean:
@rm -rf $(OBJ_DIR)
@echo $(OBJ_DIR) removed
fclean: clean
@rm -f $(NAME)
@echo $(NAME) removed
re: fclean all
.PHONY: all clean fclean re