-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
210 lines (181 loc) · 6.22 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
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
201
202
203
204
205
206
207
208
209
210
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jnovotny <jnovotny@student.hive.fi> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/06/04 16:41:34 by jnovotny #+# #+# #
# Updated: 2020/08/12 17:45:34 by jnovotny ### ########.fr #
# #
# **************************************************************************** #
# Targets
ASM_EXEC = asm
VM_EXEC = corewar
DEASM_EXEC = deasm
# GCC Settings
CC = gcc
CFLAGS = -Wall -Werror -Wextra -O3
LDFLAGS = $(LIBFT_FLAG)
INCLUDES = -I includes/ $(LIBFT_INC)
# ASM Sources
ASM_DIR = asm/
ASM_FILES = asm.c \
cleanup.c \
encoding.c \
check_operations.c \
filename_util.c \
init.c \
print_debug.c \
analysis.c \
to_bytecode.c \
write_header.c \
write_helper.c \
write_exec_code.c \
arg_math.c \
special_args.c \
analysis_utils.c \
argument_checks.c \
encoding_utils.c \
special_arg_utils.c \
utils.c \
utils2.c
ASM_SRC = $(addprefix $(ASM_DIR), $(ASM_FILES))
# DEASM Sources
DEASM_DIR = deasm/
DEASM_FILES = deasm.c \
decode.c \
read.c \
init_clean.c \
utils.c \
write.c
DEASM_SRC = $(addprefix $(DEASM_DIR), $(DEASM_FILES))
# CoreWar Sources
VM_DIR = vm/
VM_FILES = arena.c \
carriage.c \
champs.c \
debug_utils.c \
decode.c \
engine.c \
error.c \
init_colors.c \
load.c \
log.c \
process_carriage.c \
vfx_engine.c \
vfx_init.c \
vfx_keys.c \
vfx_log.c \
vfx_term.c \
vfx_utils.c \
visual.c \
vm.c \
vm_args.c \
vm_args_flags.c \
vm_args_utils.c \
op/op12_fork.c \
op/op16_aff.c \
op/op14.lldi.c \
op/op13_lld.c \
op/op15_lfork.c \
op/op05_sub.c \
op/op06_and.c \
op/op08_xor.c \
op/op02_ld.c \
op/op07_or.c \
op/op10_ldi.c \
op/op11_sti.c \
op/op04_add.c \
op/op03_st.c \
op/op09_zjmp.c \
op/op01_live.c \
op/op_utils.c \
op/op_read.c
VM_SRC = $(addprefix $(VM_DIR), $(VM_FILES))
# Libraries
LIBS_DIR = lib/
## LibFT
LIBFT_DIR = $(LIBS_DIR)libft/
LIBFT_INC = -I $(LIBFT_DIR)includes/
LIBFT = $(LIBFT_DIR)libft.a
LIBFT_FLAG = -L $(LIBFT_DIR) -lft
# Directories and Objects Settings
SRC_DIR = sources/
OBJ_DIR = objects/
TARGET_DIR = $(OBJ_DIR)
TARGET_DIR += $(addprefix $(OBJ_DIR), $(ASM_DIR) $(VM_DIR) $(DEASM_DIR) $(VM_DIR)/op)
ASM_FTO = $(ASM_SRC:.c=.o)
ASM_OBJ = $(addprefix $(OBJ_DIR), $(ASM_FTO))
VM_FTO = $(VM_SRC:.c=.o)
VM_OBJ = $(addprefix $(OBJ_DIR), $(VM_FTO))
DEASM_FTO = $(DEASM_SRC:.c=.o)
DEASM_OBJ = $(addprefix $(OBJ_DIR), $(DEASM_FTO))
# Colors
C_RED = \033[1;31m
C_GREEN = \033[1;32m
C_L_GREEN = \033[1;32m
C_BLUE = \033[1;34m
C_L_BLUE = \033[1;34m
C_WHITE = \033[1;37m
C_EOC = \033[0m
# Tools and Utilities
PROG_BAR = "$(C_RED)▒$(C_EOC)"
LFT_BAR = "▒"
LOGO = yes
LFT_ARG = LOGO=no STATUS=no PROGRESS_CHAR=$(LFT_BAR)
FIRST = yes
.PHONY: all clean fclean re
all: $(ASM_EXEC) $(DEASM_EXEC) $(VM_EXEC)
@echo "\n$(C_GREEN)Finished compiling! Enjoy the bloodbath!$(C_EOC)"
logo:
ifeq (yes, $(LOGO))
@echo "$(C_RED) ▄████▄ ▒█████ ██▀███ ▓█████ █ █░ ▄▄▄ ██▀███ $(C_EOC)"
@echo "$(C_RED)▒██▀ ▀█ ▒██▒ ██▒▓██ ▒ ██▒▓█ ▀ ▓█░ █ ░█░▒████▄ ▓██ ▒ ██▒$(C_EOC)"
@echo "$(C_RED)▒▓█ ▄ ▒██░ ██▒▓██ ░▄█ ▒▒███ ▒█░ █ ░█ ▒██ ▀█▄ ▓██ ░▄█ ▒$(C_EOC)"
@echo "$(C_RED)▒▓▓▄ ▄██▒▒██ ██░▒██▀▀█▄ ▒▓█ ▄ ░█░ █ ░█ ░██▄▄▄▄██ ▒██▀▀█▄ $(C_EOC)"
@echo "$(C_RED)▒ ▓███▀ ░░ ████▓▒░░██▓ ▒██▒░▒████▒░░██▒██▓ ▓█ ▓██▒░██▓ ▒██▒$(C_EOC)"
@echo "$(C_RED)░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░░ ▒░ ░░ ▓░▒ ▒ ▒▒ ▓▒█░░ ▒▓ ░▒▓░$(C_EOC)"
@echo "$(C_RED) ░ ▒ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ░ ░ ▒ ░ ░ ▒ ▒▒ ░ ░▒ ░ ▒░$(C_EOC)"
@echo "$(C_RED)░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ▒ ░░ ░ $(C_EOC)"
@echo "$(C_RED)░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ $(C_EOC)"
@echo "$(C_RED)░ $(C_EOC)"
@echo "\n"
LOGO = no
endif
$(TARGET_DIR): logo
@mkdir -p $(TARGET_DIR)
$(OBJ_DIR)%.o: $(SRC_DIR)%.c
@$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<
@echo $(PROG_BAR)"\c"
$(LIBFT):
@echo "\n[Compiling LibFT]"
@make -C $(LIBFT_DIR) $(LFT_ARG)
@echo "\n[Done]"
@echo "\n[Compiling into object files]"
$(ASM_EXEC): $(TARGET_DIR) $(LIBFT) $(ASM_OBJ)
@echo "\n[ASM Object files ready]"
@echo "[Linking Assembler executable]"
@$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) -o $@ $(ASM_OBJ)
@echo "[Done]"
$(VM_EXEC): $(TARGET_DIR) $(LIBFT) $(VM_OBJ)
@echo "\n[VM Object files ready]"
@echo "[Linking Virtul Machine executable]"
@$(CC) $(CFLAGS) $(LDFLAGS) -lncurses $(INCLUDES) -o $@ $(VM_OBJ)
@echo "[Done]"
$(DEASM_EXEC): $(TARGET_DIR) $(LIBFT) $(DEASM_OBJ)
@echo "\n[DEASM Object files ready]"
@echo "[Linking DeAssembler executable]"
@$(CC) $(CFLAGS) $(LDFLAGS) -lncurses $(INCLUDES) -o $@ $(DEASM_OBJ)
@echo "[Done]"
clean: logo
@make clean -C $(LIBFT_DIR) $(LFT_ARG)
@/bin/rm -rf $(OBJ_DIR)
@echo "\n$(C_RED)[Objects Obliterated!]$(C_EOC)"
fclean: clean
@make fclean -C $(LIBFT_DIR) $(LFT_ARG)
@/bin/rm -rf $(ASM_EXEC)
@/bin/rm -rf $(VM_EXEC)
@/bin/rm -rf $(DEASM_EXEC)
@echo "$(C_RED)[Executables $(ASM_EXEC), $(DEASM_EXEC) and $(VM_EXEC) have been utterly vaporized!]$(C_EOC)"
re: fclean all