generated from naviisml/c-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 1.84 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
73
74
75
NAME = pipex
AR = @ar
AR_FLAGS = -rcs
COMPILER = @gcc
COMPILER_FLAGS = -Wall -Werror -Wextra -Iincludes/
# Configuration...
TEST_CASE = ./resources/input "ls -l" "wc -l"
# Libft...
LIBFT = libft.a
LIBFT_FOLDER = ./libraries/libft
# Build Folder
BUILD_FOLDER = ./build
BUILD_FILES = $(addprefix $(BUILD_FOLDER)/, $(LIBFT))
# Source Files...
SOURCE_FOLDER = ./srcs
SOURCE_FILES = utilities/utils.c \
utilities/file.c \
modules/env.c \
modules/process.c \
modules/pipe.c \
pipex.c
# Header Files...
# 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 clean fclean re dev
# 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): $(LIBFT) $(OBJECT_FILES)
@echo "Building \t$(NAME)... (100%)"
$(COMPILER) $(COMPILER_FLAGS) $(OBJECT_FILES) $(BUILD_FILES) -o $(NAME)
# Compile Libft...
$(LIBFT):
@echo "Compiling \t$(LIBFT)..."
@$(MAKE) all -C $(LIBFT_FOLDER)
@mkdir -p $(BUILD_FOLDER)
@mv $(addprefix $(LIBFT_FOLDER)/, $(LIBFT)) $(addprefix $(BUILD_FOLDER)/, $(LIBFT))
# Compile the bonus
bonus: $(NAME)
@echo "Building \t$(NAME) Bonus... (100%)"
$(COMPILER) $(COMPILER_FLAGS) $(OBJECT_FILES) $(BUILD_FILES) -o $(NAME)
# Compile the entire project
all: $(NAME)
# Remove the `object` folder and files...
clean:
@$(MAKE) clean -C $(LIBFT_FOLDER)
@rm -rf $(OBJECT_FILES) $(OBJECT_FOLDER) $(BUILD_FOLDER)
# Remove the `object` and `build` folder and files...
fclean: clean
@$(MAKE) fclean -C $(LIBFT_FOLDER)
@rm -rf $(NAME)
# Clean the program up and re-compile it...
re: fclean all