This repository was archived by the owner on Nov 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (56 loc) · 2.38 KB
/
Copy pathMakefile
File metadata and controls
70 lines (56 loc) · 2.38 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
# **************************************************************************** #
# LE - / #
# / #
# Makefile .:: .:/ . .:: #
# +:+:+ +: +: +:+:+ #
# By: shorwood <shorwood@student.le-101.fr> +:+ +: +: +:+ #
# #+# #+ #+ #+# #
# Created: 2018/07/16 12:26:44 by shorwood #+# ## ## #+# #
# Updated: 2019/04/30 07:11:30 by shorwood ### #+. /#+ ###.fr #
# / #
# / #
# **************************************************************************** #
#--- Initialize compilation/linkeage parameters.
NAME = libft
DSRC = src
DINC = include
DBLD = build
DBIN = bin
DLIB = lib
CFLAGS = -Wall -Werror -Wextra
IFLAGS = -I$(DINC)
LDFLAGS =
#--- Set source project dependencies.
SRC = $(wildcard $(DSRC)/*/*.c)
INC = $(wildcard $(DINC)/*.h)
BLD = $(patsubst $(DSRC)/%.c,$(DBLD)/%.o,$(SRC))
# **************************************************************************** #
all: $(NAME)
#--- Default instruction to make the library.
$(NAME): $(DLIB)/$(NAME).a $(INC)
#--- Assemble into a static library. Depends on compiled object binary.
$(DLIB)/$(NAME).a: $(BLD)
@mkdir -p $(dir $@)
@ar rus $@ $? 2> /dev/null
@echo "\r\033[K• Library '$(notdir $@)' compiled"
#--- Compile into an object binary. Depends on source code.
$(DBLD)/%.o: $(DSRC)/%.c
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $(LDFLAGS) $(IFLAGS) $< -o $@ -c
@printf "\r\033[K• Compiled '$<'"
# **************************************************************************** #
test: $(NAME)
make -C test
# **************************************************************************** #
clean:
-@rm $(DBLD)/**/*.o 2> /dev/null || true
-@rm -r $(DBLD) 2> /dev/null || true
@echo "• Deleted '$(NAME)' object files"
fclean: clean
@rm -f $(DBIN)/$(NAME)
@rm -f $(DLIB)/$(NAME)
@rm -r $(DBIN) 2> /dev/null || true
@rm -r $(DLIB) 2> /dev/null || true
@echo "• Deleted '$(NAME)' library & binaries"
re: fclean all
.PHONY: clean fclean all re