-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·93 lines (75 loc) · 2.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/01/01 13:57:12 by akdovlet #+# #+# #
# Updated: 2024/05/22 16:51:32 by akdovlet ### ########.fr #
# #
# **************************************************************************** #
NAME := pipex
BNAME := pipex_bonus
LIBDIR := lib
LIBFT := $(LIBDIR)/libft/libft.a
SRC := ak_pipe.c \
ak_pipeout.c \
clear_exit.c \
cmd_exe.c \
dr_here.c \
env_access.c \
main.c \
open_infile.c \
open_outfile.c \
px_split.c \
seek_and_execute.c \
setup.c
BSRC := ak_pipe.c \
ak_pipeout.c \
clear_exit.c \
cmd_exe.c \
dr_here.c \
env_access.c \
main_bonus.c \
open_infile.c \
open_outfile.c \
px_split.c \
seek_and_execute.c \
setup.c
SRC_DIR := src
BUILD := .build
SRC := $(addprefix $(SRC_DIR)/, $(SRC))
BSRC := $(addprefix $(SRC_DIR)/, $(BSRC))
OBJ := $(patsubst $(SRC_DIR)/%.c, $(BUILD)/%.o, $(SRC))
BOBJ := $(patsubst $(SRC_DIR)/%.c, $(BUILD)/%.o, $(BSRC))
DEPS := $(OBJ:.o=.d)
BDEPS := $(BOBJ:.o=.d)
CC := cc
CFLAGS := -Wall -Werror -Wextra -MMD -MP -Iinclude -I$(LIBDIR)/libft/include -g
all: create_dirs $(NAME)
bonus: create_dirs $(BNAME)
both: all bonus
create_dirs: $(BUILD)
$(BUILD):
@if [ ! -d $(BUILD) ]; then mkdir $(BUILD); fi
$(NAME): $(OBJ) $(LIBFT)
@$(CC) $(CFLAGS) $(OBJ) $(LIBFT) -o $(NAME)
$(BNAME): $(BOBJ) $(LIBFT)
@$(CC) $(CFLAGS) $(BOBJ) $(LIBFT) -o $(BNAME)
$(BUILD)/%.o: $(SRC_DIR)/%.c
@$(CC) $(CFLAGS) -c $< -o $@
@printf "\033[1;32%sm\tCompiled: $<\033[0m\n";
$(LIBFT):
@$(MAKE) --no-print-directory -C $(LIBDIR)/libft
clean:
@if [ -d $(BUILD) ]; then $(RM) -rf $(BUILD) && echo "\033[1;31m\tDeleted: $(NAME) $(BUILD)\033[0m"; fi
@$(MAKE) --no-print-directory clean -C $(LIBDIR)/libft
fclean: clean
@if [ -f $(NAME) ]; then $(RM) -rf $(NAME) && echo "\033[1;31m\tDeleted: $(NAME)\033[0m"; fi
@if [ -f $(BNAME) ]; then $(RM) -rf $(BNAME) && echo "\033[1;31m\tDeleted: $(BNAME)\033[0m"; fi
@$(MAKE) --no-print-directory fclean -C $(LIBDIR)/libft
re: fclean all
-include $(DEPS)
-include $(BDEPS)
.PHONY: all create_dirs clean fclean re bonus both