~nloomans/ft_select

ft_select/normify.mk -rw-r--r-- 2.6 KiB
f5551145Noah Loomans prevent link breakage in README 1 year, 9 months ago
                                                                                
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
# **************************************************************************** #
#                                                                              #
#                                                         ::::::::             #
#    ft_select                                          :+:    :+:             #
#                                                      +:+                     #
#    By: Noah Loomans                                 +#+                      #
#        <nloomans@student.codam.nl>                 +#+                       #
#                                                   #+#    #+#                 #
#    License: GPLv3                                ########   odam.nl          #
#                                                                              #
# **************************************************************************** #

NAME=ft_select

all: $(NAME)

# Libaries #--------------------------------------------------------------------

LIBFT_NAME=		ft
LIBFT_DIR=		libft
LIBFT_A=		$(LIBFT_DIR)/lib$(LIBFT_NAME).a
LIBFT_IFLAGS=	-I $(LIBFT_DIR)
LIBFT_LFLAGS=	-L $(LIBFT_DIR) -l$(LIBFT_NAME)

$(LIBFT_A):
	$(MAKE) -C $(LIBFT_DIR)

FTPRINTF_NAME=		ftprintf
FTPRINTF_DIR=		libftprintf
FTPRINTF_A=			$(FTPRINTF_DIR)/lib$(FTPRINTF_NAME).a
FTPRINTF_IFLAGS=	-I $(FTPRINTF_DIR)
FTPRINTF_LFLAGS=	-L $(FTPRINTF_DIR) -l$(FTPRINTF_NAME) -ltermcap

$(FTPRINTF_A):
	$(MAKE) -C $(FTPRINTF_DIR)

# Definitions #-----------------------------------------------------------------

SRC_DIR=		src
INC_DIR=		inc
OBJ_DIR=		obj

SRC_FILES=		%SRC_DIR%
INC_FILES=		%INC_DIR%
OBJ_FILES=		$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))

ifeq ($(RENDER),debug)
SRC_FILES+=		src/render.debug.c
else
SRC_FILES+=		src/render.c
endif

CFLAGS=			-Werror -Wall -Wextra -O2 -g
IFLAGS=			-I $(INC_DIR) $(LIBFT_IFLAGS) $(FTPRINTF_IFLAGS)
LFLAGS=			$(LIBFT_LFLAGS) $(FTPRINTF_LFLAGS)

# Regular rules #---------------------------------------------------------------

$(NAME): $(OBJ_FILES) $(LIBFT_A) $(FTPRINTF_A)
	$(CC) -o $@ $(OBJ_FILES) $(CFLAGS) $(LFLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_FILES)
	@mkdir -p $$(dirname $@)
	$(CC) -o $@ -c $< $(CFLAGS) $(IFLAGS)

# Phonies #---------------------------------------------------------------------

clean:
	@$(MAKE) -C $(LIBFT_DIR) fclean
	@$(MAKE) -C $(FTPRINTF_DIR) fclean
	@rm -rf $(OBJ_DIR)

fclean: clean
	@$(MAKE) -C $(LIBFT_DIR) fclean
	@$(MAKE) -C $(FTPRINTF_DIR) fclean
	@rm -f $(NAME)

re:
	@$(MAKE) fclean
	@$(MAKE)

# Special #---------------------------------------------------------------------

.SECONDARY: $(OBJ_FILES)
.PHONY: all clean fclean re