-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (38 loc) · 921 Bytes
/
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
NAME = Gbmu
SRCS_DIR = srcs/
OBJ_DIR = obj/
INC_DIR = includes/
CXX = clang++
CFLAGS = -Wall -Wextra -c -std=c++11
IFLAGS = -I $(INC_DIR)
INC_FILES = Cartridge.class.hpp \
Cpu.class.hpp \
Gb.class.hpp \
Memory.class.hpp \
Registers.class.hpp \
Instructions.class.hpp
SRCS_FILES = main.cpp \
Gb.cpp \
Cartridge.cpp \
Cpu.cpp \
Memory.cpp \
Registers.cpp \
Instructions.cpp
OBJ_FILES = $(SRCS_FILES:.cpp=.o)
OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILES))
INC = $(addprefix $(INC_DIR), $(INC_FILES))
all: $(OBJ_DIR) $(NAME)
$(NAME): $(OBJ)
$(CXX) $(IFLAGS) -o $@ $^ $(LFLAGS)
# @$ is the target (here $(OBJ_DIR))
$(OBJ_DIR):
mkdir -p $@
# $@ is the target, $< iterates over each dependency
$(OBJ_DIR)%.o: $(SRCS_DIR)%.cpp $(INC)
$(CXX) $(CFLAGS) $(IFLAGS) -o $@ $<
clean:
rm -rf $(OBJ_DIR)
fclean: clean
rm -rf $(NAME)
re: fclean all
.PHONY: all clean fclean re