-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (57 loc) · 1.94 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
65
66
67
68
69
70
71
72
# **************************************************************************** #
# #
# :::::::: #
# Makefile :+: :+: #
# +:+ #
# By: pde-bakk <marvin@codam.nl> +#+ #
# +#+ #
# Created: 2019/12/02 17:36:51 by pde-bakk #+# #+# #
# Updated: 2021/04/05 14:03:35 by pde-bakk ######## odam.nl #
# #
# **************************************************************************** #
NAME = libftprintf.a
INCLUDE = -I ./include_internal -I ./libft/include
SRC_DIR = src
BUILD_DIR = obj
SRC_EXT = c
OBJ_EXT = o
SOURCES := $(shell find $(SRC_DIR) -type f -name "*.$(SRC_EXT)")
OBJS := $(SOURCES:.$(SRC_EXT)=.$(OBJ_EXT))
OBJECTS := $(patsubst $(SRC_DIR)/%,$(BUILD_DIR)/%,$(OBJS))
LIBS = libft.a
FLAGS = -Wall -Werror -Wextra
ifdef DEBUG
FLAGS += -g -fsanitize=address
else
FLAGS += -Ofast
endif
# COLORS
SHELL := /bin/bash
PINK = \x1b[35;01m
BLUE = \x1b[34;01m
YELLOW = \x1b[33;01m
GREEN = \x1b[32;01m
RED = \x1b[31;01m
WHITE = \x1b[31;37m
RESET = \x1b[0m
all: $(NAME)
$(NAME): directories $(OBJECTS) $(LIBS)
@printf "$(YELLOW)Linking the library\n"
cp libft/libft.a $(NAME)
ar -rcs $(NAME) $(OBJECTS)
@printf "$(GREEN)Done!$(RESET)\n"
directories:
@mkdir -p $(BUILD_DIR)
%.a: %
$(MAKE) -C $<
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@$(CC) -c $(FLAGS) $(INCLUDE) $^ -o $@
clean:
@/bin/rm -f *.o *~ *.gch $(OBJECTS)
$(MAKE) $@ -C libft
fclean: clean
/bin/rm -f $(NAME)
$(MAKE) $@ -C libft
re: fclean all
bonus: re
@printf "$(PINK)Linking bonus files$(RESET)\n"