generated from naviisml/c-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (54 loc) · 1.62 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
NAME = libftprintf.a
AR = @ar
AR_FLAGS = -rcs
COMPILER = @gcc
COMPILER_FLAGS = -Wall -Werror -Wextra
# Configuration...
# Library...
LIBRARY = libft.a
LIBRARY_FOLDER = ./libft
# Source Files...
SOURCE_FOLDER = ./srcs
SOURCE_FILES = conversions/parse_fill.c \
conversions/parse_prefix.c \
conversions/parse_example.c \
flags/parse_string.c \
flags/parse_number.c \
flags/parse_hex.c \
parser.c \
ft_print.c \
ft_printf.c \
ft_fprintf.c \
# Object Files...
EXTRA_FOLDERS = $(SOURCE_FOLDER)
OBJECT_FOLDER = ./objects
OBJECT_FILES = $(addprefix $(OBJECT_FOLDER)/, $(addprefix $(SOURCE_FOLDER)/, $(SOURCE_FILES:.c=.o)))
.PHONY = $(NAME) $(LIBRARY) all library clean fclean re tester
# Compile the .c files to .o files...
$(OBJECT_FOLDER)/%.o: %.c
@mkdir -p $(OBJECT_FOLDER) $(addprefix $(OBJECT_FOLDER)/, $(dir $<))
@echo "Compiling \t$(notdir $<) (100%)"
@$(COMPILER) $(COMPILER_FLAGS) -c $< -o $@
# Compile the program...
$(NAME): $(OBJECT_FILES)
@echo "Building $(NAME)... (100%)"
$(AR) $(AR_FLAGS) $(NAME) $(OBJECT_FILES)
# Compile a library...
$(LIBRARY):
@echo "Compiling \t$(LIBRARY)..."
@$(MAKE) bonus -C $(LIBRARY_FOLDER)
@mv $(addprefix $(LIBRARY_FOLDER)/, $(LIBRARY)) $(NAME)
all: $(LIBRARY) $(NAME)
# Remove the `object` folder and files...
clean:
@$(MAKE) clean -C $(LIBRARY_FOLDER)
@rm -rf $(OBJECT_FILES) $(OBJECT_FOLDER)
# Remove the `object` and `build` folder and files...
fclean: clean
@$(MAKE) fclean -C $(LIBRARY_FOLDER)
@rm -rf $(NAME) $(LIBRARY)
# Clean the program up and re-compile it...
re: fclean all
# Run the tester (Helper)
tester: all
@$(MAKE) -C ./tester