-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (98 loc) · 4.57 KB
/
Makefile
File metadata and controls
117 lines (98 loc) · 4.57 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: bkonjuha <bkonjuha@student.hive.fi> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/08/02 15:57:46 by bkonjuha #+# #+# #
# Updated: 2020/09/22 09:11:10 by bkonjuha ### ########.fr #
# #
# **************************************************************************** #
ASM = asm
COREWAR = corewar
ASM_SRC_PATH = ./sources/assembler/
COREWAR_SRC_PATH = ./sources/vm/
ASM_SRC_FILES = check_args.c set_flags.c handle_error.c handle_d_and_f_flags.c \
find.c handle_strs.c get_op.c parse_file.c asm_gnl_utils.c \
tokenize.c validate_characters.c check_for_lexical_error.c \
handle_error_msg.c handle_tokens.c copy.c check_tokens.c \
set_champ.c parse_file_utils.c make_cor_file.c \
insert_bytes_number.c insert_statements.c get_arg_code.c \
write_hexdump.c free_memory.c validate_file.c dasm.c dasm2.c dasm3.c
COREWAR_SRC_FILES = ft_errno.c initialize.c parse_input.c validate_champions.c \
run_cycles.c print_arena.c validate_encoding.c operations/op_add.c \
operations/op_aff.c operations/op_and.c operations/op_fork.c \
operations/op_ld.c operations/op_ldi.c operations/op_lfork.c \
operations/op_live.c operations/op_lld.c operations/op_lldi.c \
operations/op_or.c operations/op_st.c operations/op_sti.c \
operations/op_sub.c operations/op_xor.c operations/op_zjmp.c \
load_champions.c parse_input2.c get_addr.c get_args.c \
proc_functions.c operations/utils.c winner.c \
visual/start_visualizer.c visual/create_color_pairs.c \
visual/draw_arena.c visual/get_attribute.c visual/print_winner.c \
visual/init_visualizer.c visual/draw_footer.c \
visual/draw_player_info.c visual/draw_players.c visual/draw_logo.c \
visual/draw_battle_info.c visual/debugger.c flag_reader.c
ASM_SRC = $(addprefix $(ASM_SRC_PATH), $(ASM_SRC_FILES))
COREWAR_SRC = $(addprefix $(COREWAR_SRC_PATH), $(COREWAR_SRC_FILES))
A_MAIN_PATH = ./sources/assembler/
C_MAIN_PATH = ./sources/vm/
A_MAIN = asm.c
C_MAIN = corewar.c
A = $(addprefix $(A_MAIN_PATH), $(A_MAIN))
C = $(addprefix $(C_MAIN_PATH), $(C_MAIN))
INCLUDES = -I ./includes/ -I ./libft/incls/
HEADER_PATH = ./includes/
HEADER_FILES = asm.h corewar.h corewar_error.h visu.h op.h
HEADERS = $(addprefix $(HEADER_PATH), $(HEADER_FILES))
COMPILE = gcc -Wall -Wextra -Werror
NCURSES = -lncurses
LIBFT_SRCS = ./libft/srcs/
LIBFT_PATH = ./libft/
LIBFT_FILE = libft.a
LIBFT = $(addprefix $(LIBFT_PATH), $(LIBFT_FILE))
FT_PRINTF_SRCS = ./libft/srcs/ft_printf/
ASM_MANPAGE = ./sources/asm_man
COREWAR_MANPAGE = ./sources/corewar_man
ASM_MAN_LOCATION = sources/man/man1/asm.1
COREWAR_MAN_LOCATION = sources/man/man1/corewar.1
GZIP = gzip
CP = cp
COLOR_RESET = \033[0m
COLOR_PENDING = \033[0;33m
COLOR_SUCCESS = \033[0;32m
COLOR_DEFAULT = \033[1;34m
all: $(ASM) $(COREWAR)
$(ASM): $(LIBFT) $(HEADERS) $(A) $(ASM_SRC)
@$(COMPILE) $(INCLUDES) $(A) $(ASM_SRC) $(LIBFT) -o $(ASM)
@echo "[$(COLOR_PENDING)Putting everything together$(COLOR_RESET)]"
@echo "[$(COLOR_SUCCESS)Executable $(ASM) created$(COLOR_RESET)]"
$(COREWAR): $(LIBFT) $(HEADERS) $(C) $(COREWAR_SRC)
@$(COMPILE) $(NCURSES) $(INCLUDES) $(C) $(COREWAR_SRC) $(LIBFT) -o $(COREWAR)
@echo "[$(COLOR_PENDING)Putting everything together$(COLOR_RESET)]"
@echo "[$(COLOR_SUCCESS)Executable $(COREWAR) created$(COLOR_RESET)]"
$(LIBFT): $(LIBFT_SRCS)*.c $(FT_PRINTF_SRCS)*.c
@echo "Recompiling library"
@make -C libft/
man:
mkdir -p sources/man/man1
@$(CP) -f $(ASM_MANPAGE) $(ASM_MAN_LOCATION)
@$(GZIP) -f $(ASM_MAN_LOCATION)
@$(CP) -f $(COREWAR_MANPAGE) $(COREWAR_MAN_LOCATION)
@$(GZIP) -f $(COREWAR_MAN_LOCATION)
exec: $(LIBFT)
@$(COMPILE) $(INCLUDES) $(A) $(ASM_SRC) $(LIBFT) -o $(ASM)
@$(COMPILE) $(NCURSES) $(INCLUDES) $(C) $(COREWAR_SRC) $(LIBFT) -o $(COREWAR)
clean:
@make clean -C libft/ > /dev/null
mclean:
@rm -f $(ASM_MAN_LOCATION).gz
@rm -f $(COREWAR_MAN_LOCATION).gz
@rm -rf ./sources/man
fclean: clean
@rm -fv $(ASM) > /dev/null
@rm -fv $(COREWAR) > /dev/null
@make fclean -C libft/ > /dev/null
re: fclean all
.PHONY = all exec clean mclean fclean re man