-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
176 lines (150 loc) · 4.37 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: csphilli <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/06/25 09:12:39 by cphillip #+# #+# #
# Updated: 2021/03/11 16:49:23 by csphilli ### ########.fr #
# #
# **************************************************************************** #
# targets
ASM_EXEC = asm
COR_EXEC = corewar
# gcc settings
CC = gcc
CFLAGS = -Wall -Wextra -Wall
INCLUDES = -I includes/ $(LIBFT_INC) $(FT_PRINTF_INC)
# library
LIB_DIR = libft/
LIBFT = $(LIB_DIR)libft.a
LIBFT_INC = -I $(LIB_DIR)includes/
LINK_LIBFT = -L $(LIB_DIR) -lft
# ft_printf
FT_PRINTF_DIR = ft_printf/
FT_PRINTF = $(FT_PRINTF_DIR)libft_printf.a
FT_PRINTF_INC = -I $(FT_PRINTF_DIR)includes/
LINK_FT_PRINTF = -L $(FT_PRINTF_DIR) -lft_printf
# object directories
OBJ_DIR = obj/
TGT_DIR = $(OBJ_DIR)
TGT_DIR += $(addprefix $(OBJ_DIR), $(ASM_DIR) $(COR_DIR))
# files
SRC_DIR = src/
# includes
INC_DIR = includes/
INC_FILES = asm_oplist.h\
asm.h\
op.h\
core.h\
cop.h
INC_SRC = $(addprefix $(INC_DIR), $(INC_FILES))
# assembler
ASM_DIR = asm/
ASM_FILES = ascii_to_hex.c\
calc_arg_type.c\
encode_ins.c\
encoding.c\
set_bytes.c\
split_hex.c\
write_to_file.c\
arg_utils.c\
check_for_newline.c\
check_for_s.c\
error_chk_instructions.c\
errors.c\
ft_pow.c\
get_args.c\
get_data.c\
get_name_comment.c\
handle_labels.c\
hex_to_dec_utils.c\
hex_to_dec.c\
label_calcs.c\
label_utils.c\
label_utils2.c\
name_comment_utils.c\
printing.c\
simp_signs.c\
token_utils.c\
tokenizing.c\
type_parse.c\
asm.c\
duplicate_label_chk.c
ASM_SRC = $(addprefix $(ASM_DIR), $(ASM_FILES))
# assembler objects
ASM_CTO = $(ASM_SRC:.c=.o)
ASM_OBJ = $(addprefix $(OBJ_DIR), $(ASM_CTO))
# corewar
COR_DIR = corewar_src/
COR_FILES = core.c\
core_arg_reader.c\
core_flags.c\
core_players.c\
core_players2.c\
core_carriage.c\
core_play.c\
core_code_handler.c\
core_check.c\
core_execute.c\
core_tools.c\
core_values.c\
core_dump.c\
c_live.c\
c_ld.c\
c_st.c\
c_add.c\
c_sub.c\
c_and.c\
c_or.c\
c_xor.c\
c_zjmp.c\
c_ldi.c\
c_sti.c\
c_fork.c\
c_lld.c\
c_lldi.c\
c_lfork.c\
c_aff.c\
n_arena.c\
n_cases.c\
n_color.c\
n_color2.c\
n_end.c\
n_keys.c\
n_print_update.c\
n_wait.c
COR_SRC = $(addprefix $(COR_DIR), $(COR_FILES))
# corewar objects
COR_CTO = $(COR_SRC:.c=.o)
COR_OBJ = $(addprefix $(OBJ_DIR), $(COR_CTO))
all: $(ASM_EXEC) $(COR_EXEC)
$(TGT_DIR):
@mkdir -p $(TGT_DIR)
$(OBJ_DIR)%.o: $(SRC_DIR)%.c $(INC_SRC)
@$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<
@echo "#\c"
$(LIBFT):
@make -C $(LIB_DIR)
$(FT_PRINTF):
@make -C $(FT_PRINTF_DIR)
$(ASM_EXEC): $(TGT_DIR) $(LIBFT) $(FT_PRINTF) $(ASM_OBJ)
@echo "\nASM files compiled"
@$(CC) $(CFLAGS) $(INCLUDES) $(LINK_LIBFT) $(LINK_FT_PRINTF) -o $@ $(ASM_OBJ)
@echo "Done linking ASM\n"
$(COR_EXEC): $(TGT_DIR) $(LIBFT) $(FT_PRINTF) $(COR_OBJ)
@echo "\nCOREWAR files compiled"
@$(CC) $(CFLAGS) $(INCLUDES) $(LINK_LIBFT) $(LINK_FT_PRINTF) -o $@ $(COR_OBJ) -lncurses
@echo "Done linking COREWAR!"
clean:
@make clean -C $(LIB_DIR)
@make clean -C $(FT_PRINTF_DIR)
@rm -rf $(OBJ_DIR)
fclean: clean
@make fclean -C $(LIB_DIR)
@make fclean -C $(FT_PRINTF_DIR)
@rm -rf $(ASM_EXEC)
@rm -rf $(COR_EXEC)
re: fclean all
.PHONY: all clean fclean re