-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (67 loc) · 2.92 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jackson <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/03/03 12:06:08 by jbeall #+# #+# #
# Updated: 2019/06/13 19:21:58 by jackson ### ########.fr #
# #
# **************************************************************************** #
#==================================== GENERAL =================================#
NAME = nibbler
CPPFLAGS = -Wall -Wextra -Werror -std=c++11 #-Ofast #-fsanitize=address
SRC_DIR = ./src/
LIB_DIR = ./lib/
#=================================== SOURCES ==================================#
LIST = main \
Game \
Snake
SRC = $(addsuffix .cpp, $(addprefix $(SRC_DIR), $(LIST)))
#=================================== OBJECTS ==================================#
OBJ_DIR = .obj/
OBJ = $(addsuffix .o, $(addprefix $(OBJ_DIR), $(LIST)))
DEP = $(OBJ:%.o=%.d)
#=================================== HEADERS ==================================#
#INC_DIR = ./src/
#INC = -I $(INC_DIR)
LIB = -ldl
#==================================== COLORS ==================================#
#COLORS
COM_COLOR = \033[92m
NO_COLOR = \033[m
#TEXT
COM_STRING = "$(NAME) compilation successful"
CLEAN_OBJ = "cleaned $(NAME) objects"
CLEAN_NAME = "cleaned $(NAME) binary"
CLEAN_LIB = "cleaned $(name) libraries"
#===================================== RULES ==================================#
all: obj $(NAME)
$(NAME): $(OBJ)
@echo "linking..."
@clang++ $(CPPFLAGS) $(LIB) $^ -o $@
@echo "$(COM_COLOR) $(COM_STRING) $(NO_COLOR)"
-include $(DEP)
$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp
@printf "compiling: %s\n" $<
@clang++ $(CPPFLAGS) $(INC) -MMD -g -c $< -o $@
dylib:
@mkdir -p $(LIB_DIR)
@clang++ -std=c++11 -g -shared -fPIC -lncurses -o $(LIB_DIR)lib1.dylib $(SRC_DIR)Render1.cpp
@echo "lib1 successfully built!"
@clang++ -std=c++11 -g -shared -fPIC `pkg-config --cflags --libs sdl2` -lSDL2_ttf -o $(LIB_DIR)lib2.dylib $(SRC_DIR)Render2.cpp
@echo "lib2 successfully built!"
@clang++ -std=c++11 -g -shared -fPIC `pkg-config --cflags --libs sdl2` -l SDL2_ttf -l SDL2_image -o $(LIB_DIR)lib3.dylib $(SRC_DIR)Render3.cpp
@echo "lib3 successfully built!"
obj:
@mkdir -p $(OBJ_DIR)
clean:
@rm -rf $(OBJ_DIR)
@echo "$(COM_COLOR)$(CLEAN_OBJ)$(NO_COLOR)"
@rm -rf $(LIB_DIR)
@echo "$(COM_COLOR)$(CLEAN_LIB)$(NO_COLOR)"
fclean: clean
@rm -f $(NAME)
@echo "$(COM_COLOR)$(CLEAN_NAME)$(NO_COLOR)"
re: fclean all