-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (47 loc) · 1.74 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
NAME = woody_woodpacker
SHELL = /bin/bash
AC = nasm
CC = gcc
AFLAGS = -f elf64
CFLAGS = -g -Wall -Wextra -Werror
LIBFT_DIR = libft/
LIBFT_NAME = libft.a
LIBFT = $(addprefix $(LIBFT_DIR), $(LIBFT_NAME))
SRCS_DIR = srcs/
C_SRCS = $(addprefix $(SRCS_DIR), $(SRCS_LIST))
ASM_SRCS = $(addprefix $(SRCS_DIR), $(SRCS_LIST))
C_SRCS_LIST = expand_elf.c get_elf.c handle_elf.c key.c \
handle_file.c inject_woody.c main.c prepare_woody.c
ASM_SRCS_LIST = loader.s cpr_algo.s
OBJS_DIR = objs/
OBJS_LIST := $(patsubst %.c, %.o, $(C_SRCS_LIST)) $(patsubst %.s, %.o, $(ASM_SRCS_LIST))
OBJS = $(addprefix $(OBJS_DIR), $(OBJS_LIST))
HEADERS = -I ./includes -I ./libft/includes -I ./includes/sys
LIBS = -L libft -lft
.PHONY : all clean fclean re
all : $(NAME)
$(NAME) : $(LIBFT) $(OBJS)
@echo "\033[37mLinking...\033[0m"
@$(CC) $(CFLAGS) $^ $(LIBS) -o $@
@echo "\033[32mBinary \033[1;32m$(NAME)\033[1;0m\033[32m created.\033[0m"
$(OBJS_DIR)%.o : $(SRCS_DIR)%.c includes/*.h
@mkdir -p $(OBJS_DIR)
@$(CC) $(CFLAGS) $(HEADERS) -c $< -o $@
@echo "\033[34mCompilation of \033[36m$(notdir $<)\033[34m done.\033[0m"
$(OBJS_DIR)%.o : $(SRCS_DIR)%.s includes/*.h
@mkdir -p $(OBJS_DIR)
@$(AC) $(AFLAGS) $< -o $@
@echo "\033[34mCompilation of \033[36m$(notdir $<)\033[34m done.\033[0m"
$(LIBFT) :
@make --no-print-directory -C $(LIBFT_DIR)
clean :
@make clean --no-print-directory -C $(LIBFT_DIR)
@rm -rf $(OBJS_DIR)
@echo "\033[31mObjects files \033[1;31m$(OBJS_LIST)\033[1;0m\033[31m removed.\033[0m"
fclean : clean
@rm -rf $(LIBFT)
@echo "\033[31mLib \033[1;31m$(notdir $(LIBFT))\033[1;0m\033[31m removed.\033[0m"
@rm -rf $(OBJS_DIR)
@rm -rf $(NAME)
@echo "\033[31mBin \033[1;31m$(NAME)\033[1;0m\033[31m removed.\033[0m"
re : fclean all