forked from mikim42/corewar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
200 lines (168 loc) · 5.1 KB
/
Copy pathMakefile
File metadata and controls
200 lines (168 loc) · 5.1 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mikim <mikim@student.42.us.org> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/01/21 19:53:23 by mikim #+# #+# #
# Updated: 2018/02/03 16:34:45 by ashih ### ########.fr #
# #
# **************************************************************************** #
SRC_VM = cor_hotfix.c \
core_io.c \
curses.c \
debug.c \
display_control.c \
display_core.c \
display_lives_bar.c \
display_players.c \
display_process_pc.c \
do_live.c \
do_ld.c \
do_st.c \
do_add.c \
do_sub.c \
do_and.c \
do_or.c \
do_xor.c \
do_zjmp.c \
do_ldi.c \
do_sti.c \
do_fork.c \
do_lld.c \
do_lldi.c \
do_lfork.c \
do_aff.c \
draw.c \
freedom.c \
init_progs.c \
keys.c \
last_cycle.c \
main.c \
op_ext.c \
parse.c \
rainbow_road.c \
reap.c \
read_arg.c \
shuffle.c \
sprite.c \
step.c \
validation.c \
verbose.c
SRC_ASM = assembler.c \
arg_parser.c \
check_name_comment.c \
init_program.c \
instruction_parser.c \
main.c \
op_ext.c \
split_syntax.c
SRC_DISASM = disassembler.c \
main.c \
op_ext.c \
validation.c
SRC_CHAMP = affbot.s \
laffbot.s \
marysue.s \
livepls.s \
replicationcentral.s \
doyoulikeforks.s \
plagiarism.s \
synchro0.s \
synchro1.s
OBJ_VM = $(SRC_VM:.c=.o)
OBJ_ASM = $(SRC_ASM:.c=.o)
OBJ_DISASM = $(SRC_DISASM:.c=.o)
OBJ_CHAMP = $(SRC_CHAMP:.s=.cor)
SRCDIR_VM = srcs_vm/
SRCDIR_ASM = srcs_asm/
SRCDIR_DISASM = srcs_disasm/
OBJDIR_VM = objs_vm/
OBJDIR_ASM = objs_asm/
OBJDIR_DISASM = objs_disasm/
SRCDIR_CHAMP = srcs_champ/
OBJDIR_CHAMP = objs_champ/
LIBFT = libs/libft/
MLX = libs/minilibx/
SRCS_VM = $(addprefix $(SRCDIR_VM), $(SRC_VM))
OBJS_VM = $(addprefix $(OBJDIR_VM), $(OBJ_VM))
SRCS_ASM = $(addprefix $(SRCDIR_ASM), $(SRC_ASM))
OBJS_ASM = $(addprefix $(OBJDIR_ASM), $(OBJ_ASM))
SRCS_DISASM = $(addprefix $(SRCDIR_DISASM), $(SRC_DISASM))
OBJS_DISASM = $(addprefix $(OBJDIR_DISASM), $(OBJ_DISASM))
SRCS_CHAMP = $(addprefix $(SRCDIR_CHAMP), $(SRC_CHAMP))
OBJS_CHAMP = $(addprefix $(OBJDIR_CHAMP), $(OBJ_CHAMP))
VM_LIBS = -L $(LIBFT) -lft -L $(MLX) -lmlx -lncurses \
-framework OpenGL -framework AppKit
ASM_LIBS = -L $(LIBFT) -lft
VM_HEADER = -I includes -I $(LIBFT)includes -I $(MLX)
ASM_HEADER = -I includes -I $(LIBFT)includes
CC = gcc
CFLAG = -c
WFLAG = -Wall -Wextra -Werror
VM = corewar
ASM = asm
DISASM = disasm
CHAMP = champions
.PHONY: all $(CHAMP) clean fclean re
.SUFFIXES: .c .o .s .cor
all: $(VM) $(ASM) $(DISASM) $(CHAMP)
#COMPILING VIRTUAL MACHINE
$(OBJDIR_VM)%.o: $(SRCDIR_VM)%.c
@/bin/mkdir -p $(OBJDIR_VM)
@$(CC) $(CFLAG) $(WFLAG) $(VM_HEADER) $< -o $@
$(VM): $(OBJS_VM)
@make -s -C $(LIBFT)
@make -s -C $(MLX)
@$(CC) $(OBJS_VM) $(VM_LIBS) -o $@
@echo "\x1b[33;1m[$(VM) - LADIES AND GENTLEMAN, WELCOME TO THE CORE. "\
"ARE YOU READY FOR COOOOOOOOOOREWAAAAAAR?]\x1b[0m"
@echo
#COMPILING ASSEMBLER
$(OBJDIR_ASM)%.o: $(SRCDIR_ASM)%.c
@/bin/mkdir -p $(OBJDIR_ASM)
@$(CC) $(CFLAG) $(WFLAG) $(ASM_HEADER) $< -o $@
$(ASM): $(OBJS_ASM)
@make -s -C $(LIBFT)
@$(CC) $(OBJS_ASM) $(ASM_LIBS) -o $@
@echo "\x1b[32;1m[$(ASM) - Partcipiants, please line up in an orderly"\
"fashion, and I shall translate your champion source files into the"\
"finest binaries of the land!]\x1b[0m"
@echo
#COMPILING DISASSEMBLER
$(OBJDIR_DISASM)%.o: $(SRCDIR_DISASM)%.c
@/bin/mkdir -p $(OBJDIR_DISASM)
@$(CC) $(CFLAG) $(WFLAG) $(ASM_HEADER) $< -o $@
$(DISASM): $(OBJS_DISASM)
@make -s -C $(LIBFT)
@$(CC) $(OBJS_DISASM) $(ASM_LIBS) -o $@
@echo "\x1b[34;1m[$(DISASM) - Bring me the corpses of your vanquished"\
"champions, and I shall reveal the inner workings of their source"\
"design!]\x1b[0m"
@echo
#COMPILING CHAMPIONS
$(OBJDIR_CHAMP)%.cor: $(SRCDIR_CHAMP)%.s
@/bin/mkdir -p $(OBJDIR_CHAMP)
@echo "\x1b[32;1m[$(ASM) - Now registering champion from $(<)..."\
"]\x1b[0m"
@./$(ASM) $<
@echo "\x1b[33;1mGreetings, $(notdir $(<:.s=.cor)), please proceed to"\
"the arena at $(OBJDIR_CHAMP)\x1b[0m"
@/bin/mv $(<:.s=.cor) $(OBJDIR_CHAMP)
@echo
$(CHAMP): $(OBJS_CHAMP)
clean:
@/bin/rm -rf $(OBJDIR_VM) $(OBJDIR_ASM) $(OBJDIR_DISASM)
@make -s -C $(LIBFT) clean
@make -s -C $(MLX) clean
@echo "\x1b[35;1m[clean - Kicking out crowds from the last"\
"COOOOOOOOOOREWAAAAAAR...]\x1b[0m"
@echo
fclean: clean
@/bin/rm -rf $(VM) $(ASM) $(DISASM) $(LIBFT)libft.a $(OBJDIR_CHAMP)
@echo "\x1b[31;1m[fclean - Demolishing the old colosseum, so an even"\
"fancier new one can be built for the next"\
"COOOOOOOOOOREWAAAAAAR...]\x1b[0m"
@echo
re: fclean all