-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
69 lines (55 loc) · 1.97 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jrameau <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/12/13 11:43:23 by jrameau #+# #+# #
# Updated: 2017/07/04 07:12:16 by nick ### ########.fr #
# #
# **************************************************************************** #
# Project file
NAME = ft_select
# Project builds and dirs
SRCDIR = ./src/
SRCNAMES = $(shell ls $(SRCDIR) | grep -E ".+\.c")
SRC = $(addprefix $(SRCDIR), $(SRCNAMES))
INC = ./inc/
BUILDDIR = ./build/
BUILDOBJS = $(addprefix $(BUILDDIR), $(SRCNAMES:.c=.o))
# Libft builds and dirs
LIBDIR = ./libft/
LIBFT = ./libft/libft.a
LIBINC = ./libft/includes/
# Optimization and Compiler flags and commands
CC = gcc
CFLAGS = -Wall -Werror -Wextra -D_XOPEN_SOURCE=500
# Debugging flags
DEBUG = -ggdb3
# Main rule
all: $(BUILDDIR) $(LIBFT) $(NAME)
# Object dir rule
$(BUILDDIR):
mkdir -p $(BUILDDIR)
# Objects rule
$(BUILDDIR)%.o:$(SRCDIR)%.c
$(CC) $(CFLAGS) -I$(LIBINC) -I$(INC) -o $@ -c $<
# Project file rule
$(NAME): $(BUILDOBJS)
$(CC) $(CFLAGS) -o $(NAME) $(BUILDOBJS) $(LIBFT) -ltermcap
# Libft rule
$(LIBFT):
make -C $(LIBDIR)
# Cleaning up the build files
clean:
rm -rf $(BUILDDIR)
make -C $(LIBDIR) clean
# Getting rid of the project file
fclean: clean
rm -rf $(NAME)
make -C $(LIBDIR) fclean
# Do both of the above
re: fclean all
# Just in case those files exist in the root dir
.PHONY: all fclean clean re